0
以下是相關測試:Rspec的測試與水豚即使save_and_open_page未能正確
#spec/requests/posts_spec.rb
require 'spec_helper'
describe "Posts pages" do
subject { page }
describe "edit" do
let (:post) { Post.order('release_date desc').first }
before do
visit posts_path
within(:css, "div#post_#{post.id}") { click_link "Edit" }
save_and_open_page # has correct title
end
it { should have_selector('title', "Editing #{post.title}") } # fails
end
end
失敗消息:
1) Posts pages edit
Failure/Error: it { should have_selector('title', "Editing #{post.title}") }
expected css "Editing unde inventore illo accusamus" to return something
然而,當頁面在瀏覽器中通過save_and_open_page
打開,標題是正確的,它已打開正確的edit
頁面。我仔細檢查模板中的任何拼寫錯誤與測試,並且匹配。
那麼我錯過了什麼?
嘗試使用調試器,並與您的數據一起玩,以確定是否丟失或不正確。 – 2012-08-07 23:36:18