Sha256: d6296cc406e9d691f5424cec349fa73255a0d5588165b5869976b798e9980d90

Contents?: true

Size: 1.42 KB

Versions: 129

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe RSpec::Mocks::AnyInstance::MessageChains do
  let(:chains) { RSpec::Mocks::AnyInstance::MessageChains.new }
  let(:stub_chain) { RSpec::Mocks::AnyInstance::StubChain.new }
  let(:expectation_chain) { RSpec::Mocks::AnyInstance::ExpectationChain.new }

  it "knows if a method does not have an expectation set on it" do
    chains.add(:method_name, stub_chain)
    chains.has_expectation?(:method_name).should be_false
  end

  it "knows if a method has an expectation set on it" do
    chains.add(:method_name, stub_chain)
    chains.add(:method_name, expectation_chain)
    chains.has_expectation?(:method_name).should be_true
  end

  it "can remove all stub chains" do
    chains.add(:method_name, stub_chain)
    chains.add(:method_name, expectation_chain)
    chains.add(:method_name, RSpec::Mocks::AnyInstance::StubChain.new)

    chains.remove_stub_chains_for!(:method_name)
    chains[:method_name].should eq([expectation_chain])
  end
  
  context "creating stub chains" do
    it "understands how to add a stub chain for a method" do
      chains.add(:method_name, stub_chain)
      chains[:method_name].should eq([stub_chain])
    end

    it "allows multiple stub chains for a method" do
      chains.add(:method_name, stub_chain)
      chains.add(:method_name, another_stub_chain = RSpec::Mocks::AnyInstance::StubChain.new)
      chains[:method_name].should eq([stub_chain, another_stub_chain])
    end
  end
end

Version data entries

129 entries across 77 versions & 9 rubygems

Version Path
classiccms-0.6.6 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.5 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.5 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.4 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.4 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.3 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.3 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.2 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.2 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.1 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.1 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.0 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.6.0 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.17 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.17 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.16 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.16 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.15 vendor/bundle/gems/rspec-mocks-2.10.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.15 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb
classiccms-0.5.14 vendor/bundle/gems/rspec-mocks-2.9.0/spec/rspec/mocks/any_instance/message_chains_spec.rb