【发布时间】:2014-08-14 16:31:28
【问题描述】:
我现在正在阅读 M. Hart 的 Rails 教程。由于补丁请求后测试重定向出错,在 9.2.1 停止。使用 Ruby on Rails 4.1 框架,我的应用程序的瑰宝:
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'
我有用户控制器
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
我的 Rspec+Capybara 重定向测试:
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
当我运行 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)>'
怎么了?
【问题讨论】:
标签: ruby-on-rails rspec tdd capybara