To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!More about adding a collaborator
stub with substitute implementation
You can stub an implementation of a method (a.k.a. fake) by passing a block
to the stub() method.
- stub implementation
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
- I run "rspec ./stub_implementation_spec.rb"
- the output should contain "1 example, 0 failures"
Last published 11 months ago by dchelimsky.
RSpec Mocks settings