-
-
Save zmoazeni/71a30f8d26928dfe9663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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