Here’s the relevant test:
#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
The failure message:
1) Posts pages edit
Failure/Error: it { should have_selector('title', "Editing #{post.title}" ) }
expected css "Editing unde inventore illo accusamus" to return something
However, when the page opens in my browser via save_and_open_page, the title is correct and it has opened the correct edit page. I double-checked for any typos in the template vs. the test, and it matches up.
So what am I missing?
Your syntax for
have_selectoris wrong. Try this: