calabash-cucumber 0.9.124 → 0.9.125
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/calabash-cucumber/core.rb +78 -39
- data/lib/calabash-cucumber/version.rb +2 -2
- metadata +2 -2
@@ -6,6 +6,8 @@ module Calabash
|
|
6
6
|
module Core
|
7
7
|
|
8
8
|
DATA_PATH = File.expand_path(File.dirname(__FILE__))
|
9
|
+
CAL_HTTP_RETRY_COUNT=3
|
10
|
+
RETRYABLE_ERRORS = [Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ETIMEDOUT]
|
9
11
|
|
10
12
|
def macro(txt)
|
11
13
|
if self.respond_to? :step
|
@@ -267,7 +269,30 @@ module Calabash
|
|
267
269
|
texts
|
268
270
|
end
|
269
271
|
|
270
|
-
def
|
272
|
+
def recording_name_for(recording_name, os, device)
|
273
|
+
if !recording_name.end_with? ".base64"
|
274
|
+
"#{recording_name}_#{os}_#{device}.base64"
|
275
|
+
else
|
276
|
+
recording_name
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
def load_recording(recording,rec_dir)
|
282
|
+
data = nil
|
283
|
+
if (File.exists?(recording))
|
284
|
+
data = File.read(recording)
|
285
|
+
elsif (File.exists?("features/#{recording}"))
|
286
|
+
data = File.read("features/#{recording}")
|
287
|
+
elsif (File.exists?("#{rec_dir}/#{recording}"))
|
288
|
+
data = File.read("#{rec_dir}/#{recording}")
|
289
|
+
elsif (File.exists?("#{DATA_PATH}/resources/#{recording}"))
|
290
|
+
data = File.read("#{DATA_PATH}/resources/#{recording}")
|
291
|
+
end
|
292
|
+
data
|
293
|
+
end
|
294
|
+
|
295
|
+
def load_playback_data(recording_name, options={})
|
271
296
|
os = options["OS"] || ENV["OS"]
|
272
297
|
device = options["DEVICE"] || ENV["DEVICE"] || "iphone"
|
273
298
|
|
@@ -288,30 +313,20 @@ EOF
|
|
288
313
|
end
|
289
314
|
|
290
315
|
rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/playback"
|
291
|
-
|
292
|
-
|
316
|
+
|
317
|
+
recording = recording_name_for(recording_name, os, device)
|
318
|
+
data = load_recording(recording,rec_dir)
|
319
|
+
|
320
|
+
if data.nil? and os=="ios6"
|
321
|
+
recording = recording_name_for(recording_name, "ios5", device)
|
293
322
|
end
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
elsif (File.exists?("#{rec_dir}/#{recording}"))
|
300
|
-
data = File.read("#{rec_dir}/#{recording}")
|
301
|
-
elsif (File.exists?("#{DATA_PATH}/resources/#{recording}"))
|
302
|
-
data = File.read("#{DATA_PATH}/resources/#{recording}")
|
303
|
-
else
|
304
|
-
if os=="ios6"
|
305
|
-
recording = recording.gsub("ios6","ios5")
|
306
|
-
if (File.exists?("#{DATA_PATH}/resources/#{recording}"))
|
307
|
-
data = File.read("#{DATA_PATH}/resources/#{recording}")
|
308
|
-
else
|
309
|
-
screenshot_and_raise "Playback not found: #{recording} (searched for #{recording} in #{Dir.pwd}, #{rec_dir}, #{DATA_PATH}/resources"
|
310
|
-
end
|
311
|
-
else
|
312
|
-
screenshot_and_raise "Playback not found: #{recording} (searched for #{recording} in #{Dir.pwd}, #{rec_dir}, #{DATA_PATH}/resources"
|
313
|
-
end
|
323
|
+
|
324
|
+
data = load_recording(recording,rec_dir)
|
325
|
+
|
326
|
+
if data.nil?
|
327
|
+
screenshot_and_raise "Playback not found: #{recording} (searched for #{recording} in #{Dir.pwd}, #{rec_dir}, #{DATA_PATH}/resources"
|
314
328
|
end
|
329
|
+
|
315
330
|
data
|
316
331
|
end
|
317
332
|
|
@@ -362,8 +377,25 @@ EOF
|
|
362
377
|
File.open("_recording.plist", 'wb') do |f|
|
363
378
|
f.write res
|
364
379
|
end
|
380
|
+
|
365
381
|
device = ENV['DEVICE'] || 'iphone'
|
366
|
-
os = ENV['OS']
|
382
|
+
os = ENV['OS']
|
383
|
+
|
384
|
+
unless os
|
385
|
+
major = Calabash::Cucumber::SimulatorHelper.ios_major_version
|
386
|
+
unless major
|
387
|
+
raise <<EOF
|
388
|
+
Unable to determine iOS major version
|
389
|
+
Most likely you have updated your calabash-cucumber client
|
390
|
+
but not your server. Please follow closely:
|
391
|
+
|
392
|
+
https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version
|
393
|
+
|
394
|
+
If you are running version 0.9.120+ then please report this message as a bug.
|
395
|
+
EOF
|
396
|
+
end
|
397
|
+
os = "ios#{major}"
|
398
|
+
end
|
367
399
|
|
368
400
|
file_name = "#{file_name}_#{os}_#{device}.base64"
|
369
401
|
system("/usr/bin/plutil -convert binary1 -o _recording_binary.plist _recording.plist")
|
@@ -385,6 +417,15 @@ EOF
|
|
385
417
|
res['result']
|
386
418
|
end
|
387
419
|
|
420
|
+
def calabash_exit
|
421
|
+
# Exiting the app shuts down the HTTP connection and generates ECONNREFUSED,
|
422
|
+
# which needs to be suppressed.
|
423
|
+
begin
|
424
|
+
http(:path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED])
|
425
|
+
rescue Errno::ECONNREFUSED
|
426
|
+
[]
|
427
|
+
end
|
428
|
+
end
|
388
429
|
|
389
430
|
def map(query, method_name, *method_args)
|
390
431
|
operation_map = {
|
@@ -429,10 +470,9 @@ EOF
|
|
429
470
|
url
|
430
471
|
end
|
431
472
|
|
432
|
-
CAL_HTTP_RETRY_COUNT=3
|
433
|
-
|
434
473
|
def make_http_request(options)
|
435
474
|
body = nil
|
475
|
+
retryable_errors = options[:retryable_errors] || RETRYABLE_ERRORS
|
436
476
|
CAL_HTTP_RETRY_COUNT.times do |count|
|
437
477
|
begin
|
438
478
|
if not @http
|
@@ -457,21 +497,20 @@ EOF
|
|
457
497
|
raise e
|
458
498
|
end
|
459
499
|
rescue Exception => e
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
else
|
470
|
-
puts "Failing... #{e.class}"
|
471
|
-
raise e
|
472
|
-
end
|
500
|
+
if retryable_errors.include?(e)
|
501
|
+
if count < CAL_HTTP_RETRY_COUNT-1
|
502
|
+
sleep(0.5)
|
503
|
+
@http.reset_all
|
504
|
+
@http=nil
|
505
|
+
STDOUT.write "Retrying.. #{e.class}: (#{e})\n"
|
506
|
+
STDOUT.flush
|
507
|
+
|
473
508
|
else
|
509
|
+
puts "Failing... #{e.class}"
|
474
510
|
raise e
|
511
|
+
end
|
512
|
+
else
|
513
|
+
raise e
|
475
514
|
end
|
476
515
|
end
|
477
516
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calabash-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.125
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|