To save your structure - you can change the code like this:
require 'spec_helper'
describe "Pages" do
describe "navigation" do
shared_examples_for 'main page' do |path_name|
before { visit send(path_name) }
it "should be on #{path_name}" do
page.should have_link('Home')
page.should have_link('Inventory')
page.should have_link('FAQ')
page.should have_link('About Us')
page.should have_link('Location')
page.should have_link('Contact Us')
# page.should have_link('Login')
end
end
it_should_behave_like 'main_page', :root_path
it_should_behave_like 'main_page', :faq_path
it_should_behave_like 'main_page', :about_path
it_should_behave_like 'main_page', :location_path
it_should_behave_like 'main_page', :contact_path
# it_should_behave_like 'main_page', :login_path
end
end
because "paths are not defined at the class level in specs"(c)
You cannot call path methods in spec class. It should be in it
block.
And your structure is not perfect. It will be better to put code in modules and then include it, if you want to avoid the duplication.