I'l slowly working my way through Michael Hartl's excellent Ruby on Rails Tutorial. All was going very well.. until the exercises in Chapter 5 that is. Now I'm very stuck. After making changes detailed in the actual exercises section, my RSpec tests are now failing.
- Note that I am running SPORK (but that tests also fail when I am not using SPORK).
Here is an example of the output I get from each static page tested :
Static pages Home page it should behave like all static pages Failure/Error: it { should have_selector('title', text: full_title(page_title)) } TypeError: can't convert RSpec::Matchers::BuiltIn::Include to String Shared Example Group: "all static pages" called from ./spec/requests/static_pages_spec.rb:19 # (eval):2:in
has_selector?' # ./spec/requests/static_pages_spec.rb:9:in
block (3 levels) in '
Here is static_pages_spec.rb :
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 "Home page" do
before { visit root_path }
before { visit root_path }
let(:heading) { 'Sample App' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_selector 'title', text: '| Home' }
end
describe "Help page" do
before { visit root_path }
before { visit root_path }
let(:heading) { 'Sample App' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_selector 'title', text: '| Help' }
end
describe "About page" do
before { visit root_path }
let(:heading) { 'Sample App' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_selector 'title', text: '| About' }
end
describe "Contact page" do
before { visit root_path }
let(:heading) { 'Sample App' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_selector 'title', text: '| Contact' }
end
rails console
(with that exact command) and then tryfull_title('test')
– alf