Created
May 4, 2017 14:35
-
-
Save benlinton/7fc551b4572e3a81efbc23abd340cad2 to your computer and use it in GitHub Desktop.
Rails Test Helper
This file contains hidden or 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
# 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