Skip to content

Commit

Permalink
Land #15
Browse files Browse the repository at this point in the history
  • Loading branch information
jhart-r7 committed Jan 16, 2015
2 parents e1e95eb + 2ad67c5 commit 9970c05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/recog/fingerprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def create_regexp(xml)
# @return [String] Contents of the source XML's `description` tag
def parse_description(xml)
element = xml.xpath('description')
element.empty? ? '' : element.first.content.gsub(/[\r\n]+/, ' ').gsub(/\s{3,}/, ' ').strip
element.empty? ? '' : element.first.content.to_s.gsub(/\s+/, ' ').strip
end

# @param xml [Nokogiri::XML::Element]
Expand Down
2 changes: 1 addition & 1 deletion lib/recog/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Recog
VERSION = '1.0.8'
VERSION = '1.0.9'
end
5 changes: 5 additions & 0 deletions spec/data/whitespaced_fingerprint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<fingerprint pattern=".*this doesn't matter.*">
<description> I love
whitespace!
</description>
</fingerprint>
12 changes: 12 additions & 0 deletions spec/lib/recog/fingerprint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
require 'nokogiri'
require 'recog/fingerprint'

describe Recog::Fingerprint do
let(:xml) do
path = File.expand_path(File.join('spec', 'data', 'whitespaced_fingerprint.xml'))
doc = Nokogiri::XML(IO.read(path))
doc.xpath("//fingerprint").first
end
subject { Recog::Fingerprint.new(xml) }

describe "#name" do
it "properly squashes whitespace" do
expect(subject.name).to eq('I love whitespace!')
end
end
end

0 comments on commit 9970c05

Please sign in to comment.