xpath 2.0.0 → 3.2.0

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/spec/union_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe XPath::Union do
@@ -5,60 +7,57 @@ describe XPath::Union do
5
7
  let(:doc) { Nokogiri::HTML(template) }
6
8
 
7
9
  describe '#expressions' do
8
- it "should return the expressions" do
10
+ it 'should return the expressions' do
9
11
  @expr1 = XPath.generate { |x| x.descendant(:p) }
10
12
  @expr2 = XPath.generate { |x| x.descendant(:div) }
11
13
  @collection = XPath::Union.new(@expr1, @expr2)
12
- @collection.expressions.should == [@expr1, @expr2]
14
+ @collection.expressions.should eq [@expr1, @expr2]
13
15
  end
14
16
  end
15
17
 
16
18
  describe '#each' do
17
- it "should iterate through the expressions" do
19
+ it 'should iterate through the expressions' do
18
20
  @expr1 = XPath.generate { |x| x.descendant(:p) }
19
21
  @expr2 = XPath.generate { |x| x.descendant(:div) }
20
22
  @collection = XPath::Union.new(@expr1, @expr2)
21
23
  exprs = []
22
24
  @collection.each { |expr| exprs << expr }
23
- exprs.should == [@expr1, @expr2]
25
+ exprs.should eq [@expr1, @expr2]
24
26
  end
25
27
  end
26
28
 
27
29
  describe '#map' do
28
- it "should map the expressions" do
30
+ it 'should map the expressions' do
29
31
  @expr1 = XPath.generate { |x| x.descendant(:p) }
30
32
  @expr2 = XPath.generate { |x| x.descendant(:div) }
31
33
  @collection = XPath::Union.new(@expr1, @expr2)
32
- @collection.map { |expr| expr.expression }.should == [:descendant, :descendant]
34
+ @collection.map(&:expression).should eq %i[descendant descendant]
33
35
  end
34
36
  end
35
37
 
36
38
  describe '#to_xpath' do
37
- it "should create a valid xpath expression" do
39
+ it 'should create a valid xpath expression' do
38
40
  @expr1 = XPath.generate { |x| x.descendant(:p) }
39
41
  @expr2 = XPath.generate { |x| x.descendant(:div).where(x.attr(:id) == 'foo') }
40
42
  @collection = XPath::Union.new(@expr1, @expr2)
41
43
  @results = doc.xpath(@collection.to_xpath)
42
- @results[0][:title].should == 'fooDiv'
43
- @results[1].text.should == 'Blah'
44
- @results[2].text.should == 'Bax'
44
+ @results[0][:title].should eq 'fooDiv'
45
+ @results[1].text.should eq 'Blah'
46
+ @results[2].text.should eq 'Bax'
45
47
  end
46
48
  end
47
49
 
48
-
49
50
  describe '#where and others' do
50
- it "should be delegated to the individual expressions" do
51
+ it 'should be delegated to the individual expressions' do
51
52
  @expr1 = XPath.generate { |x| x.descendant(:p) }
52
53
  @expr2 = XPath.generate { |x| x.descendant(:div) }
53
54
  @collection = XPath::Union.new(@expr1, @expr2)
54
55
  @xpath1 = @collection.where(XPath.attr(:id) == 'foo').to_xpath
55
56
  @xpath2 = @collection.where(XPath.attr(:id) == 'fooDiv').to_xpath
56
57
  @results = doc.xpath(@xpath1)
57
- @results[0][:title].should == 'fooDiv'
58
+ @results[0][:title].should eq 'fooDiv'
58
59
  @results = doc.xpath(@xpath2)
59
- @results[0][:id].should == 'fooDiv'
60
+ @results[0][:id].should eq 'fooDiv'
60
61
  end
61
62
  end
62
-
63
63
  end
64
-