btakita / rr

RR (Double Ruby) is a test double framework that features a rich selection of double techniques and a terse syntax.
http://github.com/rr/rr
MIT License
501 stars 58 forks source link

Using a wildcard argument matcher inside a block given to #stub or #mock doesn't seem to work #93

Open mcmire opened 11 years ago

mcmire commented 11 years ago

This test fails:

require 'minitest/autorun'
require 'rr'

class FooTest < MiniTest::Unit::TestCase
  include RR::Adapters::MiniTest

  attr_reader :object

  def setup
    @object = Object.new
  end

  def test_foo
    mock(object) do
      baz(anything).once
    end
    object.baz('whatever')
  end
end

Output:

Run options: --seed 37148

# Running tests:

F

Finished tests in 0.003291s, 303.8590 tests/s, 0.0000 assertions/s.

  1) Error:
test_foo(FooTest):
RR::Errors::DoubleNotFoundError: On subject #<Object:0x007fc11b888b30>,
unexpected method invocation:
  baz("whatever")
expected invocations:
- baz(#<RR::DoubleDefinitions::DoubleDefinition:0x007fc11b883bf8 @implementation=#<Proc:0x007fc11b883a90@/Users/elliot/code/github/forks/rr/lib/rr/double_definitions/double_definition.rb:242 (lambda)>, .................. [snip]

  2) Failure:
test_foo(FooTest) [/Users/elliot/tmp/rr-test.rb:18]:
anything()
Called 0 times.
Expected 1 times.