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

Version Path
rspec-mocks-2.0.0.beta.8 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.7 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.6 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.5 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.4 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.3 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.2 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.beta.1 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a10 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a9 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a8 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a7 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a6 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a5 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a4 spec/rspec/mocks/stub_chain_spec.rb
rspec-mocks-2.0.0.a3 spec/rspec/mocks/stub_chain_spec.rb