Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 982847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:45:48+00:00 2026-05-16T04:45:48+00:00

Take this scenario. I have a Google Analytics tracking code, and I only want

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:45:49+00:00Added an answer on May 16, 2026 at 4:45 am

    You should be able to force the environment in the test code itself, something along the lines of
    ENV['RACK_ENV'] = 'test'
    ENV['RACK_ENV'] = 'production'

    I would consider it a pretty bad code smell though.

    I have had to mess about with environments before(http://richardconroy.blogspot.com/2010/01/issues-testing-sinatra-datamapper-app.html), to get test code to recognise that it should be executing against test environments. This is just doing it backwards I suppose.

    Still, aren’t google analytics tracking cookies site specific? Having the tracking cookie in your development/test/staging environment shouldn’t influence your stats.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take this scenario: You have a few flag enumerations in C# tied to (and
I have a tricky scenario whereby I want to add ScriptManager scriptreference only on
Which threading model is best for this scenario: I have a process can take
I have this scenario. The app allows me to take a pic of something
How do i create aliases in c# Take this scenario class CommandMessages { string
Take this example code (ignore it being horribly inefficient for the moment) let listToString
Take this code into consideration: Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port)); try
Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site
I have this scenario wherein I get a linear equation in the Prolog query
I have a scenario that looks like this: User A is a registered user.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.