Skip to content

Instantly share code, notes, and snippets.

@agraves
Last active July 18, 2017 17:35
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 agraves/875b5efd765401b731b312d7e6cde758 to your computer and use it in GitHub Desktop.
Save agraves/875b5efd765401b731b312d7e6cde758 to your computer and use it in GitHub Desktop.
# implicit
class ErrorReporter
def active?
Rails.environment.production?
end
end
Rails.environment.stub :production?, true do
assert ErrorReporter.active?
end
# explicit
class ErrorReporter
def active?(environment=Rails.environment)
environment.production?
end
end
assert ErrorReporter.active? OpenStruct.new(:production => true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment