<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>features/fixtures/representatives.2009-06-04.xml.patch</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -5,7 +5,7 @@ Feature: hansard parser
 
 Scenario: downloading the hansard
 	Given a &quot;house of representatives&quot; hansard dated &quot;2009-06-04&quot;
-	Given a parlinfo page for the hansard
+	And a parlinfo page for the hansard
 	And a parlinfo xml for the hansard with id &quot;6862-2&quot;
 	When I download the hansard
 	Then I should have the hansard body
@@ -13,5 +13,13 @@ Scenario: downloading the hansard
 Scenario: failing to download the hansard
 
 Scenario: downloading and patching the hansard
+	Given a &quot;house of representatives&quot; hansard dated &quot;2009-06-04&quot;
+	And a parlinfo page for the hansard
+	And a parlinfo xml for the hansard with id &quot;6862-2&quot;
+	And an xml patch for the hansard
+
+	When I download and patch the hansard
+	Then I should have the hansard body
+	And it should be patched with &quot;Hayes, Christopher, MP&quot; at line &quot;75&quot;
 
 Scenario: parsing the hansard</diff>
      <filename>features/hansard_parser.feature</filename>
    </modified>
    <modified>
      <diff>@@ -10,10 +10,22 @@ Given /^a parlinfo xml for the hansard with id &quot;([^\&quot;]*)&quot;$/ do |id|
 	@app.parlinfo.prepare_hansard_xml!(id)
 end
 
+Given /^an xml patch for the hansard$/ do
+	@app.hansard.xml_patch!
+end
+
 When /^I download the hansard$/ do
-	@app.hansard_parser.make!([]).download!
+	@app.hansard_parser.make!([]).download_and_patch!
+end
+
+When /^I download and patch the hansard$/ do
+	@app.hansard_parser.make!([]).download_and_patch!
 end
 
 Then /^I should have the hansard body$/ do
 	@app.hansard_parser.body?
 end
+
+Then /^it should be patched with &quot;([^\&quot;]*)&quot; at line &quot;([^\&quot;]*)&quot;$/ do |text, line|
+	@app.hansard_parser.patched?(text,line.to_i)
+end</diff>
      <filename>features/step_definitions/hansard_parser_steps.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,3 +16,7 @@ end
 World do
 	OurWorld.new
 end
+
+After do
+	@app.after!
+end</diff>
      <filename>features/support/env.rb</filename>
    </modified>
    <modified>
      <diff>@@ -238,6 +238,20 @@ Content-Length: #{text.size}
 		def make(house_str,date)
 			OpenStruct.new(:house =&gt; house.interpret(house_str), :date =&gt; date)
 		end
+
+		def xml_patch_name
+			&quot;#{o.house == 'reps' ? 'representatives' : 'senate'}.#{o.date}.xml.patch&quot; 
+		end
+
+		def xml_patch
+			fixture.path(xml_patch_name)
+		end
+
+		def xml_patch!
+			patch = File.join(root,'data','patches',xml_patch_name)
+			FileUtils::cp(xml_patch, patch)
+			do_after { FileUtils::rm(patch) }
+		end
 	end
 
 	require 'hansard_parser'
@@ -247,13 +261,21 @@ Content-Length: #{text.size}
 		end
 
 		def download!
-			@body = o.unpatched_hansard_xml_source_data_on_date(hansard.o.date, house.make(hansard.o.house))
+			@body = o.hansard_xml_source_data_on_date(hansard.o.date, house.make(hansard.o.house))
 			self
 		end
 
+		def download_and_patch!
+			@body = o.hansard_xml_source_data_on_date(hansard.o.date, house.make(hansard.o.house))
+		end
+
 		def body?
 			@body.should_not be_blank
 		end
+
+		def patched?(text,line)
+			@body.split(&quot;\n&quot;)[line].should include(text)
+		end
 	end
 
 	require 'person'
@@ -401,6 +423,21 @@ Content-Length: #{text.size}
 			MechanizeProxyCache.perform_caching = false
 		end
 
+		def after!
+			if !@after_list.blank?
+				@after_list.each {|block| block[]}
+			end
+		end
+
+		def root
+			@root ||= File.expand_path(File.dirname(__FILE__)+'/../..')
+		end
+
+		def do_after(&amp;block)
+			@after_list ||= []
+			@after_list &lt;&lt; block
+		end
+
 		namespace(:fixture,:Fixtures)
 		namespace(:web,:FakeWeb)
 		namespace(:parlinfo,:Parlinfo)</diff>
      <filename>features/support/oa_app.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ffeb2ce71d7c0a864c2e3203bd290ab1f00c0d5d</id>
    </parent>
  </parents>
  <author>
    <name>lachie</name>
    <email>lachiec@gmail.com</email>
  </author>
  <url>http://github.com/lachie/openaustralia-parser/commit/626da53dac8a4458b11545c8bddfacbfe2750463</url>
  <id>626da53dac8a4458b11545c8bddfacbfe2750463</id>
  <committed-date>2009-06-15T04:18:31-07:00</committed-date>
  <authored-date>2009-06-15T04:18:31-07:00</authored-date>
  <message>scenario: downloading and patching the hansard</message>
  <tree>796d1167a381be2b75265eba44a1c6b677c135e2</tree>
  <committer>
    <name>lachie</name>
    <email>lachiec@gmail.com</email>
  </committer>
</commit>
