Skip to content

Commit

Permalink
Align Spec::Be, BeClose failure message to other messages (#11946)
Browse files Browse the repository at this point in the history
The failure message previously had its `to_s` method called on it, but other expectations use `inspect`. This was creating failure messages like this: `Expected 2022-03-28 22:05:06.966811000 UTC to be GreaterThan 2022-03-28 22:05:06 UTC`
  • Loading branch information
jgaskins authored Apr 28, 2022
1 parent 05a9be4 commit f3903d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/spec/expectations.cr
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ module Spec
end

def failure_message(actual_value)
"Expected #{actual_value.inspect} to be within #{@delta} of #{@expected_value}"
"Expected #{actual_value.inspect} to be within #{@delta.inspect} of #{@expected_value.inspect}"
end

def negative_failure_message(actual_value)
"Expected #{actual_value.inspect} not to be within #{@delta} of #{@expected_value}"
"Expected #{actual_value.inspect} not to be within #{@delta.inspect} of #{@expected_value.inspect}"
end
end

Expand Down Expand Up @@ -193,11 +193,11 @@ module Spec
end

def failure_message(actual_value)
"Expected #{actual_value.inspect} to be #{@op} #{@expected_value}"
"Expected #{actual_value.inspect} to be #{@op} #{@expected_value.inspect}"
end

def negative_failure_message(actual_value)
"Expected #{actual_value.inspect} not to be #{@op} #{@expected_value}"
"Expected #{actual_value.inspect} not to be #{@op} #{@expected_value.inspect}"
end
end

Expand Down

0 comments on commit f3903d2

Please sign in to comment.