Permalink
Browse files

have_xpath instead of have_selector to avoid problems with forms within

tables
  • Loading branch information...
nando committed Mar 16, 2010
1 parent fa97be0 commit f0be0f38f6ab3b20bfbeab56793bd894ddc6666d
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/mundo_pepino/es_ES/definitions.rb
@@ -275,23 +275,22 @@
end
Entonces /^(#{_veo_o_no_}) (?:una|la) tabla (?:(["'].+?['"]|[^ ]+) )?con (?:el|los) (?:siguientes? )?(?:valore?s?|contenidos?):$/ do |should, table_id, valores|
- table_id = "##{table_id.to_unquoted}" if table_id
+ table_id = "[@id = '#{table_id.to_unquoted}']" if table_id
shouldified = shouldify(should)
- #TODO For capybara page instead response and have_css instead have_selector
- response.send shouldified, have_selector("table#{table_id}")
+ response.send shouldified, have_xpath("//table#{table_id}")
- if have_selector("table#{table_id} tbody").matches?(response)
+ if have_xpath("//table#{table_id}/tbody").matches?(response)
start_row = 1
- tbody = "tbody"
+ tbody = "/tbody"
else
start_row = 2
tbody = ""
end
valores.raw[1..-1].each_with_index do |row, i|
row.each_with_index do |cell, j|
- response.send shouldified,
- have_selector("table#{table_id} #{tbody} tr:nth-child(#{i+start_row})>td:nth-child(#{j+1})") { |td|
+ response.send shouldified,
+ have_xpath("//table#{table_id}#{tbody}/tr[position() = #{i+start_row} ]/td[position() = #{j+1}]") { |td|
td.inner_text.should =~ /#{cell == '.*' ? cell : Regexp.escape((cell||"").to_translated)}/
}
end

0 comments on commit f0be0f3

Please sign in to comment.