Skip to content

Instantly share code, notes, and snippets.

@benlinton
Created May 4, 2017 14:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Rails Test Helper
# Only outputs block if preceeded by `=` in rails views
# Preferred.
def testify(value = nil, &block)
return unless Rails.env.development? || Rails.env.test?
block_given? ? capture(&block) : value
end
# Outputs block for both `-` and `=` in rails views
def testify(value = nil, &block)
return unless Rails.env.development? || Rails.env.test?
if block_given?
block.call
nil
else
value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment