Ответ 1
Используйте anything
:
Foo.should_receive(:bar).with(:baz, anything)
class Foo
def bar(a, b)
...
Foo.should_receive( :bar )
ожидает, что bar вызывается с любыми аргументами.
Foo.should_receive( :bar ).with( :baz, :qux )
ожидает: baz и: qux для передачи в качестве параметров.
Как ожидать, что первый параметр равен: baz, и не заботятся о других параметрах?
Используйте anything
:
Foo.should_receive(:bar).with(:baz, anything)
Для Rspec 1.3 anything
не работает, когда ваш метод получает хэш в качестве аргумента, поэтому, пожалуйста, используйте hash_including(:key => val)
:
Connectors::Scim::Preprocessors::Builder.
should_receive(:build).
with(
hash_including(:connector => connector)
).
and_return(preprocessor)
}