Skip to content

Instantly share code, notes, and snippets.

@F-3r
Created November 19, 2019 00:39
Show Gist options
  • Save F-3r/41d4c1ab03c9edac1340a1d932ad1eb0 to your computer and use it in GitHub Desktop.
Save F-3r/41d4c1ab03c9edac1340a1d932ad1eb0 to your computer and use it in GitHub Desktop.
testing proto-framework
class Verify
attr_reader :subject
def initialize(subject)
@subject = subject
end
def eq(b)
if subject == b
puts "\e[38;5;51m +1 \e[0m"
else
puts "\e[38;5;9m -1 #{subject.inspect} != #{b.inspect}\e[0m"
end
end
end
def verify(a)
Verify.new(a)
end
def check(name, &block)
print "\n - #{name} "
block.call
end
# Examples:
check "2 + 3 is 5" do
verify(2 + 3).eq 5
end
check "Nothing is true" do
verify(nil).eq true
end
# will output something like:
#
# - 2 + 3 is 5 +1
#
# - Nothing is true -1 (nil != true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment