capybara-ng 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 272b3ae336ae30ce0cfc4a0b336f9e59a56d5f77
4
- data.tar.gz: 259f32420faf615fe85b396b9cbe49913849440d
3
+ metadata.gz: d0fd3873f9fff7e7552e5a62b0a16a12cb8e960f
4
+ data.tar.gz: 03011c29b2d399748ca090482395bb0fb47e4820
5
5
  SHA512:
6
- metadata.gz: 7ad84aeb366c9c2f9416fc5d61ba43b870ee7518325b0ec1d6d7c431fed0386fc22078dc211bce90dfcd0df9a9b1ab7afa9bea643352ab6e1c4b71aee660dcdc
7
- data.tar.gz: 7a67b059a94349fa8e033bc337d8a966d9014826c47640cd8fc650a98cd0d44d0be37fb0aa503f88a116b4946087a85b8393fdb3f7081fc250dff13d784bdf8a
6
+ metadata.gz: 42bc6bbfb546dd007a27308146e4bec2e914ae99cb47a167bbfbf3a8bd35c0ca61d0676a68af1d456129eb2e312d21790145ac03b5e8f8ddf43f81b99624c51f
7
+ data.tar.gz: 2154e49664ff9d9a06c616b019383d0e14fff13755d95623f07aa69a6ff638180b57175b1963f6ec376e8c3e18fadb896fdef2c0bcd07da6979af8947606e103
data/.ruby-gemset CHANGED
@@ -1 +1 @@
1
- capybara-angular
1
+ capybara-ng
data/.travis.yml ADDED
@@ -0,0 +1,25 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ sudo: false
5
+ cache: bundler
6
+ # directories:
7
+ # - vendor/bundle
8
+ # - spec/dummy/vendor/bundl
9
+ gemfile: spec/dummy/Gemfile
10
+ branches:
11
+ only:
12
+ - master
13
+
14
+ #before_install:
15
+ # - "export DISPLAY=:99.0"
16
+ # - "sh -e /etc/init.d/xvfb start"
17
+
18
+ # @see https://github.com/travis-ci/travis-ci/issues/938
19
+ before_install:
20
+ - export DISPLAY=:99.0
21
+ - sh -e /etc/init.d/xvfb start
22
+ - curl -Lo chrome.zip https://download-chromium.appspot.com/dl/Linux_x64 && unzip chrome.zip
23
+
24
+ before_script: travis/setup.sh
25
+ script: travis/run.sh
data/README.md CHANGED
@@ -41,6 +41,17 @@ RSpec.configure do |config|
41
41
  end
42
42
  ```
43
43
 
44
+ ## Examples
45
+
46
+ ### Example test cases
47
+
48
+ ````bash
49
+ cd spec/dummy
50
+ bundle
51
+ bundle exec rake rspec
52
+ bundle exec rake cucumber
53
+ ```
54
+
44
55
  ### Experimenting features
45
56
 
46
57
  @see https://github.com/kikonen/sampler/blob/master/dummy/spec/request/test_spec.rb
@@ -1,4 +1,8 @@
1
1
  # bind logic to capybara
2
2
  class Capybara::Session
3
3
  include ::Angular::DSL
4
+
5
+ def ng_session_options
6
+ @ng_session_options ||= {}
7
+ end
4
8
  end
data/lib/angular/dsl.rb CHANGED
@@ -5,10 +5,11 @@ module DSL
5
5
  end
6
6
 
7
7
  def ng_root_selector(root_selector = nil)
8
+ opt = ng.page.ng_session_options
8
9
  if root_selector
9
- @ng_root_selector = root_selector
10
+ opt[:root_selector] = root_selector
10
11
  end
11
- @ng_root_selector || ::Angular.root_selector
12
+ opt[:root_selector] || ::Angular.root_selector
12
13
  end
13
14
 
14
15
  def ng_install
@@ -23,14 +24,14 @@ module DSL
23
24
  # @return current location absolute url
24
25
  #
25
26
  def ng_location_abs(opt = {})
26
- selector = opt.delete(:rootSelector) || ng_root_selector
27
+ selector = opt.delete(:root_selector) || ng_root_selector
27
28
  ng.make_call :getLocationAbsUrl, [selector], opt
28
29
  end
29
30
 
30
31
  # @return current location absolute url
31
32
  #
32
33
  def ng_location(opt = {})
33
- selector = opt.delete(:rootSelector) || ng_root_selector
34
+ selector = opt.delete(:root_selector) || ng_root_selector
34
35
  ng.make_call :getLocation, [selector], opt
35
36
  end
36
37
 
@@ -38,18 +39,18 @@ module DSL
38
39
  # @return current location
39
40
  #
40
41
  def ng_set_location(url, opt = {})
41
- selector = opt.delete(:rootSelector) || ng_root_selector
42
+ selector = opt.delete(:root_selector) || ng_root_selector
42
43
  ng.make_call :setLocation, [selector, url], opt
43
44
  end
44
45
 
45
46
  #
46
47
  # @param opt
47
- # - :rootSelector
48
+ # - :root_selector
48
49
  # - :wait
49
50
  # @return eval result
50
51
  #
51
52
  def ng_eval(expr, opt = {})
52
- selector = opt.delete(:rootSelector) || ng_root_selector
53
+ selector = opt.delete(:root_selector) || ng_root_selector
53
54
  ng.make_call :evaluate, [selector, expr], opt
54
55
  end
55
56
 
@@ -59,7 +60,7 @@ module DSL
59
60
  # @param opt
60
61
  # - :exact
61
62
  # - :using
62
- # - :rootSelector
63
+ # - :root_selector
63
64
  # - :wait
64
65
  # @return true | false
65
66
  #
@@ -77,11 +78,12 @@ module DSL
77
78
  # - :row
78
79
  # - :exact
79
80
  # - :using
80
- # - :rootSelector
81
+ # - :root_selector
81
82
  # - :wait
82
83
  # @return nth node
83
84
  #
84
85
  def ng_binding(binding, opt = {})
86
+ opt[:root_selector] ||= ng_root_selector
85
87
  row = ng.row(opt)
86
88
  ng_bindings(binding, opt)[row]
87
89
  end
@@ -92,12 +94,13 @@ module DSL
92
94
  # @param opt
93
95
  # - :exact
94
96
  # - :using
95
- # - :rootSelector
97
+ # - :root_selector
96
98
  # - :wait
97
99
  # @return [node, ...]
98
100
  #
99
101
  def ng_bindings(binding, opt = {})
100
- ng.get_nodes :findBindings, [binding, opt[:exact]], opt
102
+ opt[:root_selector] ||= ng_root_selector
103
+ ng.get_nodes :findBindings, [binding, opt[:exact] == true], opt
101
104
  end
102
105
 
103
106
  #
@@ -105,7 +108,7 @@ module DSL
105
108
  #
106
109
  # @param opt
107
110
  # - :using
108
- # - :rootSelector
111
+ # - :root_selector
109
112
  # - :wait
110
113
  # @return true | false
111
114
  #
@@ -122,11 +125,12 @@ module DSL
122
125
  # @param opt
123
126
  # - :row
124
127
  # - :using
125
- # - :rootSelector
128
+ # - :root_selector
126
129
  # - :wait
127
130
  # @return nth node
128
131
  #
129
132
  def ng_model(model, opt = {})
133
+ opt[:root_selector] ||= ng_root_selector
130
134
  row = ng.row(opt)
131
135
  ng_models(model, opt)[row]
132
136
  end
@@ -136,11 +140,12 @@ module DSL
136
140
  #
137
141
  # @param opt
138
142
  # - :using
139
- # - :rootSelector
143
+ # - :root_selector
140
144
  # - :wait
141
145
  # @return [node, ...]
142
146
  #
143
147
  def ng_models(model, opt = {})
148
+ opt[:root_selector] ||= ng_root_selector
144
149
  ng.get_nodes :findByModel, [model], opt
145
150
  end
146
151
 
@@ -149,11 +154,12 @@ module DSL
149
154
  #
150
155
  # @param opt
151
156
  # - :using
152
- # - :rootSelector
157
+ # - :root_selector
153
158
  # - :wait
154
159
  # @return true | false
155
160
  #
156
161
  def has_ng_option?(options, opt = {})
162
+ opt[:root_selector] ||= ng_root_selector
157
163
  ng_options(options, opt)
158
164
  true
159
165
  rescue NotFound
@@ -166,11 +172,12 @@ module DSL
166
172
  # @param opt
167
173
  # - :row
168
174
  # - :using
169
- # - :rootSelector
175
+ # - :root_selector
170
176
  # - :wait
171
177
  # @return nth node
172
178
  #
173
179
  def ng_option(options, opt = {})
180
+ opt[:root_selector] ||= ng_root_selector
174
181
  row = ng.row(opt)
175
182
  ng_options(options, opt)[row]
176
183
  end
@@ -180,11 +187,12 @@ module DSL
180
187
  #
181
188
  # @param opt
182
189
  # - :using
183
- # - :rootSelector
190
+ # - :root_selector
184
191
  # - :wait
185
192
  # @return [node, ...]
186
193
  #
187
194
  def ng_options(options, opt = {})
195
+ opt[:root_selector] ||= ng_root_selector
188
196
  ng.get_nodes :findByOptions, [options], opt
189
197
  end
190
198
 
@@ -193,11 +201,12 @@ module DSL
193
201
  #
194
202
  # @param opt
195
203
  # - :using
196
- # - :rootSelector
204
+ # - :root_selector
197
205
  # - :wait
198
206
  # @return true | false
199
207
  #
200
208
  def has_ng_repeater_row?(repeater, opt = {})
209
+ opt[:root_selector] ||= ng_root_selector
201
210
  ng.get_nodes(:findRepeaterRows, [repeater, 0], opt)
202
211
  true
203
212
  rescue NotFound
@@ -210,11 +219,12 @@ module DSL
210
219
  # @param opt
211
220
  # - :row
212
221
  # - :using
213
- # - :rootSelector
222
+ # - :root_selector
214
223
  # - :wait
215
224
  # @return nth node
216
225
  #
217
226
  def ng_repeater_row(repeater, opt = {})
227
+ opt[:root_selector] ||= ng_root_selector
218
228
  row = ng.row(opt)
219
229
  data = ng.get_nodes(:findRepeaterRows, [repeater, row], opt)
220
230
  data.first
@@ -225,11 +235,12 @@ module DSL
225
235
  #
226
236
  # @param opt
227
237
  # - :using
228
- # - :rootSelector
238
+ # - :root_selector
229
239
  # - :wait
230
240
  # @return [node, ...]
231
241
  #
232
242
  def ng_repeater_rows(repeater, opt = {})
243
+ opt[:root_selector] ||= ng_root_selector
233
244
  ng.get_nodes :findAllRepeaterRows, [repeater], opt
234
245
  end
235
246
 
@@ -239,11 +250,12 @@ module DSL
239
250
  # @param opt
240
251
  # - :row
241
252
  # - :using
242
- # - :rootSelector
253
+ # - :root_selector
243
254
  # - :wait
244
255
  # @return nth node
245
256
  #
246
257
  def ng_repeater_column(repeater, binding, opt = {})
258
+ opt[:root_selector] ||= ng_root_selector
247
259
  row = ng.row(opt)
248
260
  ng_repeater_columns(repeater, binding, opt)[row]
249
261
  end
@@ -253,11 +265,12 @@ module DSL
253
265
  #
254
266
  # @param opt
255
267
  # - :using
256
- # - :rootSelector
268
+ # - :root_selector
257
269
  # - :wait
258
270
  # @return [node, ...]
259
271
  #
260
272
  def ng_repeater_columns(repeater, binding, opt = {})
273
+ opt[:root_selector] ||= ng_root_selector
261
274
  ng.get_nodes :findRepeaterColumn, [repeater, binding], opt
262
275
  end
263
276
 
@@ -265,11 +278,12 @@ module DSL
265
278
  # @param opt
266
279
  # - :row
267
280
  # - :using
268
- # - :rootSelector
281
+ # - :root_selector
269
282
  # - :wait
270
283
  # @return nth node
271
284
  #
272
285
  def ng_repeater_element(repeater, index, binding, opt = {})
286
+ opt[:root_selector] ||= ng_root_selector
273
287
  row = ng.row(opt)
274
288
  ng_repeater_elements(repeater, index, binding, opt)[row]
275
289
  end
@@ -277,11 +291,12 @@ module DSL
277
291
  #
278
292
  # @param opt
279
293
  # - :using
280
- # - :rootSelector
294
+ # - :root_selector
281
295
  # - :wait
282
296
  # @return [node, ...]
283
297
  #
284
298
  def ng_repeater_elements(repeater, index, binding, opt = {})
299
+ opt[:root_selector] ||= ng_root_selector
285
300
  ng.get_nodes :findRepeaterElement, [repeater, index, binding], opt
286
301
  end
287
302
  end
data/lib/angular/setup.rb CHANGED
@@ -20,14 +20,14 @@ module Angular
20
20
  #
21
21
  # @param opt
22
22
  # - :using
23
- # - :rootSelector
23
+ # - :root_selector
24
24
  # - :wait
25
25
  #
26
26
  def get_nodes(method, params, opt = {})
27
27
  opt = {
28
28
  nodes: true,
29
29
  using: nil,
30
- rootSelector: ::Angular.root_selector,
30
+ root_selector: ::Angular.root_selector,
31
31
  }.merge(opt)
32
32
  make_call(method, params, opt)
33
33
  end
@@ -46,7 +46,7 @@ module Angular
46
46
  ng_wait if opt[:wait]
47
47
 
48
48
  params << opt[:using] if opt.has_key?(:using)
49
- params << opt[:rootSelector] if opt.has_key?(:rootSelector)
49
+ params << opt[:root_selector] if opt.has_key?(:root_selector)
50
50
  js_params = params.map do |p|
51
51
  if p.nil?
52
52
  'null'
@@ -77,6 +77,10 @@ module Angular
77
77
  raise NotFound.new("#{method}: #{params.inspect}")
78
78
  end
79
79
 
80
+ if js_result.is_a? String
81
+ raise js_result
82
+ end
83
+
80
84
  js_result.map do |el|
81
85
  el ? Capybara::Selenium::Node.new(page.driver, el) : nil
82
86
  end
@@ -1,3 +1,3 @@
1
1
  module Angular
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
data/travis/run.sh ADDED
@@ -0,0 +1,13 @@
1
+ cd spec/dummy
2
+ export BUNDLE_GEMFILE=$PWD/Gemfile
3
+
4
+ xvfb-run -a bundle exec cucumber
5
+ EXIT_1=$?
6
+
7
+ xvfb-run -a bundle exec rspec
8
+ EXIT_2=$?
9
+
10
+ if [[ $EXIT_1 != 0 || $EXIT_2 != 0 ]]; then
11
+ echo "Failed"
12
+ exit 1
13
+ fi
data/travis/setup.sh ADDED
@@ -0,0 +1,3 @@
1
+ #cd spec/dummy
2
+ #export BUNDLE_GEMFILE=$PWD/Gemfile
3
+ #bundle install
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,6 +62,7 @@ files:
62
62
  - ".gitignore"
63
63
  - ".ruby-gemset"
64
64
  - ".ruby-version"
65
+ - ".travis.yml"
65
66
  - Gemfile
66
67
  - LICENSE.txt
67
68
  - README.md
@@ -78,6 +79,8 @@ files:
78
79
  - lib/angular/version.rb
79
80
  - lib/angular/waiter.rb
80
81
  - lib/capybara-ng.rb
82
+ - travis/run.sh
83
+ - travis/setup.sh
81
84
  homepage: https://github.com/kikonen/capybara-ng
82
85
  licenses:
83
86
  - MIT