我正在從Michael Hartl的教程學習Ruby on Rails。
現在我被困在9.2.1章。
下面是書中的代碼:
Ruby on Rails(Michael Hart教程)授權錯誤(章節9.2.1)
authentication_pages_spec.erb 需要 'spec_helper'
describe "Authentication" do
subject { page }
describe "signin" do
before { visit signin_path }
describe "with invalid information" do
before { click_button "Sign in" }
it { should have_title('Sign in') }
it { should have_selector('div.alert.alert-error', text: 'Invalid') }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
end
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
it { should have_title(user.name) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Settings', href: edit_user_path(user)) }
it { should have_link('Sign out', href: signout_path) }
it { should_not have_link('Sign in', href: signin_path) }
describe "followed by signout" do
before { click_link "Sign out" }
it { should have_link('Sign in') }
end
end
describe "authorization" do
describe "for non-signed-in users" do
let(:user) { FactoryGirl.create(:user) }
describe "in the Users controller" do
describe "visiting the edit page" do
before { visit edit_user_path(user) }
it { should have_title('Sign in') }
end
describe "submitting to the update action" do
before { put user_path(user) }
specify { response.should redirect_to(signin_path) }
end
end
end
end
end
但是當我測試:
rspec spec/
有2級的錯誤,我不t知道如何解決在線:
it { should have_title('Sign in') }
和線路:
specify { response.should redirect_to(signin_path) }
以下是錯誤圖像: http://i.stack.imgur.com/85WaX.png
這些是什麼錯誤? –
哎呀,對不起! 這是圖像。 http://i.stack.imgur.com/85WaX.png –