Sha256: 71b3dd071b48f623adec1ff7728b2950589146215f789dbde2c6985fec736366

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 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::PositiveExpectationChain.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

12 entries across 12 versions & 5 rubygems

Version Path
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/spec/rspec/mocks/any_instance/message_chains_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/spec/rspec/mocks/any_instance/message_chains_spec.rb
rspec-mocks-2.12.1 spec/rspec/mocks/any_instance/message_chains_spec.rb
rspec-mocks-2.12.0 spec/rspec/mocks/any_instance/message_chains_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.11.3/spec/rspec/mocks/any_instance/message_chains_spec.rb
gem_repackager-0.1.0 support/gems/rspec-mocks-2.11.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
rspec-mocks-2.11.3 spec/rspec/mocks/any_instance/message_chains_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/rspec-mocks-2.11.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
rspec-mocks-2.11.2 spec/rspec/mocks/any_instance/message_chains_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/rspec-mocks-2.11.1/spec/rspec/mocks/any_instance/message_chains_spec.rb
rspec-mocks-2.11.1 spec/rspec/mocks/any_instance/message_chains_spec.rb
rspec-mocks-2.11.0 spec/rspec/mocks/any_instance/message_chains_spec.rb