Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## 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
You can’t perform that action at this time.