Skip to content

Instantly share code, notes, and snippets.

@zmoazeni
Created May 24, 2009 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zmoazeni/71a30f8d26928dfe9663 to your computer and use it in GitHub Desktop.
Save zmoazeni/71a30f8d26928dfe9663 to your computer and use it in GitHub Desktop.
## New class
class EnvChecker
def self.production?
ENV['RAILS_ENV'] == 'production'
end
def self.development?
ENV['RAILS_ENV'] == 'development'
end
end
## Helper snipbit
### Instead of this:
...
def swfobject_tag(source, options={})
path = swfobject_path(source)
verify_file_exists = options.fetch(:verify_file_exists, ENV['RAILS_ENV'] == 'development')
...
### Use this
...
def swfobject_tag(source, options={})
path = swfobject_path(source)
verify_file_exists = options.fetch(:verify_file_exists, EnvChecker.development?)
...
## In Helper Spec
### Instead of:
...
before(:each) do
ENV['RAILS_ENV'] = 'production'
self.stub!(:compute_public_path).and_return('/applets/url.swf')
end
...
### Use this:
...
before(:each) do
EnvChecker.stub!(:development?).and_return(false)
EnvChecker.stub!(:production?).and_return(true)
self.stub!(:compute_public_path).and_return('/applets/url.swf')
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment