class BeComputedByMatcher
Public Class Methods
new(sym, *args)
click to toggle source
# File lib/mspec/matchers/be_computed_by.rb, line 2 def initialize(sym, *args) @method = sym @args = args end
Public Instance Methods
failure_message()
click to toggle source
# File lib/mspec/matchers/be_computed_by.rb, line 28 def failure_message ["Expected #{@value.inspect}", "to be computed by #{method_call} (computed #{@actual.inspect} instead)"] end
matches?(array)
click to toggle source
# File lib/mspec/matchers/be_computed_by.rb, line 7 def matches?(array) array.each do |line| @receiver = line.shift @value = line.pop @arguments = line @arguments += @args @actual = @receiver.send(@method, *@arguments) return false unless @actual == @value end return true end
method_call()
click to toggle source
# File lib/mspec/matchers/be_computed_by.rb, line 20 def method_call method_call = "#{@receiver.inspect}.#{@method}" unless @arguments.empty? method_call << " from #{@arguments.map { |x| x.inspect }.join(", ")}" end method_call end