Last active
August 29, 2015 14:22
-
-
Save raizyr/bb15a7ea639daa09350b to your computer and use it in GitHub Desktop.
Not one line, but possibly easier to read
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
require 'test/unit' | |
include Test::Unit::Assertions | |
instance_true = {:source_dest_check => true} | |
instance_nil = {:source_dest_check => nil} | |
instance_false = {:source_dest_check => false} | |
instance_raise = {} | |
instance_garbage = {:source_dest_check => 'asdfl;kjag'} | |
def test(instance) | |
source_dest_check = !!instance[:source_dest_check] == instance[:source_dest_check] ? instance[:source_dest_check] : true | |
source_dest_check | |
end | |
assert test(instance_nil) == true, "Nil was not true" | |
assert test(instance_true) == true, "True was not true" | |
assert test(instance_false) == false, "False was not false" | |
assert test(instance_raise) == true, "Key error was not true" | |
assert test(instance_garbage) == true, "Garbage was not true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment