Sha256: a621f7ca25b61f8395f993d891e7c089ee874b55c85dc205043681a6a9bfe5f7
Contents?: true
Size: 674 Bytes
Versions: 3
Compression:
Stored size: 674 Bytes
Contents
module BaconExpect; module Matcher class Change def initialize(change_block) @change_block = change_block end def by(amount) @change_amount = amount self end def matches?(subject, &expectation_block) old_value = @change_block.call expectation_block.call new_value = @change_block.call if @change_amount new_value - @change_amount == old_value else new_value != old_value end end def fail!(subject) message = "Block expected to change value" message += " by #{@change_amount}" if @change_amount raise FailedExpectation.new(message) end end end; end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bacon-expect-1.0.2 | lib/bacon-expect/matchers/change.rb |
bacon-expect-1.0.1 | lib/bacon-expect/matchers/change.rb |
bacon-expect-0.1 | lib/bacon-expect/matchers/change.rb |