Sha256: 833aeab20ed3267207259adb3871a6d7af8b5253e932ec319d57f8b768e2205b

Contents?: true

Size: 1.74 KB

Versions: 13

Compression:

Stored size: 1.74 KB

Contents

Feature: explicit arguments

  Allows you to explicitly specify the argument values

  Scenario: explicit arguments
    Given a file named "stub_explicit_args_spec.rb" with:
      """ruby
      describe "stubbed explicit arguments" do
        it "works on stubs" do
          object = Object.new
          object.stub(:foo).with(:this) do |arg|
            "got this"
          end
          object.stub(:foo).with(:that) do |arg|
            "got that"
          end

          object.foo(:this).should eq("got this")
          object.foo(:that).should eq("got that")
        end

        it "works on doubles and expectations" do
          object = double('foo')
          object.should_receive(:bar).with(:foo)

          object.bar(:foo)
        end
      end
      """
    When I run `rspec stub_explicit_args_spec.rb`
    Then the output should contain "2 examples, 0 failures"

  Scenario: explicit arguments with multiple arities
    Given a file named "stub_multiple_explicit_args_spec.rb" with:
      """ruby
      describe "stubbed multiple explicit arguments" do
        it "works on stubs" do
          object = Object.new
          object.stub(:foo).with(:this) do |arg|
            "got this"
          end
          object.stub(:foo).with(:this, :that) do |arg1, arg2|
            "got this and that"
          end

          object.foo(:this).should eq("got this")
          object.foo(:this, :that).should eq("got this and that")
        end
        
        it "works on mocks" do
          object = double('foo')
          object.should_receive(:foo).with(:this, :that)

          object.foo(:this, :that)
        end
      end
      """
    When I run `rspec stub_multiple_explicit_args_spec.rb`
    Then the output should contain "2 examples, 0 failures"

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-mocks-2.13.0/features/argument_matchers/explicit.feature
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/explicit.feature
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/explicit.feature
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/explicit.feature
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/argument_matchers/explicit.feature
rspec-mocks-2.13.1 features/argument_matchers/explicit.feature
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-mocks-2.13.0/features/argument_matchers/explicit.feature
rspec-mocks-2.13.0 features/argument_matchers/explicit.feature
remq-0.0.4 vendor/bundle/gems/rspec-mocks-2.12.2/features/argument_matchers/explicit.feature
remq-0.0.3 vendor/bundle/gems/rspec-mocks-2.12.2/features/argument_matchers/explicit.feature
rspec-mocks-2.12.2 features/argument_matchers/explicit.feature
rspec-mocks-2.12.1 features/argument_matchers/explicit.feature
rspec-mocks-2.12.0 features/argument_matchers/explicit.feature