class So::Received
Public Class Methods
new(method, time=nil, args=nil)
click to toggle source
# File lib/spec_object.rb, line 337 def initialize(method, time=nil, args=nil) raise "expected method name" unless method.is_a?(Symbol) @method = method @time = time @args = args end
Public Instance Methods
at(time)
click to toggle source
# File lib/spec_object.rb, line 345 def at(time) time = time.to_so_expr time.assert_time r = Received.new(@method, time, @args) r end
evaluate(calls)
click to toggle source
# File lib/spec_object.rb, line 383 def evaluate(calls) t = @time.evaluate(calls) if !(t.kind_of?(Time)) return self end method, args, output = calls[t.n] if method != @method return false.to_so_expr end if args.size != @args.size return false.to_so_expr end exprs = args.zip(@args).map do |(value, expr)| value.to_so_expr == expr end And.and_(*exprs) end
pp(n)
click to toggle source
# File lib/spec_object.rb, line 360 def pp(n) s = if !(@args.nil?) @args.map do |arg| arg.pp(n+4) end.join("\n") else "#{' '*(n+2)}" end t_pp = if !(@time.nil?) @time.pp(n+2) else "#{' '*(n+2)}nil" end "#{' '*n}(received #{@method.inspect}\n#{t_pp}\n#{' '*(n+2)}(\n#{s}))" end
substitute(v, e)
click to toggle source
# File lib/spec_object.rb, line 376 def substitute(v, e) time = @time.substitute(v, e) args = @args.map do |arg| arg.substitute(v, e) end Received.new(@method, time, args) end
with(*args)
click to toggle source
# File lib/spec_object.rb, line 352 def with(*args) args.map! do |arg| arg.assert_value arg.to_so_expr end Received.new(@method, @time, args) end