module RSpecCandy::Helpers::ShouldReceiveChain

Public Instance Methods

should_not_receive_chain(*parts) click to toggle source
# File lib/rspec_candy/helpers/should_receive_chain.rb, line 9
def should_not_receive_chain(*parts)
  setup_expectation_chain(parts, :negate => true)
end
should_receive_chain(*parts) click to toggle source
# File lib/rspec_candy/helpers/should_receive_chain.rb, line 5
def should_receive_chain(*parts)
  setup_expectation_chain(parts)
end

Private Instance Methods

setup_expectation_chain(parts, options = {}) click to toggle source
# File lib/rspec_candy/helpers/should_receive_chain.rb, line 15
def setup_expectation_chain(parts, options = {})
  obj = self
  for part in parts
    if part == parts.last
      expectation = options[:negate] ? :should_not_receive : :should_receive
      obj = add_expectation_chain_link(obj, expectation, part)
    else
      next_obj = Switcher.new_mock('chain link')
      add_expectation_chain_link(obj, :stub, part).and_return(next_obj)
      obj = next_obj
    end
  end
  obj
end