page_magic 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -1
- data/.simplecov +2 -2
- data/Gemfile +9 -9
- data/Gemfile.lock +70 -73
- data/Rakefile +9 -1
- data/VERSION +1 -1
- data/circle.yml +3 -1
- data/lib/active_support/core_ext/object/to_query.rb +84 -0
- data/lib/page_magic.rb +2 -1
- data/lib/page_magic/drivers.rb +2 -3
- data/lib/page_magic/element.rb +10 -4
- data/lib/page_magic/elements.rb +1 -1
- data/lib/page_magic/instance_methods.rb +4 -1
- data/lib/page_magic/matcher.rb +2 -2
- data/lib/page_magic/utils/string.rb +12 -0
- data/page_magic.gemspec +15 -11
- data/spec/lib/active_support/core_ext/object/to_query_test.rb +78 -0
- data/spec/page_magic/element/query_spec.rb +2 -2
- data/spec/page_magic/element/selector_spec.rb +2 -2
- data/spec/page_magic/elements_spec.rb +2 -4
- data/spec/page_magic/session_spec.rb +2 -3
- data/spec/page_magic/utils/string_spec.rb +34 -0
- metadata +28 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdfe7b7eb4aa09e8eab7a961a1b03156f4650af8
|
4
|
+
data.tar.gz: faaf84a4ff0c42dffa54b405bfbcb31812a3be6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 352cdaa5d434b979ec5061193e9864f7fcb1b2d3418a4de064be94fef99ce71288da4421c4cfaceb1079fc0349e4b7c1ab4852c91c0f626bc9c7922f20f80b55
|
7
|
+
data.tar.gz: 1b22dfc283761f9ded938a899d115b7ffb3b07c96e58736879f33161621b6ccfb1510d0f1886bec75e30a95d1d5c4656613fc9671c9cc79a23e2d0d5f21cca69
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,8 @@ Metrics/LineLength:
|
|
4
4
|
AllCops:
|
5
5
|
TargetRubyVersion: 2.1
|
6
6
|
Exclude:
|
7
|
+
- 'lib/active_support/**/*'
|
8
|
+
- 'spec/lib/active_support/**/*'
|
7
9
|
- 'pkg/**/*'
|
8
10
|
- 'vendor/**/*'
|
9
11
|
- 'coverage/**/*'
|
@@ -17,4 +19,18 @@ Metrics/MethodLength:
|
|
17
19
|
Max: 11
|
18
20
|
|
19
21
|
Style/MethodMissing:
|
20
|
-
Enabled: false
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/BlockLength:
|
25
|
+
Enabled: true
|
26
|
+
Exclude:
|
27
|
+
- 'spec/**/*'
|
28
|
+
|
29
|
+
Style/PercentLiteralDelimiters:
|
30
|
+
PreferredDelimiters:
|
31
|
+
default: ()
|
32
|
+
'%i': '[]'
|
33
|
+
'%I': '[]'
|
34
|
+
'%r': '{}'
|
35
|
+
'%w': '[]'
|
36
|
+
'%W': '[]'
|
data/.simplecov
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'pullreview/coverage'
|
2
|
-
require "codeclimate-test-reporter"
|
3
2
|
|
4
|
-
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter,PullReview::Coverage::Formatter
|
3
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter,PullReview::Coverage::Formatter]
|
5
4
|
|
6
5
|
SimpleCov.start do
|
7
6
|
add_filter '/spec/'
|
7
|
+
add_filter '/lib/active_support/core_ext/object/to_query.rb'
|
8
8
|
end
|
data/Gemfile
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gem 'activesupport-inflector'
|
3
4
|
gem 'capybara', '>= 2.5'
|
4
|
-
gem 'activesupport', '~> 4'
|
5
5
|
|
6
6
|
group :test do
|
7
|
-
gem '
|
8
|
-
gem 'sinatra'
|
9
|
-
gem 'rspec', require: 'rspec/core/rake_task'
|
10
|
-
gem 'simplecov', require: false
|
11
|
-
gem 'poltergeist'
|
7
|
+
gem 'arbre'
|
12
8
|
gem 'codeclimate-test-reporter', group: :test, require: nil
|
9
|
+
gem 'poltergeist'
|
13
10
|
gem 'pullreview-coverage', require: false
|
14
11
|
gem 'reek'
|
15
|
-
gem '
|
12
|
+
gem 'rspec', require: 'rspec/core/rake_task'
|
13
|
+
gem 'simplecov', require: false
|
14
|
+
gem 'sinatra'
|
15
|
+
gem 'watir-webdriver'
|
16
16
|
end
|
17
17
|
|
18
18
|
group :development do
|
19
|
+
gem 'github-markup', '~> 1.4'
|
19
20
|
gem 'jeweler', '~> 2.0'
|
21
|
+
gem 'redcarpet', '~> 3.3'
|
20
22
|
gem 'rubocop', '~> 0.34', require: 'rubocop/rake_task'
|
21
23
|
gem 'yard', '~> 0.8'
|
22
|
-
gem 'redcarpet', '~> 3.3'
|
23
|
-
gem 'github-markup', '~> 1.4'
|
24
24
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (4.2.
|
4
|
+
activesupport (4.2.10)
|
5
5
|
i18n (~> 0.7)
|
6
|
-
json (~> 1.7, >= 1.7.7)
|
7
6
|
minitest (~> 5.1)
|
8
7
|
thread_safe (~> 0.3, >= 0.3.4)
|
9
8
|
tzinfo (~> 1.1)
|
10
|
-
|
11
|
-
|
9
|
+
activesupport-inflector (0.1.0)
|
10
|
+
addressable (2.4.0)
|
12
11
|
arbre (1.1.1)
|
13
12
|
activesupport (>= 3.0.0)
|
14
13
|
ast (2.3.0)
|
@@ -17,159 +16,157 @@ GEM
|
|
17
16
|
ice_nine (~> 0.11.0)
|
18
17
|
thread_safe (~> 0.3, >= 0.3.1)
|
19
18
|
builder (3.2.3)
|
20
|
-
capybara (2.
|
19
|
+
capybara (2.15.2)
|
21
20
|
addressable
|
22
|
-
|
21
|
+
mini_mime (>= 0.1.3)
|
23
22
|
nokogiri (>= 1.3.3)
|
24
23
|
rack (>= 1.0.0)
|
25
24
|
rack-test (>= 0.5.4)
|
26
25
|
xpath (~> 2.0)
|
27
|
-
certifi (
|
28
|
-
childprocess (0.
|
26
|
+
certifi (2017.07.27)
|
27
|
+
childprocess (0.8.0)
|
29
28
|
ffi (~> 1.0, >= 1.0.11)
|
30
29
|
cliver (0.3.2)
|
31
|
-
codeclimate-engine-rb (0.
|
30
|
+
codeclimate-engine-rb (0.4.0)
|
32
31
|
virtus (~> 1.0)
|
33
|
-
codeclimate-test-reporter (0.
|
34
|
-
simplecov (
|
32
|
+
codeclimate-test-reporter (1.0.8)
|
33
|
+
simplecov (<= 0.13)
|
35
34
|
coercible (1.0.0)
|
36
35
|
descendants_tracker (~> 0.0.1)
|
37
36
|
descendants_tracker (0.0.4)
|
38
37
|
thread_safe (~> 0.3, >= 0.3.1)
|
39
|
-
diff-lcs (1.
|
38
|
+
diff-lcs (1.3)
|
40
39
|
docile (1.1.5)
|
41
40
|
equalizer (0.0.11)
|
42
41
|
faraday (0.9.2)
|
43
42
|
multipart-post (>= 1.2, < 3)
|
44
|
-
ffi (1.9.
|
43
|
+
ffi (1.9.18)
|
45
44
|
git (1.3.0)
|
46
|
-
github-markup (1.
|
47
|
-
github_api (0.
|
48
|
-
addressable (~> 2.
|
49
|
-
descendants_tracker (~> 0.0.
|
45
|
+
github-markup (1.6.1)
|
46
|
+
github_api (0.16.0)
|
47
|
+
addressable (~> 2.4.0)
|
48
|
+
descendants_tracker (~> 0.0.4)
|
50
49
|
faraday (~> 0.8, < 0.10)
|
51
|
-
hashie (>=
|
52
|
-
|
53
|
-
|
54
|
-
oauth2
|
50
|
+
hashie (>= 3.4)
|
51
|
+
mime-types (>= 1.16, < 3.0)
|
52
|
+
oauth2 (~> 1.0)
|
55
53
|
hashie (3.5.6)
|
56
54
|
highline (1.7.8)
|
57
|
-
i18n (0.
|
55
|
+
i18n (0.8.6)
|
58
56
|
ice_nine (0.11.2)
|
59
|
-
jeweler (2.3.
|
57
|
+
jeweler (2.3.7)
|
60
58
|
builder
|
61
|
-
bundler (>= 1
|
59
|
+
bundler (>= 1)
|
62
60
|
git (>= 1.2.5)
|
63
|
-
github_api (~> 0.
|
61
|
+
github_api (~> 0.16.0)
|
64
62
|
highline (>= 1.6.15)
|
65
63
|
nokogiri (>= 1.5.10)
|
66
64
|
psych (~> 2.2)
|
67
65
|
rake
|
68
66
|
rdoc
|
69
67
|
semver2
|
70
|
-
json (1.
|
68
|
+
json (2.1.0)
|
71
69
|
jwt (1.5.6)
|
72
|
-
mime-types (3
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
minitest (5.9.0)
|
70
|
+
mime-types (2.99.3)
|
71
|
+
mini_mime (0.1.4)
|
72
|
+
mini_portile2 (2.3.0)
|
73
|
+
minitest (5.10.3)
|
77
74
|
multi_json (1.12.2)
|
78
75
|
multi_xml (0.6.0)
|
79
76
|
multipart-post (2.0.0)
|
80
|
-
nokogiri (1.
|
81
|
-
mini_portile2 (~> 2.
|
77
|
+
nokogiri (1.8.1)
|
78
|
+
mini_portile2 (~> 2.3.0)
|
82
79
|
oauth2 (1.4.0)
|
83
80
|
faraday (>= 0.8, < 0.13)
|
84
81
|
jwt (~> 1.0)
|
85
82
|
multi_json (~> 1.3)
|
86
83
|
multi_xml (~> 0.5)
|
87
84
|
rack (>= 1.2, < 3)
|
88
|
-
|
85
|
+
parallel (1.12.0)
|
86
|
+
parser (2.4.0.0)
|
89
87
|
ast (~> 2.2)
|
90
|
-
poltergeist (1.
|
88
|
+
poltergeist (1.16.0)
|
91
89
|
capybara (~> 2.1)
|
92
90
|
cliver (~> 0.3.1)
|
93
91
|
websocket-driver (>= 0.2.0)
|
94
92
|
powerpack (0.1.1)
|
95
93
|
psych (2.2.4)
|
96
|
-
public_suffix (3.0.0)
|
97
94
|
pullreview-coverage (0.0.5)
|
98
95
|
certifi
|
99
96
|
simplecov (>= 0.7.1, < 1.0.0)
|
100
97
|
rack (1.6.8)
|
101
98
|
rack-protection (1.5.3)
|
102
99
|
rack
|
103
|
-
rack-test (0.
|
104
|
-
rack (>= 1.0)
|
105
|
-
rainbow (2.
|
100
|
+
rack-test (0.7.0)
|
101
|
+
rack (>= 1.0, < 3)
|
102
|
+
rainbow (2.2.2)
|
103
|
+
rake
|
106
104
|
rake (12.1.0)
|
107
105
|
rdoc (5.1.0)
|
108
|
-
redcarpet (3.
|
109
|
-
reek (4.2
|
110
|
-
codeclimate-engine-rb (~> 0.
|
111
|
-
parser (
|
106
|
+
redcarpet (3.4.0)
|
107
|
+
reek (4.7.2)
|
108
|
+
codeclimate-engine-rb (~> 0.4.0)
|
109
|
+
parser (>= 2.4.0.0, < 2.5)
|
112
110
|
rainbow (~> 2.0)
|
113
|
-
rspec (3.
|
114
|
-
rspec-core (~> 3.
|
115
|
-
rspec-expectations (~> 3.
|
116
|
-
rspec-mocks (~> 3.
|
117
|
-
rspec-core (3.
|
118
|
-
rspec-support (~> 3.
|
119
|
-
rspec-expectations (3.
|
111
|
+
rspec (3.6.0)
|
112
|
+
rspec-core (~> 3.6.0)
|
113
|
+
rspec-expectations (~> 3.6.0)
|
114
|
+
rspec-mocks (~> 3.6.0)
|
115
|
+
rspec-core (3.6.0)
|
116
|
+
rspec-support (~> 3.6.0)
|
117
|
+
rspec-expectations (3.6.0)
|
120
118
|
diff-lcs (>= 1.2.0, < 2.0)
|
121
|
-
rspec-support (~> 3.
|
122
|
-
rspec-mocks (3.
|
119
|
+
rspec-support (~> 3.6.0)
|
120
|
+
rspec-mocks (3.6.0)
|
123
121
|
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
-
rspec-support (~> 3.
|
125
|
-
rspec-support (3.
|
126
|
-
rubocop (0.
|
127
|
-
|
122
|
+
rspec-support (~> 3.6.0)
|
123
|
+
rspec-support (3.6.0)
|
124
|
+
rubocop (0.50.0)
|
125
|
+
parallel (~> 1.10)
|
126
|
+
parser (>= 2.3.3.1, < 3.0)
|
128
127
|
powerpack (~> 0.1)
|
129
|
-
rainbow (>=
|
128
|
+
rainbow (>= 2.2.2, < 3.0)
|
130
129
|
ruby-progressbar (~> 1.7)
|
131
130
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
132
|
-
ruby-progressbar (1.
|
133
|
-
rubyzip (1.2.
|
134
|
-
selenium-webdriver (
|
131
|
+
ruby-progressbar (1.9.0)
|
132
|
+
rubyzip (1.2.1)
|
133
|
+
selenium-webdriver (3.6.0)
|
135
134
|
childprocess (~> 0.5)
|
136
135
|
rubyzip (~> 1.0)
|
137
|
-
websocket (~> 1.0)
|
138
136
|
semver2 (3.4.2)
|
139
|
-
simplecov (0.
|
137
|
+
simplecov (0.13.0)
|
140
138
|
docile (~> 1.1.0)
|
141
139
|
json (>= 1.8, < 3)
|
142
140
|
simplecov-html (~> 0.10.0)
|
143
|
-
simplecov-html (0.10.
|
144
|
-
sinatra (1.4.
|
141
|
+
simplecov-html (0.10.2)
|
142
|
+
sinatra (1.4.8)
|
145
143
|
rack (~> 1.5)
|
146
144
|
rack-protection (~> 1.4)
|
147
145
|
tilt (>= 1.3, < 3)
|
148
146
|
thread_safe (0.3.6)
|
149
|
-
tilt (2.0.
|
150
|
-
tzinfo (1.2.
|
147
|
+
tilt (2.0.8)
|
148
|
+
tzinfo (1.2.3)
|
151
149
|
thread_safe (~> 0.1)
|
152
|
-
unicode-display_width (1.
|
150
|
+
unicode-display_width (1.3.0)
|
153
151
|
virtus (1.0.5)
|
154
152
|
axiom-types (~> 0.1)
|
155
153
|
coercible (~> 1.0)
|
156
154
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
157
155
|
equalizer (~> 0.0, >= 0.0.9)
|
158
|
-
watir-webdriver (0.9.
|
156
|
+
watir-webdriver (0.9.9)
|
159
157
|
selenium-webdriver (>= 2.46.2)
|
160
|
-
websocket (
|
161
|
-
websocket-driver (0.6.4)
|
158
|
+
websocket-driver (0.7.0)
|
162
159
|
websocket-extensions (>= 0.1.0)
|
163
160
|
websocket-extensions (0.1.2)
|
164
|
-
xpath (2.
|
161
|
+
xpath (2.1.0)
|
165
162
|
nokogiri (~> 1.3)
|
166
|
-
yard (0.9.
|
163
|
+
yard (0.9.9)
|
167
164
|
|
168
165
|
PLATFORMS
|
169
166
|
ruby
|
170
167
|
|
171
168
|
DEPENDENCIES
|
172
|
-
activesupport
|
169
|
+
activesupport-inflector
|
173
170
|
arbre
|
174
171
|
capybara (>= 2.5)
|
175
172
|
codeclimate-test-reporter
|
data/Rakefile
CHANGED
@@ -19,4 +19,12 @@ end
|
|
19
19
|
|
20
20
|
Jeweler::RubygemsDotOrgTasks.new
|
21
21
|
|
22
|
-
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new do |t|
|
24
|
+
t.libs << 'spec'
|
25
|
+
t.pattern = 'spec/**/*_test.rb'
|
26
|
+
t.warning = true
|
27
|
+
t.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
task default: [:spec, :test, 'rubocop:auto_correct']
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.9
|
data/circle.yml
CHANGED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
class Object
|
4
|
+
# Alias of <tt>to_s</tt>.
|
5
|
+
def to_param
|
6
|
+
to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
# Converts an object into a string suitable for use as a URL query string,
|
10
|
+
# using the given <tt>key</tt> as the param name.
|
11
|
+
def to_query(key)
|
12
|
+
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class NilClass
|
17
|
+
# Returns +self+.
|
18
|
+
def to_param
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class TrueClass
|
24
|
+
# Returns +self+.
|
25
|
+
def to_param
|
26
|
+
self
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class FalseClass
|
31
|
+
# Returns +self+.
|
32
|
+
def to_param
|
33
|
+
self
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Array
|
38
|
+
# Calls <tt>to_param</tt> on all its elements and joins the result with
|
39
|
+
# slashes. This is used by <tt>url_for</tt> in Action Pack.
|
40
|
+
def to_param
|
41
|
+
collect(&:to_param).join '/'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Converts an array into a string suitable for use as a URL query string,
|
45
|
+
# using the given +key+ as the param name.
|
46
|
+
#
|
47
|
+
# ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
|
48
|
+
def to_query(key)
|
49
|
+
prefix = "#{key}[]"
|
50
|
+
|
51
|
+
if empty?
|
52
|
+
nil.to_query(prefix)
|
53
|
+
else
|
54
|
+
collect { |value| value.to_query(prefix) }.join '&'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Hash
|
60
|
+
# Returns a string representation of the receiver suitable for use as a URL
|
61
|
+
# query string:
|
62
|
+
#
|
63
|
+
# {name: 'David', nationality: 'Danish'}.to_query
|
64
|
+
# # => "name=David&nationality=Danish"
|
65
|
+
#
|
66
|
+
# An optional namespace can be passed to enclose key names:
|
67
|
+
#
|
68
|
+
# {name: 'David', nationality: 'Danish'}.to_query('user')
|
69
|
+
# # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
|
70
|
+
#
|
71
|
+
# The string pairs "key=value" that conform the query string
|
72
|
+
# are sorted lexicographically in ascending order.
|
73
|
+
#
|
74
|
+
# This method is also aliased as +to_param+.
|
75
|
+
def to_query(namespace = nil)
|
76
|
+
collect do |key, value|
|
77
|
+
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
|
78
|
+
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
79
|
+
end
|
80
|
+
end.compact.sort! * '&'
|
81
|
+
end
|
82
|
+
|
83
|
+
alias to_param to_query
|
84
|
+
end
|
data/lib/page_magic.rb
CHANGED
data/lib/page_magic/drivers.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'page_magic/driver'
|
2
|
+
require 'page_magic/utils/string'
|
2
3
|
module PageMagic
|
3
4
|
# class Drivers - creates an object that can be used to hold driver definitions
|
4
5
|
# These PageMagic gets the user's chosen driver from this object.
|
@@ -16,12 +17,10 @@ module PageMagic
|
|
16
17
|
# Loads drivers defined in files at the given path
|
17
18
|
# @param [String] path where the drivers are located
|
18
19
|
def load(path = "#{__dir__}/drivers")
|
19
|
-
require 'active_support/inflector'
|
20
|
-
|
21
20
|
Dir["#{path}/*.rb"].each do |driver_file|
|
22
21
|
require driver_file
|
23
22
|
driver_name = File.basename(driver_file)[/(.*)\.rb$/, 1]
|
24
|
-
register self.class.const_get(
|
23
|
+
register self.class.const_get(Utils::String.classify(driver_name))
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
data/lib/page_magic/element.rb
CHANGED
@@ -6,12 +6,18 @@ require 'page_magic/element/query_builder'
|
|
6
6
|
module PageMagic
|
7
7
|
# class Element - represents an element in a html page.
|
8
8
|
class Element
|
9
|
-
EVENT_TYPES = [
|
9
|
+
EVENT_TYPES = %i[set select select_option unselect_option click].freeze
|
10
10
|
DEFAULT_HOOK = proc {}.freeze
|
11
11
|
EVENT_NOT_SUPPORTED_MSG = '%s event not supported'.freeze
|
12
12
|
|
13
|
-
include
|
14
|
-
|
13
|
+
include Locators
|
14
|
+
include WaitMethods
|
15
|
+
include SessionMethods
|
16
|
+
include Watchers
|
17
|
+
include SelectorMethods
|
18
|
+
extend Forwardable
|
19
|
+
extend SelectorMethods
|
20
|
+
extend Elements
|
15
21
|
|
16
22
|
attr_reader :type, :name, :parent_element, :browser_element, :before_events, :after_events
|
17
23
|
|
@@ -24,7 +30,7 @@ module PageMagic
|
|
24
30
|
# @!method before_events
|
25
31
|
# If a block is passed in, it adds it to be run before an event is triggered on an element.
|
26
32
|
# @see .after_events
|
27
|
-
%i
|
33
|
+
%i[after_events before_events].each do |method|
|
28
34
|
define_method method do |&block|
|
29
35
|
instance_variable_name = "@#{method}".to_sym
|
30
36
|
instance_variable_value = instance_variable_get(instance_variable_name) || [DEFAULT_HOOK]
|
data/lib/page_magic/elements.rb
CHANGED
@@ -14,7 +14,7 @@ module PageMagic
|
|
14
14
|
|
15
15
|
INVALID_METHOD_NAME_MSG = 'a method already exists with this method name'.freeze
|
16
16
|
|
17
|
-
TYPES = [
|
17
|
+
TYPES = %i[text_field button link checkbox select_list radio textarea].collect do |type|
|
18
18
|
[type, :"#{type}s"]
|
19
19
|
end.flatten.freeze
|
20
20
|
|
@@ -3,7 +3,10 @@ module PageMagic
|
|
3
3
|
module InstanceMethods
|
4
4
|
attr_reader :browser, :session, :browser_element
|
5
5
|
|
6
|
-
include
|
6
|
+
include Element::Locators
|
7
|
+
include WaitMethods
|
8
|
+
include SessionMethods
|
9
|
+
include Watchers
|
7
10
|
|
8
11
|
# Creates a new instance
|
9
12
|
# @param [Session] session session that provides gateway to the browser throw the users chosen browser
|
data/lib/page_magic/matcher.rb
CHANGED
@@ -44,7 +44,7 @@ module PageMagic
|
|
44
44
|
# @param [Matcher] other
|
45
45
|
# @return [Fixnum] -1 = smaller, 0 = equal to, 1 = greater than
|
46
46
|
def <=>(other)
|
47
|
-
results = [
|
47
|
+
results = %i[path parameters fragment].collect do |component|
|
48
48
|
compare(send(component), other.send(component))
|
49
49
|
end
|
50
50
|
results.find { |result| !result.zero? } || 0
|
@@ -113,7 +113,7 @@ module PageMagic
|
|
113
113
|
|
114
114
|
def query_string_valid?(string)
|
115
115
|
return true unless parameters
|
116
|
-
|
116
|
+
parameters.none? do |key, value|
|
117
117
|
!compatible?(parameters_hash(string)[key.downcase.to_s], value)
|
118
118
|
end
|
119
119
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module PageMagic
|
2
|
+
module Utils
|
3
|
+
# module String - contains methods for manipulating strings
|
4
|
+
module String
|
5
|
+
class << self
|
6
|
+
def classify(string_or_symbol)
|
7
|
+
string_or_symbol.to_s.split('_').collect(&:capitalize).reduce(:+)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/page_magic.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: page_magic 1.2.
|
5
|
+
# stub: page_magic 1.2.9 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "page_magic"
|
9
|
-
s.version = "1.2.
|
9
|
+
s.version = "1.2.9"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"Rakefile",
|
31
31
|
"VERSION",
|
32
32
|
"circle.yml",
|
33
|
+
"lib/active_support/core_ext/object/to_query.rb",
|
33
34
|
"lib/page_magic.rb",
|
34
35
|
"lib/page_magic/class_methods.rb",
|
35
36
|
"lib/page_magic/driver.rb",
|
@@ -51,11 +52,13 @@ Gem::Specification.new do |s|
|
|
51
52
|
"lib/page_magic/matcher.rb",
|
52
53
|
"lib/page_magic/session.rb",
|
53
54
|
"lib/page_magic/session_methods.rb",
|
55
|
+
"lib/page_magic/utils/string.rb",
|
54
56
|
"lib/page_magic/wait_methods.rb",
|
55
57
|
"lib/page_magic/watcher.rb",
|
56
58
|
"lib/page_magic/watchers.rb",
|
57
59
|
"page_magic.gemspec",
|
58
60
|
"spec/element_spec.rb",
|
61
|
+
"spec/lib/active_support/core_ext/object/to_query_test.rb",
|
59
62
|
"spec/page_magic/class_methods_spec.rb",
|
60
63
|
"spec/page_magic/driver_spec.rb",
|
61
64
|
"spec/page_magic/drivers/poltergeist_spec.rb",
|
@@ -73,6 +76,7 @@ Gem::Specification.new do |s|
|
|
73
76
|
"spec/page_magic/matcher_spec.rb",
|
74
77
|
"spec/page_magic/session_methods_spec.rb",
|
75
78
|
"spec/page_magic/session_spec.rb",
|
79
|
+
"spec/page_magic/utils/string_spec.rb",
|
76
80
|
"spec/page_magic/wait_methods_spec.rb",
|
77
81
|
"spec/page_magic/watchers_spec.rb",
|
78
82
|
"spec/page_magic_spec.rb",
|
@@ -95,30 +99,30 @@ Gem::Specification.new do |s|
|
|
95
99
|
s.specification_version = 4
|
96
100
|
|
97
101
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
102
|
+
s.add_runtime_dependency(%q<activesupport-inflector>, [">= 0"])
|
98
103
|
s.add_runtime_dependency(%q<capybara>, [">= 2.5"])
|
99
|
-
s.
|
104
|
+
s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
|
100
105
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
106
|
+
s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
|
101
107
|
s.add_development_dependency(%q<rubocop>, ["~> 0.34"])
|
102
108
|
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
103
|
-
s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
|
104
|
-
s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
|
105
109
|
else
|
110
|
+
s.add_dependency(%q<activesupport-inflector>, [">= 0"])
|
106
111
|
s.add_dependency(%q<capybara>, [">= 2.5"])
|
107
|
-
s.add_dependency(%q<
|
112
|
+
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
108
113
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
114
|
+
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
109
115
|
s.add_dependency(%q<rubocop>, ["~> 0.34"])
|
110
116
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
111
|
-
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
112
|
-
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
113
117
|
end
|
114
118
|
else
|
119
|
+
s.add_dependency(%q<activesupport-inflector>, [">= 0"])
|
115
120
|
s.add_dependency(%q<capybara>, [">= 2.5"])
|
116
|
-
s.add_dependency(%q<
|
121
|
+
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
117
122
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
123
|
+
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
118
124
|
s.add_dependency(%q<rubocop>, ["~> 0.34"])
|
119
125
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
120
|
-
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
121
|
-
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
122
126
|
end
|
123
127
|
end
|
124
128
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minitest'
|
4
|
+
Minitest.autorun
|
5
|
+
require 'active_support/core_ext/object/to_query'
|
6
|
+
|
7
|
+
class ToQueryTest < ::Minitest::Test
|
8
|
+
def test_simple_conversion
|
9
|
+
assert_query_equal 'a=10', a: 10
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_cgi_escaping
|
13
|
+
assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_nil_parameter_value
|
17
|
+
empty = Object.new
|
18
|
+
def empty.to_param
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
assert_query_equal 'a=', 'a' => empty
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_nested_conversion
|
25
|
+
assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
|
26
|
+
person: Hash[:login, 'seckar', :name, 'Nicholas']
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_multiple_nested
|
30
|
+
assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
|
31
|
+
Hash[:account, { person: { id: 20 } }, :person, { id: 10 }]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_array_values
|
35
|
+
assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
|
36
|
+
person: { id: [10, 20] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_array_values_are_not_sorted
|
40
|
+
assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
|
41
|
+
person: { id: [20, 10] }
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_empty_array
|
45
|
+
assert_equal 'person%5B%5D=', [].to_query('person')
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_nested_empty_hash
|
49
|
+
assert_equal '',
|
50
|
+
{}.to_query
|
51
|
+
assert_query_equal 'a=1&b%5Bc%5D=3',
|
52
|
+
a: 1, b: { c: 3, d: {} }
|
53
|
+
assert_query_equal '',
|
54
|
+
a: { b: { c: {} } }
|
55
|
+
assert_query_equal 'b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12',
|
56
|
+
p: 12, b: { c: false, e: nil, f: '' }
|
57
|
+
assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=',
|
58
|
+
b: { c: 3, k: {}, f: '' }
|
59
|
+
assert_query_equal 'b=3',
|
60
|
+
a: [], b: 3
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_hash_with_namespace
|
64
|
+
hash = { name: 'Nakshay', nationality: 'Indian' }
|
65
|
+
assert_equal 'user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian', hash.to_query('user')
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_hash_sorted_lexicographically
|
69
|
+
hash = { type: 'human', name: 'Nakshay' }
|
70
|
+
assert_equal 'name=Nakshay&type=human', hash.to_query
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def assert_query_equal(expected, actual)
|
76
|
+
assert_equal expected.split('&'), actual.to_query.split('&')
|
77
|
+
end
|
78
|
+
end
|
@@ -18,7 +18,7 @@ module PageMagic
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'raises an error' do
|
21
|
-
expected_message = 'Unable to find css "wrong"'
|
21
|
+
expected_message = 'Unable to find visible css "wrong"'
|
22
22
|
expect { subject.execute(page.browser) }.to raise_exception(ElementMissingException, expected_message)
|
23
23
|
end
|
24
24
|
end
|
@@ -29,7 +29,7 @@ module PageMagic
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'raises an error' do
|
32
|
-
expected_message = 'Ambiguous match, found 2 elements matching css "a"'
|
32
|
+
expected_message = 'Ambiguous match, found 2 elements matching visible css "a"'
|
33
33
|
expect { subject.execute(page.browser) }.to raise_error AmbiguousQueryException, expected_message
|
34
34
|
end
|
35
35
|
end
|
@@ -33,7 +33,7 @@ module PageMagic
|
|
33
33
|
described_class.new(supports_type: true)
|
34
34
|
end
|
35
35
|
it 'includes the element type in the result' do
|
36
|
-
expect(subject.build(:field, :locator)).to eq([
|
36
|
+
expect(subject.build(:field, :locator)).to eq(%i[field locator])
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -54,7 +54,7 @@ module PageMagic
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'is added to the result' do
|
57
|
-
expect(subject.build(:field, :locator)).to eq([
|
57
|
+
expect(subject.build(:field, :locator)).to eq(%i[css locator])
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -113,8 +113,7 @@ module PageMagic
|
|
113
113
|
subject.class_eval do
|
114
114
|
link(:hello, text: 'world')
|
115
115
|
|
116
|
-
def hello
|
117
|
-
end
|
116
|
+
def hello; end
|
118
117
|
end
|
119
118
|
end.to raise_error(InvalidMethodNameException)
|
120
119
|
end
|
@@ -122,8 +121,7 @@ module PageMagic
|
|
122
121
|
it 'should not allow element names that match method names' do
|
123
122
|
expect do
|
124
123
|
subject.class_eval do
|
125
|
-
def hello
|
126
|
-
end
|
124
|
+
def hello; end
|
127
125
|
|
128
126
|
link(:hello, text: 'world')
|
129
127
|
end
|
@@ -124,7 +124,7 @@ module PageMagic
|
|
124
124
|
context 'more than one match on path' do
|
125
125
|
it 'orders the results by specificity ' do
|
126
126
|
subject.define_page_mappings %r{/page} => :mapped_page_using_regex, '/page' => :mapped_page_using_string
|
127
|
-
expected_result = [
|
127
|
+
expected_result = %i[mapped_page_using_string mapped_page_using_regex]
|
128
128
|
expect(subject.instance_eval { matches('/page') }).to eq(expected_result)
|
129
129
|
end
|
130
130
|
end
|
@@ -155,8 +155,7 @@ module PageMagic
|
|
155
155
|
|
156
156
|
it 'checks the current page' do
|
157
157
|
page.class_eval do
|
158
|
-
def my_method
|
159
|
-
end
|
158
|
+
def my_method; end
|
160
159
|
end
|
161
160
|
expect(subject.respond_to?(:my_method)).to eq(true)
|
162
161
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'page_magic/utils/string'
|
2
|
+
module PageMagic
|
3
|
+
module Utils
|
4
|
+
describe String do
|
5
|
+
describe '.classify' do
|
6
|
+
context 'parameter is symbol' do
|
7
|
+
it 'returns a string' do
|
8
|
+
expect(described_class.classify(:Symbol)).to eq('Symbol')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'parameter is string' do
|
13
|
+
it 'returns a string' do
|
14
|
+
expect(described_class.classify(:String)).to eq('String')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'single word' do
|
19
|
+
context 'first letter is lower case' do
|
20
|
+
it 'converts the first letter to uppercase' do
|
21
|
+
expect(described_class.classify(:symbol)).to eq('Symbol')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'snakecase' do
|
27
|
+
it 'removes underscores and capitalises each word' do
|
28
|
+
expect(described_class.classify(:snake_case)).to eq('SnakeCase')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leon Davis
|
@@ -11,103 +11,103 @@ cert_chain: []
|
|
11
11
|
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport-inflector
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: capybara
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: github-markup
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: jeweler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '2.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: redcarpet
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0.34'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0.34'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: yard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0.8'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0.8'
|
111
111
|
description: Framework for modeling and interacting with webpages which wraps capybara
|
112
112
|
email: info@lad-tech.com
|
113
113
|
executables: []
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- Rakefile
|
128
128
|
- VERSION
|
129
129
|
- circle.yml
|
130
|
+
- lib/active_support/core_ext/object/to_query.rb
|
130
131
|
- lib/page_magic.rb
|
131
132
|
- lib/page_magic/class_methods.rb
|
132
133
|
- lib/page_magic/driver.rb
|
@@ -148,11 +149,13 @@ files:
|
|
148
149
|
- lib/page_magic/matcher.rb
|
149
150
|
- lib/page_magic/session.rb
|
150
151
|
- lib/page_magic/session_methods.rb
|
152
|
+
- lib/page_magic/utils/string.rb
|
151
153
|
- lib/page_magic/wait_methods.rb
|
152
154
|
- lib/page_magic/watcher.rb
|
153
155
|
- lib/page_magic/watchers.rb
|
154
156
|
- page_magic.gemspec
|
155
157
|
- spec/element_spec.rb
|
158
|
+
- spec/lib/active_support/core_ext/object/to_query_test.rb
|
156
159
|
- spec/page_magic/class_methods_spec.rb
|
157
160
|
- spec/page_magic/driver_spec.rb
|
158
161
|
- spec/page_magic/drivers/poltergeist_spec.rb
|
@@ -170,6 +173,7 @@ files:
|
|
170
173
|
- spec/page_magic/matcher_spec.rb
|
171
174
|
- spec/page_magic/session_methods_spec.rb
|
172
175
|
- spec/page_magic/session_spec.rb
|
176
|
+
- spec/page_magic/utils/string_spec.rb
|
173
177
|
- spec/page_magic/wait_methods_spec.rb
|
174
178
|
- spec/page_magic/watchers_spec.rb
|
175
179
|
- spec/page_magic_spec.rb
|