Sha256: b5cc5581c3347274d5a0cd51c9f97566d596b7334440404efcc2f34ddb9f1012
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-mocks-2.14.0.rc1 | features/method_stubs/stub_implementation.feature |