Alex
2009-Feb-06 21:12 UTC
[rspec-users] How to test the code inside the block of the to_xml function?
Hi all, when I spec the to_xml function like this: @some_model.should_receive(:to_xml), it dskips the code located in the block, here is the controller code: ... output = @detenteur.to_xml( :skip_types => false, :skip_instruct => true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| lots of code... end How can I test the code inside? Thanks!
David Chelimsky
2009-Feb-12 04:46 UTC
[rspec-users] How to test the code inside the block of the to_xml function?
On Fri, Feb 6, 2009 at 3:12 PM, Alex <afolgueras at gmail.com> wrote:> Hi all, when I spec the to_xml function like this: > @some_model.should_receive(:to_xml), it dskips the code located in the > block, here is the controller code: > > ... > output = @detenteur.to_xml( :skip_types => false, :skip_instruct => > true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur| > lots of code... > end > > How can I test the code inside?mock_xml_detenteur = mock(''xml_detenteur'') @some_model.should_receive(:to_xml).and_yield(mock_xml_detenteur) # set expectations on mock_xml_detenteur Make sense?> > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >