Permalink
Browse files

[#21] enhanced matcher to deal with variable amount of whitespace

  • Loading branch information...
1 parent 6164bbe commit 5af14b1df9be62fd56ca691708efb6dfd5352d47 @helabed helabed committed May 26, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/matchers/table_header_matcher.rb
  2. +6 −0 spec/table_header_matcher_spec.rb
@@ -33,7 +33,7 @@ def extract_html_content html
elements = elements.reject{|e| e.search('th').empty? }
elements.map do |node|
node.search('/th').map do |n|
- n.inner_text.strip.gsub(/\n[\n \t]*/, "\n")
+ n.inner_text.strip.gsub(/[ \t]*\n[\n \t]*/, "\n")
#n.inner_text.strip.gsub(/\n \t\t/, "\n")
end
end
@@ -41,6 +41,12 @@
"<table id='my_id'><tr><th>h1 - row 1 <br/>\t\th1 - row 2</th></tr></table>",
[["h1 - row 1\nh1 - row 2"]]
end
+
+ it 'should throw away any amount of white space spanning new lines' do
+ verify_table_header_match 'my_id',
+ "<table id='my_id'><tr><th>h1 - row 1 \n <br/>\n \t\th1 - row 2</th></tr></table>",
+ [["h1 - row 1\nh1 - row 2"]]
+ end
end
describe 'passed wrong id' do

0 comments on commit 5af14b1

Please sign in to comment.