marty_rspec 0.0.0 → 0.0.1
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.
- checksums.yaml +5 -13
- data/lib/marty_rspec/custom_matchers.rb +26 -0
- data/lib/marty_rspec/netzke_grid.rb +14 -4
- data/lib/marty_rspec/util.rb +11 -36
- data/lib/marty_rspec/version.rb +1 -1
- data/lib/marty_rspec.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MDE3YzJmNjNhY2U0OTI0NGNjMGRmMjU5ZmNhZmI0YjcxNWJhYWQ3OA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6561535ced695e713a4c2aacb6a9e466019c2185
|
4
|
+
data.tar.gz: 0c034a62ed8e12a41ab5006d715a625f930ad12f
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NGU5ZWE4Njc0MGQ2NTQzZGI5OGVkYWUyN2E3NzZjNGJhOTQwYTk0ZjRiZWUx
|
11
|
-
YzU2ZTRmOGUxZDliYjA2MGVkNjQ5NGU4MTM2NzM0ZDg1OTY1OGY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MjZlN2I0MTU0YWQ3NWM2Yzk5ZGQzNTA3OWNmMWU5OGM1NGVlZDA1MjEwMGZj
|
14
|
-
NzBhZWMyZDE1MDlhYTA4ZTgxYzA3ZDc2NWFjOWEwZjFjMGYxNWMzYTRmZjJi
|
15
|
-
NjFkYzQzODI3Y2UzNjVlOGJlODE3NzRkYmJmNWY1YjIwNjk4ODM=
|
6
|
+
metadata.gz: e9c19c974199c52acf44de92a9abc5f2dc83360d9b0170c0fbb46f9156f0eaf86f4792974fde6a59bfaa5453801b5d93bf8f4a37d687c1665cc5d4d3bbff281e
|
7
|
+
data.tar.gz: 6f7d07317c44ec96cdbc1e464cbb90a6ec93cf1e4710b703a16375721dcb68ca731ed6369d7192afa2c7528a374b71dd6df4bef80a854ed5fa4b3a6d7901c1d9
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Capybara.add_selector(:gridpanel) do
|
2
|
+
xpath { |name| ".//div[contains(@id, '#{name}')] | " +
|
3
|
+
".//div[contains(@id, '#{name.camelize(:lower)}')]" }
|
4
|
+
end
|
5
|
+
Capybara.add_selector(:msg) do
|
6
|
+
xpath { "//div[@id='msg-div']" }
|
7
|
+
end
|
8
|
+
Capybara.add_selector(:body) do
|
9
|
+
xpath { ".//div[@data-ref='body']" }
|
10
|
+
end
|
11
|
+
Capybara.add_selector(:input) do
|
12
|
+
xpath { |name| "//input[@name='#{name}']" }
|
13
|
+
end
|
14
|
+
Capybara.add_selector(:status) do
|
15
|
+
xpath { |name| "//div[contains(@id, 'statusbar')]//div[text()='#{name}']" }
|
16
|
+
end
|
17
|
+
Capybara.add_selector(:btn) do
|
18
|
+
xpath { |name| ".//span[text()='#{name}']" }
|
19
|
+
end
|
20
|
+
Capybara.add_selector(:refresh) do
|
21
|
+
xpath { "//img[contains(@class, 'x-tool-refresh')]" }
|
22
|
+
end
|
23
|
+
Capybara.add_selector(:gridcolumn) do
|
24
|
+
xpath { |name| ".//span[contains(@class, 'x-column-header')]" +
|
25
|
+
"//span[text()='#{name}']" }
|
26
|
+
end
|
@@ -9,6 +9,7 @@ module MartyRSpec
|
|
9
9
|
class NetzkeGridNode
|
10
10
|
include Util
|
11
11
|
include Capybara::DSL
|
12
|
+
include RSpec::Matchers
|
12
13
|
|
13
14
|
attr_reader :name, :grid
|
14
15
|
|
@@ -112,7 +113,7 @@ module MartyRSpec
|
|
112
113
|
js_get_fields = fields.each_key.map do |k|
|
113
114
|
<<-JS
|
114
115
|
var col = Ext.ComponentQuery.query('gridcolumn[name=\"#{k}\"]', grid)[0];
|
115
|
-
var value = col.assoc ? r.get('
|
116
|
+
var value = col.assoc ? r.get('association_values')['#{k}'] :
|
116
117
|
r.get('#{k}');
|
117
118
|
if (value instanceof Date) {
|
118
119
|
obj['#{k}'] = value.toISOString().substring(0,
|
@@ -130,7 +131,12 @@ module MartyRSpec
|
|
130
131
|
#{js_get_fields}
|
131
132
|
return obj;
|
132
133
|
JS
|
133
|
-
|
134
|
+
|
135
|
+
# in netzke 1.0, "False" becomes false
|
136
|
+
expected_value = fields.each_with_object({}) do | (k, v), h |
|
137
|
+
h[k.to_s] = v == "False" ? false : v
|
138
|
+
end
|
139
|
+
wait_for_element { expect(res).to eq(expected_value) }
|
134
140
|
end
|
135
141
|
|
136
142
|
def sorted_by? col, direction = 'asc'
|
@@ -140,7 +146,7 @@ module MartyRSpec
|
|
140
146
|
var colValues = [];
|
141
147
|
|
142
148
|
grid.getStore().each(function(r){
|
143
|
-
var val = col.assoc ? r.get('
|
149
|
+
var val = col.assoc ? r.get('association_values)['#{col}'] :
|
144
150
|
r.get('#{col}');
|
145
151
|
if (val) colValues.#{direction == 'asc' ? 'push' : 'unshift'}(val);
|
146
152
|
});
|
@@ -163,7 +169,11 @@ module MartyRSpec
|
|
163
169
|
var store = combo.getStore();
|
164
170
|
|
165
171
|
// force a retry if the store is still loading
|
166
|
-
if (store.loading == true) {
|
172
|
+
if (store.loading == true) {
|
173
|
+
now = new Date().getTime();
|
174
|
+
while(new Date().getTime() < now + 100) { }
|
175
|
+
return false;
|
176
|
+
}
|
167
177
|
|
168
178
|
for(var i = 0; i < store.getCount(); i++) {
|
169
179
|
r.push(store.getAt(i).get('text'));
|
data/lib/marty_rspec/util.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
module MartyRSpec
|
1
|
+
module MartyRSpec
|
2
|
+
module Util
|
3
|
+
MAX_WAIT_TIME = 5.0
|
2
4
|
|
3
5
|
# essentially works as documentation & wait
|
4
6
|
def by message, level=0
|
@@ -80,7 +82,7 @@ module MartyRSpec::Util
|
|
80
82
|
end
|
81
83
|
|
82
84
|
def zoom_out
|
83
|
-
el = find(
|
85
|
+
el = find(:body, match: :first)
|
84
86
|
el.native.send_keys([:control, '0'])
|
85
87
|
el.native.send_keys([:control, '-'])
|
86
88
|
el.native.send_keys([:control, '-'])
|
@@ -102,11 +104,10 @@ module MartyRSpec::Util
|
|
102
104
|
res
|
103
105
|
end
|
104
106
|
|
105
|
-
def run_js js_str, seconds_to_wait =
|
107
|
+
def run_js js_str, seconds_to_wait = MAX_WAIT_TIME, sleeptime = 0.1
|
106
108
|
result = wait_for_element(seconds_to_wait, sleeptime) do
|
107
|
-
res =
|
108
|
-
|
109
|
-
res.nil? ? true : res
|
109
|
+
page.document.synchronize { @res = page.execute_script(js_str) }
|
110
|
+
@res
|
110
111
|
end
|
111
112
|
result
|
112
113
|
end
|
@@ -222,14 +223,12 @@ module MartyRSpec::Util
|
|
222
223
|
end
|
223
224
|
|
224
225
|
def ext_cell_val(row, col, grid, var_str = 'value')
|
225
|
-
# FOR NETZKE 1.0, use this line for columns
|
226
|
-
# r.get('association_values')['#{col}'] :
|
227
226
|
<<-JS
|
228
227
|
#{ext_var(grid, 'grid')}
|
229
228
|
#{ext_var(ext_col(col, 'grid'), 'col')}
|
230
229
|
#{ext_var(ext_row(row, 'grid'), 'row')}
|
231
230
|
var #{var_str} = col.assoc ?
|
232
|
-
row.get('
|
231
|
+
row.get('association_values')['#{col}'] :
|
233
232
|
row.get('#{col}');
|
234
233
|
JS
|
235
234
|
end
|
@@ -284,33 +283,9 @@ module MartyRSpec::Util
|
|
284
283
|
wait_for_element { !ajax_loading? }
|
285
284
|
end
|
286
285
|
|
287
|
-
# Capybara finders
|
288
286
|
def custom_selectors
|
289
|
-
|
290
|
-
|
291
|
-
".//div[contains(@id, '#{name.camelize(:lower)}')]" }
|
292
|
-
end
|
293
|
-
Capybara.add_selector(:msg) do
|
294
|
-
xpath { "//div[@id='msg-div']" }
|
295
|
-
end
|
296
|
-
Capybara.add_selector(:body) do
|
297
|
-
xpath { ".//div[@data-ref='body']" }
|
298
|
-
end
|
299
|
-
Capybara.add_selector(:input) do
|
300
|
-
xpath { |name| "//input[@name='#{name}']" }
|
301
|
-
end
|
302
|
-
Capybara.add_selector(:status) do
|
303
|
-
xpath { |name| "//div[contains(@id, 'statusbar')]//div[text()='#{name}']" }
|
304
|
-
end
|
305
|
-
Capybara.add_selector(:btn) do
|
306
|
-
xpath { |name| ".//span[text()='#{name}']" }
|
307
|
-
end
|
308
|
-
Capybara.add_selector(:refresh) do
|
309
|
-
xpath { "//img[contains(@class, 'x-tool-refresh')]" }
|
310
|
-
end
|
311
|
-
Capybara.add_selector(:gridcolumn) do
|
312
|
-
xpath { |name| ".//span[contains(@class, 'x-column-header')]" +
|
313
|
-
"//span[text()='#{name}']" }
|
314
|
-
end
|
287
|
+
# DEPRECATED: Selectors are automatically loaded now
|
288
|
+
warn "[DEPRECATED] no longer needed to manually load selectors"
|
315
289
|
end
|
290
|
+
end
|
316
291
|
end
|
data/lib/marty_rspec/version.rb
CHANGED
data/lib/marty_rspec.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Matsuo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description:
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
38
|
- lib/marty_rspec.rb
|
39
|
+
- lib/marty_rspec/custom_matchers.rb
|
39
40
|
- lib/marty_rspec/netzke_grid.rb
|
40
41
|
- lib/marty_rspec/util.rb
|
41
42
|
- lib/marty_rspec/version.rb
|
@@ -51,17 +52,17 @@ require_paths:
|
|
51
52
|
- lib
|
52
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
54
|
requirements:
|
54
|
-
- -
|
55
|
+
- - ">="
|
55
56
|
- !ruby/object:Gem::Version
|
56
57
|
version: '0'
|
57
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
|
-
- -
|
60
|
+
- - ">="
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '0'
|
62
63
|
requirements: []
|
63
64
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.6.
|
65
|
+
rubygems_version: 2.6.2
|
65
66
|
signing_key:
|
66
67
|
specification_version: 4
|
67
68
|
summary: RSpec helper methods for Marty
|