Sha256: 44ea341b6c1810bea00d0fe9f562b7aeb8014a98ac6b38071fe8bbba226b2487

Contents?: true

Size: 687 Bytes

Versions: 18

Compression:

Stored size: 687 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

18 entries across 18 versions & 8 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-mocks-2.13.0/features/argument_matchers/README.md
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/features/argument_matchers/README.md
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/features/argument_matchers/README.md
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/README.md
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/README.md
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/README.md
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/README.md
rspec-mocks-2.13.1 features/argument_matchers/README.md
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-mocks-2.13.0/features/argument_matchers/README.md
rspec-mocks-2.13.0 features/argument_matchers/README.md
remq-0.0.4 vendor/bundle/gems/rspec-mocks-2.12.2/features/argument_matchers/README.md
remq-0.0.3 vendor/bundle/gems/rspec-mocks-2.12.2/features/argument_matchers/README.md
rspec-mocks-2.12.2 features/argument_matchers/README.md
rspec-mocks-2.12.1 features/argument_matchers/README.md
rspec-mocks-2.12.0 features/argument_matchers/README.md
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/features/argument_matchers/README.md
rspec-mocks-2.11.3 features/argument_matchers/README.md
rspec-mocks-2.11.2 features/argument_matchers/README.md