Sha256: 32003d6002252381719690eec5202ddda6e8e113e1ccf500f37e8df968535e9a

Contents?: true

Size: 780 Bytes

Versions: 23

Compression:

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

23 entries across 23 versions & 3 rubygems

Version Path
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
rspec-mocks-2.3.0 features/stubs/stub_implementation.feature
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-mocks-2.1.0/features/stubs/stub_implementation.feature
rspec-mocks-2.2.0 features/stubs/stub_implementation.feature
rspec-mocks-2.1.0 features/stubs/stub_implementation.feature
rspec-mocks-2.0.1 features/stubs/stub_implementation.feature
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.3.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.2.0 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.1.2 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature
gemrage-0.1.1 vendor/ruby/1.8/gems/rspec-mocks-2.0.0/features/stubs/stub_implementation.feature