Class: Whitestone::Assertion::Equality
- Defined in:
- lib/whitestone/assertion_classes.rb
Overview
class Assertion::Nil
Instance Method Summary collapse
-
#initialize(mode, *args, &block) ⇒ Equality
constructor
A new instance of Equality.
- #message ⇒ Object
- #run ⇒ Object
Methods inherited from Base
Methods included from Guards
#args_or_block_one_only, #block_required, #no_block_allowed, #one_argument, #two_arguments, #two_or_three_arguments, #type_check
Constructor Details
#initialize(mode, *args, &block) ⇒ Equality
Returns a new instance of Equality.
171 172 173 174 175 |
# File 'lib/whitestone/assertion_classes.rb', line 171 def initialize(mode, *args, &block) super @actual, @expected = two_arguments(args) no_block_allowed end |
Instance Method Details
#message ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/whitestone/assertion_classes.rb', line 179 def case @mode when :assert String.new.tap { |str| str << Col["Equality test failed"].yb str << Col["\n Should be: ", @expected.inspect].fmt(:yb, :gb) str << Col["\n Was: ", @actual.inspect].fmt(:rb, :rb) if String === @actual and String === @expected \ and @expected.length > 40 and @actual.length > 40 diff = Differ.diff_by_char(@expected.inspect, @actual.inspect) str << "\n" << " Dif: #{diff}" end } when :negate if @expected.inspect.length < 10 Col["Inequality test failed: object should not equal", @expected.inspect].fmt [:yb, :rb] else Col.inline( "Inequality test failed: the two objects were equal.\n", :yb, " Value: ", :yb, @expected.inspect, :rb ) end end end |