Skip to content

Instantly share code, notes, and snippets.

@rafadc
Created December 17, 2010 06:52
Show Gist options
  • Save rafadc/744591 to your computer and use it in GitHub Desktop.
Save rafadc/744591 to your computer and use it in GitHub Desktop.
def test_when_success_with_nothing_to_chain
myObject = mock()
myObject.expects(:method).once.returns(nil)
myObject.expects(:method_to_be_called).once
When.success{myObject.method}.then_call{myObject.method_to_be_called}.as_a_chain
end
def test_that_parameter_is_chained_when_as_a_chain_is_called
parameter = 'Highly difficult to calculate value'
myObject = mock()
myObject.expects(:method).once.returns(parameter)
myObject.expects(:method_to_be_called).with(parameter).once
When.success{myObject.method}.then_call{|x| myObject.method_to_be_called(x)}.as_a_chain
end
def test_overload_of_that
parameter = 'Highly difficult to calculate value'
myObject = mock()
myObject.expects(:method).once.returns(parameter)
myObject.expects(:method_to_be_called).with(parameter).once
When.success{myObject.method}.then_call(:as_a_chain){|x| myObject.method_to_be_called(x)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment