lib/assert/actual_value.rb in assert-2.18.4 vs lib/assert/actual_value.rb in assert-2.19.0
- old
+ new
@@ -1,11 +1,14 @@
+require "much-not-given"
require "much-stub"
module Assert; end
class Assert::ActualValue
- def initialize(value, context:)
- @value = value
+ include MuchNotGiven
+
+ def initialize(value = self.class.not_given, context:, &value_block)
+ @value = self.class.given?(value) ? value : value_block
@context = context
end
def returns_true(*args)
@context.assert_block(*args, &@value)
@@ -21,10 +24,18 @@
def does_not_raise(*expected_exceptions)
@context.assert_nothing_raised(*expected_exceptions, &@value)
end
+ def changes(*args)
+ @context.assert_changes(*args, &@value)
+ end
+
+ def does_not_change(*args)
+ @context.assert_not_changes(*args, &@value)
+ end
+
def is_a_kind_of(expected_class, *args)
@context.assert_kind_of(expected_class, @value, *args)
end
alias_method :is_kind_of, :is_a_kind_of
@@ -52,13 +63,15 @@
end
def is_the_same_as(expected_object, *args)
@context.assert_same(expected_object, @value, *args)
end
+ alias_method :is, :is_the_same_as
def is_not_the_same_as(expected_object, *args)
@context.assert_not_same(expected_object, @value, *args)
end
+ alias_method :is_not, :is_not_the_same_as
def equals(expected_value, *args)
@context.assert_equal(expected_value, @value, *args)
end
alias_method :is_equal_to, :equals