Reputation: 359
Getting the following errors when I run 'bundle exec rspec spec/requests/static_pages_spec.rb:
9 examples, 2 failures
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:56 # Static pages Contact page should have the title 'Contact page'
rspec ./spec/requests/static_pages_spec.rb:51 # Static pages Contact page should have the content 'Contact page'
I can't figure out how to get the two tests to pass here.
Trying to get through the tutorial here, learning, very new (I believe this is the code):
describe "Contact page" do
it "should have the content 'Contact'" do
visit '/static_pages/contact'
expect(page).to have_content('Contact')
end
it "should have the title 'Contact'" do
visit '/static_pages/contact'
expect(page).to have_content("Ruby on Rails Tutorial Sample App | Contact")
end
end
end
Additionally, the html file:
<% provide(:title, 'Contact') %>
<h1>Contact</h1>
<p>
Contact Ruby on Rails Tutorial about the sample app at the
<a href="http://railstutorial.org/contact">contact page</a>.
</p>
Upvotes: 0
Views: 926
Reputation:
You're expecting the title with have_content and expecting the content with have_title.
Try
expect(page).to have_title('Contact')
and
expect(page).to have_content("Ruby on Rails Tutorial Sample App | Contact")
Actually you need to reword this last one a little because this is not the content you have in the view but you get the idea.
Upvotes: 1