Take this scenario. I have a Google Analytics tracking code, and I only want it to show up in Production mode. So I might have two scenarios like this:
Scenario: Don't embed tracking code in development or test mode
  Given the app is not in production mode
  When I go home
  Then I should really not see the tracking code
Scenario: Embed tracking code in production mode
  Given the app is in production mode
  When I go home
  Then I should really see the tracking code
So although I know how to check what the current environment is, and I know how to set the current environment in Rails or Sinatra, I have no idea how to run a specific scenario in a specific environment. Is it even possible?
I think you should really hit the live URL of your website using cucumber; because that's what you probably really want to know-- is my tracking running, like for real?
This worked for me, but you'll need to use Capybara (perhaps someone will post a similar webrat solution if it exists).
Given /^the app is in production mode$/ do
  Capybara.current_driver = :selenium
  Capybara.app_host = 'http://www.joshcrews.com'
end
When /^I go home$/ do
  visit("http://www.joshcrews.com")
end
Then /^I should really see the tracking code$/ do
  page.body.should match /UA-7396376-1/
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With