I am working with the let function in an rspec file. I wanted to use the let function to replace the use of string instance variables like I have used with @astr below.
describe "Static pages" do
let (:str) { "Ruby on Rails Tutorial Sample App" }
describe "Contact Page" do
it "should have title 'Contact'" do
@astr = "Ruby on Rails Tutorial Sample App"
visit '/static_pages/contact'
expect(page).to have_title("#{@astr} | Contact")
end
end
...
Which becomes
it "should have title 'Contact'" do
visit '/static_pages/contact'
expect(page).to have_title("#{str} | Contact")
end
What is confusing me is why #{str} works and #{:str} does not - dereference a symbol -, just as we keep the '@' for #{@astr}, why is the convention not applied to the colon in symbols?