Sha256: 672539964db9295adcda6af607812b21d9dc47505a668faa74f6a26e5f47dd73

Contents?: true

Size: 524 Bytes

Versions: 2

Compression:

Stored size: 524 Bytes

Contents

def add_expectations(obj, method, params)
  if params.is_a?(Array)
    obj.should_receive(method).with(*params)
  elsif params.nil?
    obj.should_receive(method)
  else
    obj.should_receive(method).with(params)
  end
end

def should_receive_queries(obj, method_chain)
  method_chain.each_with_index do |(method, params), idx|
    if (idx + 1) == method_chain.size
      return add_expectations(obj, method, params)
    else
      proxy = add_expectations(obj, method, params)
      proxy.and_return(obj)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aggrobot-0.1.0 spec/support/chain_query.rb
aggrobot-0.0.2 spec/support/chain_query.rb