assert2 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/assert2/xhtml.rb CHANGED
@@ -173,20 +173,30 @@ class BeHtmlWith
173
173
 
174
174
  attr_reader :references
175
175
 
176
- def build_xpath(element)
177
- path = element.name.sub(/\!$/, '')
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
- './descendant::' + build_xpath(child)
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
@@ -80,7 +80,7 @@ end
80
80
  class BeHtmlWith
81
81
 
82
82
  def deAmpAmp(stwing)
83
- stwing.gsub('&amp;amp;', '&').gsub('&amp;', '&')
83
+ stwing.to_s.gsub('&amp;amp;', '&').gsub('&amp;', '&')
84
84
  end # ERGO await a fix in Nokogiri, and hope nobody actually means &amp;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 build_xpath(element)
177
- path = element.name.sub(/\!$/, '')
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
- './descendant::' + build_xpath(child)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phlip