spec/unit/callable/call_spec.rb in finite_machine-0.2.0 vs spec/unit/callable/call_spec.rb in finite_machine-0.3.0

- old
+ new

@@ -6,16 +6,20 @@ before(:each) { Car = Class.new do attr_reader :result + def initialize + @engine_on = false + end + def turn_engine_on @result = 'turn_engine_on' @engine_on = true end - def set_engine(value) + def set_engine(value = :on) @result = "set_engine(#{value})" @engine = value.to_sym == :on end def turn_engine_off @@ -52,15 +56,33 @@ instance.call(target) expect(target.result).to eql('set_engine(on)') end end + context 'when string with arguments' do + let(:object) { 'set_engine' } + + it 'executes method with arguments' do + instance.call(target, :off) + expect(target.result).to eql('set_engine(off)') + end + end + context 'when symbol' do - let(:object) { :engine_on? } + let(:object) { :set_engine } it 'executes method on target' do instance.call(target) - expect(target.result).to eql('engine_on') + expect(target.result).to eql('set_engine(on)') + end + end + + context 'when symbol with arguments' do + let(:object) { :set_engine } + + it 'executes method on target' do + instance.call(target, :off) + expect(target.result).to eql('set_engine(off)') end end context 'when proc without args' do let(:object) { proc { |a| called << "block_with(#{a})" } }