Created
April 10, 2014 12:21
-
-
Save JasonY1/10375945 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe "User pages" do | |
| subject { page } | |
| # Profile page tests | |
| describe "profile page" do | |
| let(:user) { FactoryGirl.create(:user) } | |
| before { visit user_path(user) } | |
| it { should have_content(user.name) } | |
| it { should have_title(user.name) } | |
| end | |
| # Signup page test | |
| describe "signup page" do | |
| before { visit signup_path } | |
| it { should have_content('Sign up') } | |
| it { should have_title(full_title('Sign up')) } | |
| end | |
| #signup function test | |
| describe "signup" do | |
| before { visit signup_path } | |
| let(:submit) { "Create my account" } | |
| describe "with invalid information" do | |
| it "should no create a user" do | |
| expect { click_button submit }.not_to change(User, :count) | |
| end | |
| end | |
| describe "with valid information" do | |
| before do | |
| fill_in "Name", with: "User Name" | |
| fill_in "Email", with: "[email protected]" | |
| fill_in "Password", with: "password" | |
| fill_in "Confirmation", with: "password" | |
| end | |
| it "should create a user" do | |
| expect { click_button submit }.to change(User, :count).by(1) | |
| end | |
| describe "after saving the user" do | |
| before { click_button submit } | |
| let(:user) { User.find_by(email: '[email protected]') } | |
| it { should have_link('Sign out') } | |
| it { should have_title(user.name) } | |
| it { should have_selector('div.alert.alert-success', text: 'Welcome') } | |
| end | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Failures:
Failure/Error: it { should have_title(user.name) }
NoMethodError:
undefined method `name' for nil:NilClass
./spec/requests/user_pages_spec.rb:52:in`block (5 levels) in <top (required)>'
Finished in 1.42 seconds
50 examples, 1 failure
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:52 # User pages signup with valid information after saving the user
Randomized with seed 861