Sha256: b5aca3965574bf520f5de73936e34cdc52643329e785aff6fa30cf06846c8a87
Contents?: true
Size: 1.14 KB
Versions: 16
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' module Rspec module Mocks describe "A chained method stub" do before(:each) do @subject = Object.new end it "returns expected value from chaining only one method call" do @subject.stub_chain(:msg1).and_return(:return_value) @subject.msg1.should equal(:return_value) end it "returns expected value from chaining two method calls" do @subject.stub_chain(:msg1, :msg2).and_return(:return_value) @subject.msg1.msg2.should equal(:return_value) end it "returns expected value from chaining four method calls" do @subject.stub_chain(:msg1, :msg2, :msg3, :msg4).and_return(:return_value) @subject.msg1.msg2.msg3.msg4.should equal(:return_value) end it "returns expected value from chaining four method calls twice with some shared" do @subject.stub_chain(:msg1, :msg2, :msg3, :msg4).and_return(:first) @subject.stub_chain(:msg5, :msg2, :msg3, :msg4).and_return(:second) @subject.msg1.msg2.msg3.msg4.should equal(:first) @subject.msg5.msg2.msg3.msg4.should equal(:second) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems