Sha256: 074ca8f98a75087b79189a3919916c0579176f727bafca8579284ab32c676dc5

Contents?: true

Size: 680 Bytes

Versions: 39

Compression:

Stored size: 680 Bytes

Contents

### Introduction

Argument matchers can be used:

* In stubs to constrain the scope of the stubbed method

    obj.stub(:foo).with(:bar) do |arg|
      #do something for :bar
    end
    obj.stub(:foo).with(:baz) do |arg|
      #do something for :baz
    end

* In expectations to validate the arguments that should be received in a method call

    #create a double
    obj = double()

    #expect a message with given args
    obj.should_receive(:message).with('an argument')

If more control is needed, one can use a block

    obj.should_receive(:message) do |arg1,  arg2|
      # set expectations about the args in this block
      # and optionally set a return value
    end

Version data entries

39 entries across 39 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
rspec-mocks-2.99.4 features/argument_matchers/README.md
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/features/argument_matchers/README.md
rspec-mocks-2.99.3 features/argument_matchers/README.md
rspec-mocks-2.99.2 features/argument_matchers/README.md
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/features/argument_matchers/README.md
rspec-mocks-2.99.1 features/argument_matchers/README.md
rspec-mocks-2.99.0 features/argument_matchers/README.md
rspec-mocks-2.99.0.rc1 features/argument_matchers/README.md
rspec-mocks-2.14.6 features/argument_matchers/README.md
rspec-mocks-2.99.0.beta2 features/argument_matchers/README.md
rspec-mocks-2.14.5 features/argument_matchers/README.md
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-mocks-2.14.4/features/argument_matchers/README.md