I'd like to set a variable using "given" (or "let") that is accessible by all of the "features" within my spec.rb file. How do I do this? Where should the "given" statement be located within the file? Thanks!
require 'spec_helper'
feature "Home page" do
given(:base_title) { "What Key Am I In?" }
scenario "should have the content 'What Key Am I In?'" do
visit '/static_pages/home'
expect(page).to have_content('What Key Am I In?')
end
scenario "should have the title 'What Key Am I In? | Home'" do
visit '/static_pages/home'
expect(page).to have_title("#{base_title}")
end
scenario "should not have a custom page title | Home'" do
visit '/static_pages/home'
expect(page).not_to have_title("| Home")
end
end
feature "About page" do
scenario "should have the content 'About'" do
visit '/static_pages/about'
expect(page).to have_content('About')
end
scenario "should have the title 'What Key Am I In? | About'" do
visit '/static_pages/about'
expect(page).to have_title('What Key Am I In? | About')
end
end