Top Level Namespace
Defined Under Namespace
Modules: Kernel, Speccify
Instance Method Summary
collapse
#def_matcher
Instance Method Details
#change(&block) ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/speccify.rb', line 182
def change(&block)
Speccify::Functions::build_matcher(:change, []) do |given, matcher, args|
before = block.call
given.call
after = block.call
comparison = after != before
if list = matcher.msgs
comparison = case list[0].name
when :by then (after == before + list[0].args[0] || after == before - list[0].args[0])
when :by_at_least then (after >= before + list[0].args[0] || after <= before - list[0].args[0])
when :by_at_most then (after <= before + list[0].args[0] && after >= before - list[0].args[0])
when :from then (before == list[0].args[0]) && (after == list[1].args[0])
end
end
matcher.positive_msg = "given block didn't alter the block attached to change, #{matcher.loc}"
matcher.negative_msg = "given block did alter the block attached to change, #{matcher.loc}"
comparison
end
end
|