rspec-xml 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/lib/rspec-xml/version.rb +1 -1
- data/lib/rspec-xml/xml_matchers/have_xpath.rb +5 -6
- data/lib/rspec-xml/xml_matchers/have_xpath/matcher.rb +3 -3
- data/lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb +3 -3
- data/readme.md +3 -0
- data/spec/rspec-xml/xml_matchers/have_xpath/matcher_spec.rb +7 -7
- data/spec/rspec-xml/xml_matchers/have_xpath/text_matcher_spec.rb +11 -11
- data/spec/rspec-xml/xml_matchers/have_xpath_matcher_spec.rb +9 -14
- data/spec/rspec-xml/xml_matchers_spec.rb +5 -5
- data/spec/spec_helper.rb +1 -0
- metadata +3 -3
- data/.rspec +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4790e15a330a52a75a38666cdcf5e2d97587b9
|
4
|
+
data.tar.gz: acde529945aaa1e92570da8cace1f252ede78683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc05010c99f90ea3de5ad8db1afe705a34eaa4b92cebd5254479feabbb31f9d0e249acc5136cd3db2db32b8f30e81e25b182de2ec4e77476e11898f007799401
|
7
|
+
data.tar.gz: 6bd9b43cd3e803ea1e14449f578fd79d1faa458219138e6dc540ddb4421ecff9caa2c59c34341d049f2bd871d0998a3aef1d9260adc794e036397cf83e4bf1d8
|
data/.travis.yml
ADDED
data/lib/rspec-xml/version.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module RSpecXML
|
2
2
|
module XMLMatchers
|
3
3
|
class HaveXPath
|
4
|
-
|
5
4
|
def initialize(xpath, example_group)
|
6
5
|
self.matcher = Matcher.new(
|
7
6
|
:xpath => xpath,
|
8
7
|
:example_group => example_group
|
9
8
|
)
|
10
|
-
end
|
9
|
+
end
|
11
10
|
|
12
11
|
def with_text(text)
|
13
12
|
self.matcher = TextMatcher.new(
|
@@ -31,12 +30,12 @@ module RSpecXML
|
|
31
30
|
matcher.matches?(xml)
|
32
31
|
end
|
33
32
|
|
34
|
-
def
|
35
|
-
matcher.
|
33
|
+
def failure_message
|
34
|
+
matcher.failure_message
|
36
35
|
end
|
37
36
|
|
38
|
-
def
|
39
|
-
matcher.
|
37
|
+
def failure_message_when_negated
|
38
|
+
matcher.failure_message_when_negated
|
40
39
|
end
|
41
40
|
|
42
41
|
private
|
@@ -17,11 +17,11 @@ module RSpecXML
|
|
17
17
|
"have xpath #{full_xpath}"
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
"expected #{full_xpath} to exist"
|
20
|
+
def failure_message
|
21
|
+
"expected #{full_xpath} to exist"
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def failure_message_when_negated
|
25
25
|
"expected #{full_xpath} to not exist"
|
26
26
|
end
|
27
27
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RSpecXML
|
2
2
|
module XMLMatchers
|
3
3
|
class HaveXPath
|
4
|
-
|
4
|
+
|
5
5
|
private
|
6
6
|
|
7
7
|
class TextMatcher
|
@@ -19,11 +19,11 @@ module RSpecXML
|
|
19
19
|
"have xpath #{xpath} with text #{text}"
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def failure_message
|
23
23
|
"expected #{xpath} to contain #{text}"
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def failure_message_when_negated
|
27
27
|
"expected #{xpath} to not exist with text: #{text}"
|
28
28
|
end
|
29
29
|
|
data/readme.md
CHANGED
@@ -4,42 +4,42 @@ describe RSpecXML::XMLMatchers::HaveXPath::Matcher do
|
|
4
4
|
describe '#initialize' do
|
5
5
|
it 'should accept an xpath' do
|
6
6
|
matcher = subject.class.new(:xpath => 'not a real xpath')
|
7
|
-
matcher.xpath.
|
7
|
+
expect(matcher.xpath).to eq 'not a real xpath'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#matches?' do
|
12
12
|
# TODO mock out Nokogiri
|
13
|
-
|
13
|
+
|
14
14
|
it 'should return true if the supplied xml contains the xpath' do
|
15
15
|
matcher = subject.class.new(:xpath => '//hi')
|
16
|
-
matcher.matches?('<hi></hi>').
|
16
|
+
expect(matcher.matches?('<hi></hi>')).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should return false if the supplied xml contains the xpath' do
|
20
20
|
matcher = subject.class.new(:xpath => '//hi')
|
21
|
-
matcher.matches?('<no></no>').
|
21
|
+
expect(matcher.matches?('<no></no>')).to be_falsey
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#failure_message_for_should' do
|
26
26
|
it 'should turn a message about the xpath not existing when it should' do
|
27
27
|
subject.stubs(:xpath).returns('xpath')
|
28
|
-
subject.
|
28
|
+
expect(subject.failure_message).to eq "expected xpath to exist"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#failure_message_for_should_not' do
|
33
33
|
it 'should turn a message about the xpath existing when it should not' do
|
34
34
|
subject.stubs(:xpath).returns('xpath')
|
35
|
-
subject.
|
35
|
+
expect(subject.failure_message_when_negated).to eq "expected xpath to not exist"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#description' do
|
40
40
|
it 'should return a message describing the xpath matcher' do
|
41
41
|
subject.stubs(:xpath).returns('/expr')
|
42
|
-
subject.description.
|
42
|
+
expect(subject.description).to eq 'have xpath /expr'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -4,49 +4,49 @@ describe RSpecXML::XMLMatchers::HaveXPath::TextMatcher do
|
|
4
4
|
describe '#initialize' do
|
5
5
|
it 'should accept an xpath' do
|
6
6
|
matcher = subject.class.new(:xpath => 'not a real xpath')
|
7
|
-
matcher.send(:xpath).
|
7
|
+
expect(matcher.send(:xpath)).to eq 'not a real xpath'
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should accept text' do
|
11
11
|
matcher = subject.class.new(:text => 'text')
|
12
|
-
matcher.send(:text).
|
12
|
+
expect(matcher.send(:text)).to eq 'text'
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '#matches?' do
|
18
18
|
# TODO mock out Nokogiri
|
19
|
-
|
19
|
+
|
20
20
|
it 'should return true if the supplied xml contains the xpath with supplied text' do
|
21
21
|
matcher = subject.class.new(:xpath => '//hi', :text => 'hi')
|
22
|
-
matcher.matches?('<hi>hi</hi>').
|
22
|
+
expect(matcher.matches?('<hi>hi</hi>')).to be_truthy
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should return false if the supplied xml contains the xpath but not the text' do
|
26
26
|
matcher = subject.class.new(:xpath => '//hi', :text => 'what')
|
27
|
-
matcher.matches?('<hi></hi>').
|
27
|
+
expect(matcher.matches?('<hi></hi>')).to be_falsey
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should return false if the supplied xml does not contain the xpath' do
|
31
31
|
matcher = subject.class.new(:xpath => '//hi', :text => 'what')
|
32
|
-
matcher.matches?('<no></no>').
|
32
|
+
expect(matcher.matches?('<no></no>')).to be_falsey
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
-
describe '#
|
37
|
+
describe '#failure_message' do
|
38
38
|
it 'should turn a message about the xpath not existing when the supplied text' do
|
39
39
|
subject.stubs(:xpath).returns('xpath')
|
40
40
|
subject.stubs(:text).returns('text')
|
41
|
-
subject.
|
41
|
+
expect(subject.failure_message).to eq "expected xpath to contain text"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe '#
|
45
|
+
describe '#failure_message_when_negated' do
|
46
46
|
it 'should turn a message about the xpath existing when it should not' do
|
47
47
|
subject.stubs(:xpath).returns('xpath')
|
48
48
|
subject.stubs(:text).returns('text')
|
49
|
-
subject.
|
49
|
+
expect(subject.failure_message_when_negated).to eq "expected xpath to not exist with text: text"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -54,7 +54,7 @@ describe RSpecXML::XMLMatchers::HaveXPath::TextMatcher do
|
|
54
54
|
it 'should return a message describing the text matcher' do
|
55
55
|
subject.stubs(:xpath).returns('/expr')
|
56
56
|
subject.stubs(:text).returns('text')
|
57
|
-
subject.description.
|
57
|
+
expect(subject.description).to eq 'have xpath /expr with text text'
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -11,17 +11,17 @@ end
|
|
11
11
|
|
12
12
|
describe RSpecXML::XMLMatchers::HaveXPath do
|
13
13
|
let(:example_group) { Factory.example_group }
|
14
|
-
|
14
|
+
|
15
15
|
describe '#intialize' do
|
16
16
|
it 'should build and save a matcher containing the supplied xpath' do
|
17
|
-
|
17
|
+
|
18
18
|
RSpecXML::XMLMatchers::HaveXPath::Matcher.
|
19
19
|
expects(:new).
|
20
20
|
with(:xpath => 'fake xpath', :example_group => example_group).
|
21
21
|
returns(:flag)
|
22
22
|
|
23
23
|
xpath_matcher = Factory.xpath_matcher('fake xpath')
|
24
|
-
xpath_matcher.send(:matcher).
|
24
|
+
expect(xpath_matcher.send(:matcher)).to eq :flag
|
25
25
|
|
26
26
|
end
|
27
27
|
end
|
@@ -35,7 +35,7 @@ describe RSpecXML::XMLMatchers::HaveXPath do
|
|
35
35
|
returns(:flag)
|
36
36
|
|
37
37
|
xpath_matcher = Factory.xpath_matcher('fake xpath').with_text('blah')
|
38
|
-
xpath_matcher.send(:matcher).
|
38
|
+
expect(xpath_matcher.send(:matcher)).to eq :flag
|
39
39
|
|
40
40
|
end
|
41
41
|
end
|
@@ -49,27 +49,22 @@ describe RSpecXML::XMLMatchers::HaveXPath do
|
|
49
49
|
returns(:flag)
|
50
50
|
|
51
51
|
xpath_matcher = Factory.xpath_matcher('fake xpath').with_attr({"name" => "John Doe"})
|
52
|
-
xpath_matcher.send(:matcher).
|
52
|
+
expect(xpath_matcher.send(:matcher)).to eq :flag
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe '#
|
56
|
+
describe '#failure_message' do
|
57
57
|
it 'should delegate to the matcher' do
|
58
58
|
xpath_matcher = Factory.xpath_matcher('whatever')
|
59
|
-
xpath_matcher.stubs(:matcher).
|
60
|
-
returns(stub( :failure_message_for_should => 'woo!' ))
|
61
|
-
|
62
|
-
xpath_matcher.failure_message_for_should.should == 'woo!'
|
59
|
+
xpath_matcher.stubs(:matcher).returns(stub( :failure_message => 'woo!' ))
|
63
60
|
end
|
64
61
|
end
|
65
62
|
|
66
|
-
describe '#
|
63
|
+
describe '#failure_message_when_negated' do
|
67
64
|
it 'should delegate to the matcher' do
|
68
65
|
xpath_matcher = Factory.xpath_matcher('whatever')
|
69
|
-
xpath_matcher.stubs(:matcher).
|
70
|
-
returns(stub( :failure_message_for_should_not => 'woo!' ))
|
71
66
|
|
72
|
-
xpath_matcher.
|
67
|
+
expect(xpath_matcher.failure_message_when_negated).to eq 'expected whatever to not exist'
|
73
68
|
end
|
74
69
|
end
|
75
70
|
end
|
@@ -4,16 +4,16 @@ describe RSpecXML::XMLMatchers do
|
|
4
4
|
describe '#within' do
|
5
5
|
|
6
6
|
it 'should create instance variable @xpath_stack inside within block' do
|
7
|
-
@xpath_stack.
|
7
|
+
expect(@xpath_stack).to be_nil
|
8
8
|
within("foo/bar") do
|
9
|
-
@xpath_stack.
|
9
|
+
expect(@xpath_stack).to eq ["foo/bar"]
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should increase @xpath_stack properly when blocks are nested' do
|
14
14
|
within("foo") do
|
15
15
|
within("/bar") do
|
16
|
-
@xpath_stack.
|
16
|
+
expect(@xpath_stack).to eq ["foo", "/bar"]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -22,9 +22,9 @@ describe RSpecXML::XMLMatchers do
|
|
22
22
|
within("foo") do
|
23
23
|
within("/bar") do
|
24
24
|
end
|
25
|
-
@xpath_stack.
|
25
|
+
expect(@xpath_stack).to eq ["foo"]
|
26
26
|
end
|
27
|
-
@xpath_stack.
|
27
|
+
expect(@xpath_stack).to eq []
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Carper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: turnip
|
@@ -74,7 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
-
- ".
|
77
|
+
- ".travis.yml"
|
78
78
|
- CHANGELOG.md
|
79
79
|
- Gemfile
|
80
80
|
- Rakefile
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
-r turnip/rspec
|