Sha256: 48f8f3abafd05f3fe7cafb7e075182f62c4d2ec459d32e3715218fdd12d5c1a7

Contents?: true

Size: 782 Bytes

Versions: 13

Compression:

Stored size: 782 Bytes

Contents

Feature: stub with substitute implementation

  You can stub an implementation of a method (a.k.a. fake) by passing a block
  to the `stub` method.
  
  Scenario: stub implementation
    Given a file named "stub_implementation_spec.rb" with:
      """ruby
      describe "a stubbed implementation" do
        it "works" do
          object = Object.new
          object.stub(:foo) do |arg|
            if arg == :this
              "got this"
            elsif arg == :that
              "got that"
            end
          end
          
          object.foo(:this).should eq("got this")
          object.foo(:that).should eq("got that")
        end
      end
      """
    When I run `rspec stub_implementation_spec.rb`
    Then the output should contain "1 example, 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/method_stubs/stub_implementation.feature
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/method_stubs/stub_implementation.feature
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/method_stubs/stub_implementation.feature
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/method_stubs/stub_implementation.feature
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-mocks-2.13.1/features/method_stubs/stub_implementation.feature
rspec-mocks-2.13.1 features/method_stubs/stub_implementation.feature
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-mocks-2.13.0/features/method_stubs/stub_implementation.feature
rspec-mocks-2.13.0 features/method_stubs/stub_implementation.feature
remq-0.0.4 vendor/bundle/gems/rspec-mocks-2.12.2/features/method_stubs/stub_implementation.feature
remq-0.0.3 vendor/bundle/gems/rspec-mocks-2.12.2/features/method_stubs/stub_implementation.feature
rspec-mocks-2.12.2 features/method_stubs/stub_implementation.feature
rspec-mocks-2.12.1 features/method_stubs/stub_implementation.feature
rspec-mocks-2.12.0 features/method_stubs/stub_implementation.feature