Sha256: 3ea186bb65fbbcee8db06d1f55410c189055addeb264179209684c684a50fa63

Contents?: true

Size: 707 Bytes

Versions: 145

Compression:

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

145 entries across 91 versions & 12 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.6.7 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md
classiccms-0.6.7 vendor/bundle/gems/rspec-mocks-2.9.0/features/argument_matchers/README.md
classiccms-0.6.6 vendor/bundle/gems/rspec-mocks-2.10.1/features/argument_matchers/README.md