assert2 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/assert2/xhtml.rb +16 -6
- data/lib/assert2/xhtml.rb~ +17 -7
- metadata +1 -1
data/lib/assert2/xhtml.rb
CHANGED
@@ -173,20 +173,30 @@ class BeHtmlWith
|
|
173
173
|
|
174
174
|
attr_reader :references
|
175
175
|
|
176
|
-
def
|
177
|
-
path =
|
176
|
+
def build_predicate(element)
|
177
|
+
path = ''
|
178
178
|
element_kids = element.children.grep(Nokogiri::XML::Element)
|
179
|
-
path << '[ '
|
180
|
-
count = @references.length
|
181
|
-
@references << element
|
182
179
|
|
183
180
|
if element_kids.any?
|
184
181
|
path << element_kids.map{|child|
|
185
|
-
'
|
182
|
+
if child.name == 'without' # TODO throw away nested withouts?
|
183
|
+
'not( ' + build_predicate(child) + '1=1 )'
|
184
|
+
else
|
185
|
+
'./descendant::' + build_xpath(child)
|
186
|
+
end
|
186
187
|
}.join(' and ')
|
187
188
|
path << ' and '
|
188
189
|
end
|
189
190
|
|
191
|
+
return path
|
192
|
+
end
|
193
|
+
|
194
|
+
def build_xpath(element)
|
195
|
+
count = @references.length
|
196
|
+
@references << element # note we skip the without @reference!
|
197
|
+
path = element.name.sub(/\!$/, '')
|
198
|
+
path << '[ '
|
199
|
+
path << build_predicate(element)
|
190
200
|
path << "refer(., '#{count}') ]" # last so boolean short-circuiting optimizes
|
191
201
|
return path
|
192
202
|
end
|
data/lib/assert2/xhtml.rb~
CHANGED
@@ -80,7 +80,7 @@ end
|
|
80
80
|
class BeHtmlWith
|
81
81
|
|
82
82
|
def deAmpAmp(stwing)
|
83
|
-
stwing.gsub('&amp;', '&').gsub('&', '&')
|
83
|
+
stwing.to_s.gsub('&amp;', '&').gsub('&', '&')
|
84
84
|
end # ERGO await a fix in Nokogiri, and hope nobody actually means &amp; !!!
|
85
85
|
|
86
86
|
def get_texts(element)
|
@@ -173,20 +173,30 @@ class BeHtmlWith
|
|
173
173
|
|
174
174
|
attr_reader :references
|
175
175
|
|
176
|
-
def
|
177
|
-
path =
|
176
|
+
def build_predicate(element)
|
177
|
+
path = ''
|
178
178
|
element_kids = element.children.grep(Nokogiri::XML::Element)
|
179
|
-
path << '[ '
|
180
|
-
count = @references.length
|
181
|
-
@references << element
|
182
179
|
|
183
180
|
if element_kids.any?
|
184
181
|
path << element_kids.map{|child|
|
185
|
-
'
|
182
|
+
if child.name == 'without' # TODO throw away nested withouts?
|
183
|
+
'not( ' + build_predicate(child) + ' 1=1 )'
|
184
|
+
else
|
185
|
+
'./descendant::' + build_xpath(child)
|
186
|
+
end
|
186
187
|
}.join(' and ')
|
187
188
|
path << ' and '
|
188
189
|
end
|
189
190
|
|
191
|
+
return path
|
192
|
+
end
|
193
|
+
|
194
|
+
def build_xpath(element)
|
195
|
+
count = @references.length
|
196
|
+
@references << element # note we skip the without @reference!
|
197
|
+
path = element.name.sub(/\!$/, '')
|
198
|
+
path << '[ '
|
199
|
+
path << build_predicate(element)
|
190
200
|
path << "refer(., '#{count}') ]" # last so boolean short-circuiting optimizes
|
191
201
|
return path
|
192
202
|
end
|