Sha256: 9d28b2e0b190df904e566a1cedd6ec571d7091a3d6529d5ffbf5ebe701d35fc9

Contents?: true

Size: 778 Bytes

Versions: 150

Compression:

Stored size: 778 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:
      """
      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

150 entries across 96 versions & 14 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.7.5 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.7.4 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.7.3 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/features/method_stubs/stub_implementation.feature
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/features/method_stubs/stub_implementation.feature
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.7.2 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.7.1 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.7.0 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.6.9 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.10.1/features/method_stubs/stub_implementation.feature
classiccms-0.6.8 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature
classiccms-0.6.7 vendor/bundle/gems/rspec-mocks-2.9.0/features/method_stubs/stub_implementation.feature