On Apr 19, 2006, at 9:19 PM, bao lee wrote:
This is a stub, not a mock.
but the value of the value returned is fixed. which is quite hard
to test the controller when different values are returned from the rpc
call… is there a way to make the number returned dynamic??
the sense that i can pre-define the returned number in the functional
test case to simulate the different kind of situation that might
I use the following pattern when I use stubs, taking advantage of
Ruby’s open classes. My flickr interface use open-uri to do its
work, so I inject my own open that will be called before Kernel’s. I
record the passed URIs and give the positional response. This makes
it easy to verify the method DTRT.
attr_accessor :responses, :uris
@uris << uri
class FlickrTest < Test::Unit::TestCase
@flickr.responses << <<-EOF
<?xml version="1.0" encoding="utf-8" ?>
nsid = @flickr.find_email :find_email => '[email protected]'
assert_equal 1, @flickr.uris.length
assert_equal '[email protected]', nsid
Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant