Permalink
Browse files

Minor refactoring for code clarity.

  • Loading branch information...
1 parent 894cd7c commit 1b4fad8d773f226d1b0c0e200cbf1f948b5b7348 Stephen Anderson committed Jan 4, 2009
Showing with 6 additions and 6 deletions.
  1. +2 −2 lib/matchers/table_body_matcher.rb
  2. +2 −2 lib/matchers/table_header_matcher.rb
  3. +2 −2 lib/matchers/table_matcher.rb
@@ -29,11 +29,11 @@ def negative_failure_message
def extract_html_content html
doc = Hpricot.XML(html)
- elements = doc.search("table#{"##{@table_id}" if @table_id} tr").select{|e| ! e.search('td').empty? }
+ elements = doc.search("table#{"##{@table_id}" if @table_id} tr").reject{|e| e.search('td').empty? }
elements.map{|n| n.search('/td').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}
end
end
end
end
-end
+end
@@ -29,11 +29,11 @@ def negative_failure_message
def extract_html_content html
doc = Hpricot.XML(html)
- elements = doc.search("table#{"##{@table_id}" if @table_id} tr").select{|e| ! e.search('th').empty? }
+ elements = doc.search("table#{"##{@table_id}" if @table_id} tr").reject{|e| e.search('th').empty? }
elements.map{|n| n.search('/th').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}
end
end
end
end
-end
+end
@@ -31,10 +31,10 @@ def extract_html_content html
doc = Hpricot.XML(html)
rows = doc.search("table#{"##{@table_id}" if @table_id} tr")
- header_elements = rows.select{|e| ! e.search('th').empty? }
+ header_elements = rows.reject{|e| e.search('th').empty? }
header_content = header_elements.map{|n| n.search('/th').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}
- body_elements = rows.select{|e| ! e.search('td').empty? }
+ body_elements = rows.reject{|e| e.search('td').empty? }
body_content = body_elements.map{|n| n.search('/td').map{|n| n.inner_text.strip.gsub(/\n \t\t/, "\n")}}
header_content + body_content

0 comments on commit 1b4fad8

Please sign in to comment.