Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller tests - Don't merge #33

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions db/migrate/20150122232003_remove_upvotes.rb

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrate/20150127020039_drop_scrapes.rb

This file was deleted.

2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150127020039) do
ActiveRecord::Schema.define(version: 20150127015409) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down
47 changes: 30 additions & 17 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
RSpec.describe UsersController, :type => :controller do


#INDEX
describe "GET #index" do
it "responds successfully with an HTTP 200 status code" do
get :index
expect(response).to be_success
expect(response).to have_http_status(200)
end
get :index
expect(response).to be_success
expect(response).to have_http_status(200)
end

it "renders the index template" do
get :index
expect(response).to render_template("index")
end
end

# describe "GET #show" do
# it "assigns the requested user to @user" do
# user = FactoryGirl.build(:a_user)
# get :show, id: user
# assigns(:user).should eq(user)
# end
#SHOW
describe "GET #show" do
it "assigns the requested user to @user" do
user = FactoryGirl.create(:user)
get :show, id: user
expect(assigns(:user)).to eq(user)
end

# it "renders the #show view" do
# user = FactoryGirl.build(:a_user)
# get :show, id: user
# response.should render_template :show
# end
it "renders the #show view" do
user = FactoryGirl.create(:user)
get :show, id: user
expect(response).to render_template :show
end
end

#NEW
describe "GET #new" do
it "renders the new template" do
get :new
expect(response).to render_template("new")
end
end

# end
#CREATE

#EDIT
#UPDATE
end
15 changes: 8 additions & 7 deletions spec/factories/user_factory.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FactoryGirl.define do

FactoryGirl.define do
sequence :email do |n|
"test#{n}@example.com"
end

#Creating an example user in this factory allows us to reference it in the rspec file
factory :a_user, class: User do

factory :user do
name "Dummy"
email "[email protected]"
password "dummy"

email
password "dummy1234"
# password has to be minimum 8 characters due to validation
end

end
12 changes: 12 additions & 0 deletions spec/support/factory_girl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods

config.before(:suite) do
begin
#DatabaseCleaner.start
FactoryGirl.lint
ensure
#DatabaseCleaner.clean
end
end
end