Skip to content

Instantly share code, notes, and snippets.

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