Skip to content

Commit

Permalink
Update assertions.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Jan 9, 2025
1 parent 82c5fda commit e5c5c55
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions lib/quickdraw/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def assert_equal(actual, expected)
#{actual.inspect}
\e[34mto be == to\e[0m
\e[34mto be == to:\e[0m
#{expected.inspect}
MESSAGE
Expand All @@ -17,31 +17,71 @@ def assert_equal(actual, expected)

def refute_equal(actual, expected)
refute(actual == expected) do
"expected #{actual.inspect} not to == #{expected.inspect}"
<<~MESSAGE
\e[34mExpected:\e[0m
#{actual.inspect}
\e[34mnot to be == to:\e[0m
#{expected.inspect}
MESSAGE
end
end

def assert_includes(collection, member)
assert(collection.include?(member)) do
"expected #{collection.inspect} to include #{member.inspect}"
<<~MESSAGE
\e[34mExpected:\e[0m
#{collection.inspect}
\e[34mto include:\e[0m
#{member.inspect}
MESSAGE
end
end

def refute_includes(collection, member)
refute(collection.include?(member)) do
"expected #{collection.inspect} not to include #{member.inspect}"
<<~MESSAGE
\e[34mExpected:\e[0m
#{collection.inspect}
\e[34mnot to include:\e[0m
#{member.inspect}
MESSAGE
end
end

def assert_operator(object, operator, other)
assert object.public_send(operator, other) do
"expected #{object.inspect} to #{operator} #{other.inspect}"
<<~MESSAGE
\e[34mExpected:\e[0m
#{object.inspect}
\e[34mto #{operator}:\e[0m
#{other.inspect}
MESSAGE
end
end

def refute_operator(object, operator, other)
refute object.public_send(operator, other) do
"expected #{object.inspect} not to #{operator} #{other.inspect}"
<<~MESSAGE
\e[34mExpected:\e[0m
#{object.inspect}
\e[34mnot to #{operator}:\e[0m
#{other.inspect}
MESSAGE
end
end

Expand Down

0 comments on commit e5c5c55

Please sign in to comment.