def parse_diff(result)
header = []
expect = []
butwas = []
found = false
state = :header
until result.empty? do
case state
when :header then
header << result.shift
state = :expect if result.first =~ /^</
when :expect then
state = :butwas if result.first.sub!(/ expected but was/, '')
expect << result.shift
when :butwas then
butwas = result[0..-1]
result.clear
else
raise "unknown state #{state}"
end
end
return header, expect, nil if butwas.empty?
expect.last.chomp!
expect.first.sub!(/^<\"/, '')
expect.last.sub!(/\">$/, '')
butwas.last.chomp!
butwas.last.chop! if butwas.last =~ /\.$/
butwas.first.sub!( /^<\"/, '')
butwas.last.sub!(/\">$/, '')
return header, expect, butwas
end