[rspec-users] Fuzzy should_receive matching

Alexander Baronec abonec at gmail.com
Thu May 30 07:44:19 UTC 2013


Hello.
I have a test problem when I should test arguments in method not by exact
matching buy with fuzzy matching.

For example I have this test:

require 'rspec'

describe do
  it do
    o = Object.new
    o.should_receive(:api_send).with mode: :say

    o.api_send mode: :say, time: Time.now + rand(1..10), bans: { login1:
{time: Time.now, expiration: Time.now + 100}}
  end
end

I want helper to test that method api_send receive mode: :say, time:
Time.now + rand(1..10), bans: { login1: {time: Time.now, expiration:
Time.now + 100}} but I do not care about what time exactly is.

I want something like

inspect_api o, mode: :say, time: Time, bans: { login:1: {time: Time,
expiration: Time}}

Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20130530/169a96a3/attachment.html>


More information about the rspec-users mailing list