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
add_expectation_chain_link(obj, expectation, part)
click to toggle source
# File lib/rspec_candy/helpers/should_receive_chain.rb, line 30 def add_expectation_chain_link(obj, expectation, part) if part.is_a?(Array) obj.send(expectation, part.first).with(*part[1..-1]) else obj.send(expectation, part) end end
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