2013-10-07 6 views

Antwort

23

Verwenden Sie die anything Matcher:

Foo.should_receive(:bar).with(:baz, anything) 
+2

Das funktioniert. Der Vorbehalt ist, dass Sie für jeden Parameter ein "irgendetwas" brauchen. –

+2

Ich bin nicht sicher, ob es nachher hinzugefügt wurde, aber RSpec hat any_args, so dass für 'bar (a, b, c)' Sie können 'Foo.should_receive (: bar) .with (: baz, any_args)' – rubyprince

+0

Danke @rubyprince sehr, super Tipp! –

0

Für Rspec 1.3anything funktioniert nicht, wenn Ihre Methode ist ein Hash als Argument empfangen, so versuchen Sie es mit hash_including(:key => val):

Connectors::Scim::Preprocessors::Builder. 
    should_receive(:build). 
    with(
     hash_including(:connector => connector) 
    ). 
    and_return(preprocessor) 
}