locator 0.0.7 → 0.0.8
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/core_ext/string/underscore.rb +2 -1
- data/lib/locator.rb +9 -8
- data/lib/locator/assertions.rb +74 -0
- data/lib/locator/matcher.rb +0 -57
- data/lib/locator/version.rb +1 -1
- metadata +28 -4
data/lib/locator.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'core_ext/string/underscore'
|
2
2
|
|
3
3
|
module Locator
|
4
|
-
autoload :
|
5
|
-
autoload :
|
6
|
-
autoload :
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
4
|
+
autoload :Assertions, 'locator/assertions'
|
5
|
+
autoload :Boolean, 'locator/boolean'
|
6
|
+
autoload :Dom, 'locator/dom'
|
7
|
+
autoload :Decoding, 'locator/decoding'
|
8
|
+
autoload :Element, 'locator/element'
|
9
|
+
autoload :Matcher, 'locator/matcher'
|
10
|
+
autoload :Result, 'locator/result'
|
11
|
+
autoload :Xpath, 'locator/xpath'
|
11
12
|
|
12
13
|
extend Decoding
|
13
14
|
|
@@ -31,7 +32,7 @@ module Locator
|
|
31
32
|
|
32
33
|
def locators
|
33
34
|
@locators ||= Hash[*Element.constants.map do |name|
|
34
|
-
[name.to_s.underscore.to_sym, Element.const_get(name)]
|
35
|
+
[name.to_s.dup.underscore.to_sym, Element.const_get(name)]
|
35
36
|
end.flatten]
|
36
37
|
end
|
37
38
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test/unit' # TODO make this optional, e.g. when Rspec or minitest are present
|
2
|
+
|
3
|
+
module Locator
|
4
|
+
module Assertions
|
5
|
+
include Test::Unit::Assertions, Matcher
|
6
|
+
|
7
|
+
# Asserts that the response body contains the given string or regexp
|
8
|
+
def assert_contains(*args)
|
9
|
+
matcher = contain(*args)
|
10
|
+
assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
|
11
|
+
end
|
12
|
+
|
13
|
+
# Asserts that the response body does not contain the given string or regexp
|
14
|
+
def assert_does_not_contain(*args)
|
15
|
+
matcher = contain(*args)
|
16
|
+
assert !matcher.matches?(send(__response_accessor).body), matcher.negative_failure_message
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_has_tag(html, *args, &block)
|
20
|
+
matcher = have_tag(*args, &block)
|
21
|
+
assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
|
22
|
+
end
|
23
|
+
|
24
|
+
def assert_no_tag(html, *args, &block)
|
25
|
+
matcher = have_tag(*args, &block)
|
26
|
+
assert !matcher.matches?(send(__response_accessor).body), matcher.negative_failure_message
|
27
|
+
end
|
28
|
+
alias :assert_does_not_have_tag :assert_no_tag
|
29
|
+
|
30
|
+
# Asserts that the response body matches the given XPath
|
31
|
+
def assert_has_xpath(html, *args, &block)
|
32
|
+
matcher = have_xpath(*args, &block)
|
33
|
+
assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
|
34
|
+
end
|
35
|
+
|
36
|
+
# Asserts that the response body does not match the given XPath
|
37
|
+
def assert_no_xpath(html, *args, &block)
|
38
|
+
matcher = have_xpath(*args, &block)
|
39
|
+
assert !matcher.matches?(send(__response_accessor).body), matcher.negative_failure_message
|
40
|
+
end
|
41
|
+
alias :assert_does_not_have_xpath :assert_no_tag
|
42
|
+
|
43
|
+
# Asserts that the response body matches the given CSS selector
|
44
|
+
def assert_has_css(html, *args, &block)
|
45
|
+
matcher = have_css(*args, &block)
|
46
|
+
assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
|
47
|
+
end
|
48
|
+
|
49
|
+
# Asserts that the response body does not match the given CSS selector
|
50
|
+
def assert_no_css(html, *args, &block)
|
51
|
+
matcher = have_css(*args, &block)
|
52
|
+
assert !matcher.matches?(send(__response_accessor).body), matcher.negative_failure_message
|
53
|
+
end
|
54
|
+
alias :assert_does_not_have_css :assert_no_tag
|
55
|
+
|
56
|
+
def assert_css_class(css_classes, css_class)
|
57
|
+
matcher = HaveCssClass.new(css_class)
|
58
|
+
assert matcher.matches?(css_classes.body), matcher.failure_message
|
59
|
+
end
|
60
|
+
|
61
|
+
def assert_no_css_class(css_classes, css_class)
|
62
|
+
matcher = HaveCssClass.new(css_class)
|
63
|
+
assert matcher.matches?(css_classes.body), matcher.negative_failure_message
|
64
|
+
end
|
65
|
+
alias :assert_does_not_include_css_class :assert_no_tag
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def __response_accessor
|
70
|
+
# TODO should probably be a module accessor
|
71
|
+
@__response_accessor ||= respond_to?(:last_response) ? :last_response : :response
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/locator/matcher.rb
CHANGED
@@ -23,62 +23,5 @@ module Locator
|
|
23
23
|
def have_css_class(css_class)
|
24
24
|
HaveCssClass.new(css_class)
|
25
25
|
end
|
26
|
-
|
27
|
-
# Asserts that the response body contains the given string or regexp
|
28
|
-
def assert_contains(*args)
|
29
|
-
matcher = contain(*args)
|
30
|
-
assert matcher.matches?(response.body), matcher.failure_message
|
31
|
-
end
|
32
|
-
|
33
|
-
# Asserts that the response body does not contain the given string or regexp
|
34
|
-
def assert_does_not_contain(*args)
|
35
|
-
matcher = contain(*args)
|
36
|
-
assert !matcher.matches?(response.body), matcher.negative_failure_message
|
37
|
-
end
|
38
|
-
|
39
|
-
def assert_has_tag(html, *args, &block)
|
40
|
-
matcher = have_tag(*args, &block)
|
41
|
-
assert matcher.matches?(response.body), matcher.failure_message
|
42
|
-
end
|
43
|
-
|
44
|
-
def assert_no_tag(html, *args, &block)
|
45
|
-
matcher = have_tag(*args, &block)
|
46
|
-
assert !matcher.matches?(response.body), matcher.negative_failure_message
|
47
|
-
end
|
48
|
-
|
49
|
-
# Asserts that the response body matches the given XPath
|
50
|
-
def assert_has_xpath(html, *args, &block)
|
51
|
-
matcher = have_xpath(*args, &block)
|
52
|
-
assert matcher.matches?(response.body), matcher.failure_message
|
53
|
-
end
|
54
|
-
|
55
|
-
# Asserts that the response body does not match the given XPath
|
56
|
-
def assert_no_xpath(html, *args, &block)
|
57
|
-
matcher = have_xpath(*args, &block)
|
58
|
-
assert !matcher.matches?(response.body), matcher.negative_failure_message
|
59
|
-
end
|
60
|
-
|
61
|
-
# Asserts that the response body matches the given CSS selector
|
62
|
-
def assert_has_css(html, *args, &block)
|
63
|
-
matcher = have_css(*args, &block)
|
64
|
-
assert matcher.matches?(response.body), matcher.failure_message
|
65
|
-
end
|
66
|
-
|
67
|
-
# Asserts that the response body does not match the given CSS selector
|
68
|
-
def assert_no_css(html, *args, &block)
|
69
|
-
matcher = have_css(*args, &block)
|
70
|
-
assert !matcher.matches?(response.body), matcher.negative_failure_message
|
71
|
-
end
|
72
|
-
|
73
|
-
def assert_css_class(css_classes, css_class)
|
74
|
-
matcher = HaveCssClass.new(css_class)
|
75
|
-
assert matcher.matches?(css_classes.body), matcher.failure_message
|
76
|
-
end
|
77
|
-
|
78
|
-
def assert_no_css_class(css_classes, css_class)
|
79
|
-
matcher = HaveCssClass.new(css_class)
|
80
|
-
assert matcher.matches?(css_classes.body), matcher.negative_failure_message
|
81
|
-
end
|
82
|
-
|
83
26
|
end
|
84
27
|
end
|
data/lib/locator/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Sven Fuchs
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-12-17 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: htmlentities
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 55
|
27
30
|
segments:
|
28
31
|
- 4
|
29
32
|
- 2
|
@@ -31,6 +34,22 @@ dependencies:
|
|
31
34
|
version: 4.2.0
|
32
35
|
type: :runtime
|
33
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: nokogiri
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 5
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 4
|
49
|
+
- 1
|
50
|
+
version: 1.4.1
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
34
53
|
description: Generic html element locators for integration testing.
|
35
54
|
email: svenfuchs@artweb-design.de
|
36
55
|
executables: []
|
@@ -43,6 +62,7 @@ files:
|
|
43
62
|
- lib/core_ext/hash/except.rb
|
44
63
|
- lib/core_ext/hash/slice.rb
|
45
64
|
- lib/core_ext/string/underscore.rb
|
65
|
+
- lib/locator/assertions.rb
|
46
66
|
- lib/locator/boolean.rb
|
47
67
|
- lib/locator/decoding.rb
|
48
68
|
- lib/locator/dom/htmlunit/element.rb
|
@@ -91,16 +111,20 @@ rdoc_options: []
|
|
91
111
|
require_paths:
|
92
112
|
- lib
|
93
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
94
115
|
requirements:
|
95
116
|
- - ">="
|
96
117
|
- !ruby/object:Gem::Version
|
118
|
+
hash: 3
|
97
119
|
segments:
|
98
120
|
- 0
|
99
121
|
version: "0"
|
100
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
101
124
|
requirements:
|
102
125
|
- - ">="
|
103
126
|
- !ruby/object:Gem::Version
|
127
|
+
hash: 23
|
104
128
|
segments:
|
105
129
|
- 1
|
106
130
|
- 3
|
@@ -109,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
133
|
requirements: []
|
110
134
|
|
111
135
|
rubyforge_project: "[none]"
|
112
|
-
rubygems_version: 1.3.
|
136
|
+
rubygems_version: 1.3.7
|
113
137
|
signing_key:
|
114
138
|
specification_version: 3
|
115
139
|
summary: Generic html element locators for integration testing
|