0
votes

I am reading M. Hart's Rails tutorial book now. Stopped at 9.2.1 because of error in testing redirection after patch request. Use Ruby on Rails 4.1 framework, my app's gems:

  ruby '2.0.0'
  gem 'rails', '4.1.0'
  ...
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.1'
  gem 'rspec-rails', '2.13.1'

I have UsersController

class UsersController < ApplicationController
  before_action :signed_in_user, only: [:edit, :update]

  #actions...
  private
    #strong parameters...

    def signed_in_user
      redirect_to signin_url, notice: "Please sign in." unless signed_in?
    end
end

My Rspec+Capybara test for redirection:

describe "Authentication" do
  subject { page }

  describe "authorization" do
    describe "for non-signed-in users" do
      let(:user) { FactoryGirl.create(:user) }

      describe "in the Users controller" do
        #...
        describe "submitting to the update action" do
          before { patch user_path(user) }
          specify { expect(response).to redirect_to(signin_path) }
        end
      end
    #...
end

And when I run rspec spec/

 1) Authentication authorization for non-signed-in users in the Users controller submitting to the update action 
     Failure/Error: specify { expect(response).to redirect_to(signin_path) }
     NoMethodError:
       undefined method `assertions' for #<RSpec::Rails::TestUnitAssertionAdapter::AssertionDelegator:0xae34810>
     # ./spec/requests/authentication_pages_spec.rb:23:in `block (6 levels) in <top (required)>'

What's wrong?

1

1 Answers

0
votes

Use:

gem "rspec-rails", '~> 2.14.0'

as per this previously answered question:

Rails 4 and RSpec, undefined method `assertions' in routing spec

Note that the gem is no longer an rc, so you should be able to use the release version.