1
嗨,我是一名通過Hartl工作的新手。在最近發生的災難之後,我已經能夠將我的應用恢復到接近工作狀態(謝謝Github!)。我現在在測試中遇到了一個錯誤。所以,當我運行測試,我得到:Ruby on Rails教程Michael Hartl第7.25章
sis-macbook-pro:sample_app Lagaspi$ bundle exec rspec spec/
..............................F
Failures:
1) User pages signup with valid information after saving the user
Failure/Error: it { should have_link('Sign out') }
expected link "Sign out" to return something
# ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'
Finished in 0.61988 seconds
31 examples, 1 failure
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:48 # User pages signup with valid information after saving the user
這裏是我的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) }
describe "signup" do
before { visit signup_path }
it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end
it { should have_selector('h1', text: user.name) }
it { should have_selector('title', text: user.name) }
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
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "[email protected]"
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 }
it { should have_link('Sign out') }
end
end
end
end
在此先感謝。
你能解釋一下這個請我是新手! –
嗨,據我所知:1)可能鏈接丟失2)鏈接的名稱是不同於'退出'3)點擊按鈕'提交'後,沒有'退出'鏈接的行動。我也是一個新手:) – juanitofatas
那麼我需要一個「退出」頁面?我如何把這個權利? –