Reputation: 351
RSpec is saying everything is fine and dandy with my Help page, but it shouldn't be. What would cause the false positive. (I have restarted my test suite several times).
Here's my spec page:
require 'spec_helper'
describe "Static pages" do
subject { page }
shared_examples_for "all static pages" do
it { should have_selector 'h1', text: heading }
it { should have_selector 'title', text: full_title(page_title) }
end
.
.
.
describe "Help page" do
before { visit help_path }
let(:heading) { 'Help' }
let(:page_title) { 'Help' }
end
.
.
.
end
Here's my Help page:
<% provide(:title, '') %>
<h1></h1>
<p>
Get help on the Ruby on Rails Tutorial at the
<a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
To get help on this sample app, see the
<a href="http://railstutorial.org/book">Rails Tutorial book</a>.
</p>
It's saying the tests pass. How to fix?
Upvotes: 1
Views: 519
Reputation: 1086
Looks like you're missing:
it_should_behave_like 'all static pages'
in the describe 'Help Page'
block. You've defined the shared examples for 'all static pages' but are not telling rspec that the 'Help Page' should behave like one.
Also, please look this answer to a very similar question. It shows how you might refactor your specs to express intent more clearly.
Upvotes: 3