1

Weirdly, the test suite is passing or failing intermittently. And I'm at a loss to work out why? I am changing nothing, just running the test over a over. Sometimes its green, other times its red.

Error message displayed for each error below:

Failure/Error: before { sign_in user }
     NoMethodError:
       undefined method `sign_in' for #<RSpec::Core::ExampleGroup::Nested_2::Nested_2::Nested_2::Nested_1:0x0000000577cb58>


65 examples, 9 failures

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:71 # User pages signup edit page 
rspec ./spec/requests/user_pages_spec.rb:73 # User pages signup edit page 
rspec ./spec/requests/user_pages_spec.rb:72 # User pages signup edit page 
rspec ./spec/requests/user_pages_spec.rb:97 # User pages signup edit with valid information 
rspec ./spec/requests/user_pages_spec.rb:96 # User pages signup edit with valid information 
rspec ./spec/requests/user_pages_spec.rb:95 # User pages signup edit with valid information 
rspec ./spec/requests/user_pages_spec.rb:94 # User pages signup edit with valid information 
rspec ./spec/requests/user_pages_spec.rb:93 # User pages signup edit with valid information 
rspec ./spec/requests/user_pages_spec.rb:79 # User pages signup edit with invalid information

user_pages_spec.rb

require 'spec_helper'

describe "User pages" do

  subject { page }

  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

  describe "signup page" do
    before { visit signup_path }

    it { should have_content('Sign up') }
    it { should have_title(full_title('Sign up')) }
  end

  describe "signup" do

    before { visit signup_path }

    let(:submit) { "Create my account" }

    describe "with invalid information" do
      it "should not create a user" do
        expect { click_button submit }.not_to change(User, :count)
      end

      describe "after submission" do
        before { click_button submit }

        it { should have_title('Sign up') }
        it { should have_content('error') }
      end
    end

    describe "with valid information" do
      before do
        fill_in "Name",         with: "Example User"
        fill_in "Email",        with: "user@example.com"
        fill_in "Password",     with: "foobar"
        fill_in "Confirmation", with: "foobar"
      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: 'user@example.com') }

        it { should have_link('Sign out') }
        it { should have_title(user.name) }
        it { should have_selector('div.alert.alert-success', text: 'Welcome') }
      end
    end

    describe "edit" do
      let(:user) { FactoryGirl.create(:user) }
      before do
        sign_in user
        visit edit_user_path(user)
      end

      describe "page" do
        it { should have_content("Update your profile") }
        it { should have_title("Edit user") }
        it { should have_link('change', href: 'http://gravatar.com/emails') }
      end

      describe "with invalid information" do
        before { click_button "Save changes" }

        it { should have_content('error') }
      end

      describe "with valid information" do
        let(:new_name)  { "New Name" }
        let(:new_email) { "new@example.com" }
        before do
          fill_in "Name",             with: new_name
          fill_in "Email",            with: new_email
          fill_in "Password",         with: user.password
          fill_in "Confirm Password", with: user.password
          click_button "Save changes"
        end

        it { should have_title(new_name) }
        it { should have_selector('div.alert.alert-success') }
        it { should have_link('Sign out', href: signout_path) }
        specify { expect(user.reload.name).to  eq new_name }
        specify { expect(user.reload.email).to eq new_email }
      end
    end
  end
end
2
  • 1
    You never actually defined the sign_in method. Is that defined elsewhere? Sep 9, 2013 at 22:45
  • Thanks. I had somehow deleted 'include ApplicationHelper' from the top of 'spec/support/utilities.rb'
    – rclark
    Sep 10, 2013 at 15:33

1 Answer 1

0

I had somehow deleted 'include ApplicationHelper' from the top of 'spec/support/utilities.rb'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.