[rspec-users] How to spec within a block?

rgagnon
Sat, 07 Feb 2009 11:47:34 -0000

I have this and I want to mock the to_xml but not his block cause this
is what I want to spec.  Is there a way to do this?

Sorry for the formatting

      output = @detenteur.to_xml( :skip_types => false, :skip_instruct
=> true, :dasherize => false, :only => [:inte_no] ) do |xml_detenteur|

        p xml_detenteur.intervenant_adresses.class.to_s

        xml_detenteur.intervenant_adresses do

          get_object_xml( @detenteur.intervenant_adresses,
@detenteur.intervenant_adresses.obtenir_adresses_vigueur, {:builder =>
xml_detenteur, :skip_instruct => true, :skip_types =>
false, :dasherize => false, :except => [:inte_no]})
        end

        xml_detenteur.intervenant_telephones do
          get_object_xml( @detenteur.intervenant_telephones,
@detenteur.intervenant_telephones.obtenir_tels_vigueur, {:builder =>
xml_detenteur, :skip_instruct => true, :skip_types =>
false, :dasherize => false, :except => [:inte_no]})
        end

        xml_detenteur.intervenants_polices do
          @polices = polices(@detenteur, @police_no, inte_polices,
xml_detenteur)
        end
      end