Carmine, someone could just give you the answer, but pardon me if I get a
little Socratic on your ass*

Given this code (which is similar to the code you're testing):

authenticate() do |result|
  puts result
end

do you understand what's going on? When is 'puts result' executed? What code
causes it to be executed? Where does 'result' get its value? What does the
'yield' keyword do? If you wanted to replace authenticate() with a stub for
testing, how would 'result' get its value? Do you understand the purpose of
and_return in RSpec mocking? What would and_yield then do?

If you're unclear on any of these points, take a step back and refresh your
memory on the subject of blocks and methods that take blocks (like
authenticate_with_open_id()) . You'll be glad you did!

///ark

*Pulp Fiction reference, in case someone reading this thinks I'm merely
being obnoxious.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to