calabash-cucumber 0.9.74 → 0.9.80.pre.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,9 @@
1
- YnBsaXN0MDCiARDVAgQKDA4DBQsND1REYXRhTxA8AQAAAAEAAQAAAAAAAAAAAAAA
2
- AAAAAAAAAAAAAAAAAAAAAQAABQIDAAAAAACgR+FAAECTQwDA50MAAAAAoFhMb2Nh
3
- dGlvbtIGCAcJUVgiQ5NAAFFZIkPnwABUVGltZRMAAE1aiOi6tFRUeXBlEQu5Xldp
4
- bmRvd0xvY2F0aW9u0gYIBwnVAgQKDA4REhUNFk8QPAYAAAABAAAAAAAAAAAAAAAA
5
- AAAAAAAAAAAAAAAAAAAAAAEAAAUCAAAAAAAAAAAAAADAkkMAQOVDAAAAAKDSBggT
6
- FCJDksAAIkPlQAATAABNWpkSZoXSBggTFAAIAAsAFgAbAFsAZABpAGsAcAByAHcA
7
- fACFAIoAjQCcAKEArADsAPEA9gD7AQQAAAAAAAACAQAAAAAAAAAXAAAAAAAAAAAA
8
- AAAAAAABCQ==
1
+ YnBsaXN0MDCiARLVAgMEBQYHCAkOEVRUaW1lVERhdGFeV2luZG93TG9jYXRpb25Y
2
+ TG9jYXRpb25UVHlwZRMAACs09fZLc08QPAEAAAABAAEAAAAAAAAAAAAAAAAAAAAA
3
+ AAAAAAAAAAAAAAEzRAICAgAAAIA/AACAPwAA6EEAAK5DAdE4ANIKCwwNUVhRWSNA
4
+ PQAAAAAAACNAdcAAAAAAANIKCw8QI0A9AAAAAAAAI0B1wAAAAAAAEQu51QIDBAUG
5
+ ExQVGBETAAArNPhGKp9PEDwGAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
6
+ AAABCJECAgEAAACAPwAAgD8AAOhBAACuQwEAekPSCgsWFyNAPQAAAAAAACNAdcAA
7
+ AAAAANIKCxkaI0A9AAAAAAAAI0B1wAAAAAAAAAgACwAWABsAIAAvADgAPQBGAIUA
8
+ igCMAI4AlwCgAKUArgC3ALoAxQDOA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AKUArgC3ALoAxQDOAQ0BEgEbASQBKQEyAAAAAAAAAgEAAAAAAAAA
9
+ GwAAAAAAAAAAAAAAAAAAATs=
@@ -0,0 +1,59 @@
1
+ require 'calabash-cucumber/core'
2
+
3
+ module Calabash
4
+ module Cucumber
5
+ module TestsHelpers
6
+ include Calabash::Cucumber::Core
7
+
8
+ def element_does_not_exist(uiquery)
9
+ query(uiquery).empty?
10
+ end
11
+
12
+ def element_exists(uiquery)
13
+ not element_does_not_exist(uiquery)
14
+ end
15
+
16
+ def view_with_mark_exists(expected_mark)
17
+ element_exists("view marked:'#{expected_mark}'")
18
+ end
19
+
20
+ def check_element_exists(query)
21
+ if not element_exists(query)
22
+ screenshot_and_raise "No element found for query: #{query}"
23
+ end
24
+ end
25
+
26
+ def check_element_does_not_exist(query)
27
+ if element_exists(query)
28
+ screenshot_and_raise "Expected no elements to match query: #{query}"
29
+ end
30
+ end
31
+
32
+ def check_view_with_mark_exists(expected_mark)
33
+ check_element_exists("view marked:'#{expected_mark}'")
34
+ end
35
+
36
+ def screenshot_and_raise(msg, prefix=nil, name=nil)
37
+ screenshot(prefix, name)
38
+ raise(msg)
39
+ end
40
+
41
+ def fail(msg="Error. Check log for details.", prefix=nil, name=nil)
42
+ screenshot_and_raise(msg, prefix, name)
43
+ end
44
+
45
+ def screenshot(prefix=nil, name=nil)
46
+ res = http({:method => :get, :path => 'screenshot'})
47
+ prefix = prefix || ENV['SCREENSHOT_PATH'] || ""
48
+ name = "screenshot_#{CALABASH_COUNT[:step_line]}.png" if name.nil?
49
+ path = "#{prefix}#{name}"
50
+ File.open(path, 'wb') do |f|
51
+ f.write res
52
+ end
53
+ puts "Saved screenshot: #{path}"
54
+ path
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = "0.9.74"
4
- FRAMEWORK_VERSION = "0.9.74"
3
+ VERSION = "0.9.80.pre.1"
4
+ FRAMEWORK_VERSION = "0.9.80.pre.1"
5
5
  end
6
6
  end
@@ -0,0 +1,114 @@
1
+ require 'calabash-cucumber/core'
2
+ require 'calabash-cucumber/tests_helpers'
3
+
4
+ module Calabash
5
+ module Cucumber
6
+ module WaitHelpers
7
+ include Calabash::Cucumber::Core
8
+ include Calabash::Cucumber::TestsHelpers
9
+
10
+ CALABASH_CONDITIONS = {:none_animating => "NONE_ANIMATING"}
11
+
12
+
13
+ def wait_for(options_or_timeout=
14
+ {:timeout => 10,
15
+ :retry_frequency => 0.2,
16
+ :post_timeout => 0.1,
17
+ :timeout_message => "Timed out waiting...",
18
+ :screenshot_on_error => true}, &block)
19
+ #note Hash is preferred, number acceptable for backwards compat
20
+ timeout=options_or_timeout
21
+ post_timeout=0.1
22
+ retry_frequency=0.2
23
+ timeout_message = nil
24
+ screenshot_on_error = true
25
+
26
+ if options_or_timeout.is_a?(Hash)
27
+ timeout = options_or_timeout[:timeout] || 10
28
+ retry_frequency = options_or_timeout[:retry_frequency] || 0.2
29
+ post_timeout = options_or_timeout[:post_timeout] || 0.1
30
+ timeout_message = options_or_timeout[:timeout_message]
31
+ screenshot_on_error = options_or_timeout[:screenshot_on_error] || true
32
+ end
33
+
34
+ begin
35
+ Timeout::timeout(timeout) do
36
+ until block.call
37
+ sleep(retry_frequency)
38
+ end
39
+ end
40
+ sleep(post_timeout) if post_timeout > 0
41
+ rescue Timeout::Error => e
42
+ handle_error_with_options(e,timeout_message, screenshot_on_error)
43
+ rescue Exception => e
44
+ handle_error_with_options(e, nil, screenshot_on_error)
45
+ end
46
+ end
47
+
48
+ #options for wait_for apply
49
+ def wait_for_elements_exist(elements_arr, options={})
50
+ options[:timeout_message] = options[:timeout_message] || "Timeout waiting for elements: #{elements_arr.join(",")}"
51
+ wait_for(options) do
52
+ elements_arr.all? { |q| element_exists(q) }
53
+ end
54
+ end
55
+
56
+ def wait_for_condition(options = {})
57
+ options[:timeout] = options[:timeout] || 10
58
+ options[:query] = options[:query] || "view"
59
+ options[:condition] = options[:condition] || CALABASH_CONDITIONS[:none_animating]
60
+ options[:post_timeout] = options[:post_timeout] || 0.1
61
+ options[:frequency] = options[:frequency] || 0.2
62
+ options[:retry_frequency] = options[:retry_frequency] || 0.2
63
+ options[:count] = options[:count] || 2
64
+ options[:timeout_message] = options[:timeout_message] || "Timeout waiting for condition (#{options[:condition]})"
65
+ options[:screenshot_on_error] = options[:screenshot_on_error] || true
66
+
67
+ begin
68
+ Timeout::timeout(options[:timeout]) do
69
+ loop do
70
+ res = http({:method => :post, :path => 'condition'},
71
+ options)
72
+ res = JSON.parse(res)
73
+ break if res['outcome'] == 'SUCCESS'
74
+ sleep(options[:retry_frequency]) if options[:retry_frequency] > 0
75
+ end
76
+ sleep(options[:post_timeout]) if options[:post_timeout] > 0
77
+ end
78
+ rescue Timeout::Error => e
79
+ handle_error_with_options(e,options[:timeout_message], options[:screenshot_on_error])
80
+ rescue Exception => e
81
+ handle_error_with_options(e,nil, options[:screenshot_on_error])
82
+ end
83
+ end
84
+
85
+ def wait_for_none_animating(options = {})
86
+ options[:condition] = CALABASH_CONDITIONS[:none_animating]
87
+ wait_for_condition(options)
88
+ end
89
+
90
+ #may be called with a string (query) or an array of strings
91
+ def wait_for_transition(done_queries, check_options={},animation_options={})
92
+ done_queries = [*done_queries]
93
+ wait_for_elements_exist(done_queries,check_options)
94
+ wait_for_none_animating(animation_options)
95
+ end
96
+
97
+ def touch_transition(touch_q, done_queries,check_options={},animation_options={})
98
+ touch(touch_q)
99
+ wait_for_transition(done_queries,check_options,animation_options)
100
+ end
101
+
102
+ def handle_error_with_options(ex, timeout_message, screenshot_on_error)
103
+ msg = (timeout_message || ex)
104
+ if screenshot_on_error
105
+ screenshot_and_raise msg
106
+ else
107
+ raise msg
108
+ end
109
+ end
110
+
111
+
112
+ end
113
+ end
114
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.74
5
- prerelease:
4
+ version: 0.9.80.pre.1
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Karl Krukow
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2012-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
@@ -91,22 +91,6 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: net-http-persistent
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
94
  description: calabash-cucumber drives tests for native iOS apps. You must link your
111
95
  app with calabash-ios-server framework to execute tests.
112
96
  email:
@@ -145,8 +129,9 @@ files:
145
129
  - features/step_definitions/calabash_steps.rb
146
130
  - lib/calabash-cucumber.rb
147
131
  - lib/calabash-cucumber/calabash_steps.rb
148
- - lib/calabash-cucumber/color_helper.rb
132
+ - lib/calabash-cucumber/core.rb
149
133
  - lib/calabash-cucumber/cucumber.rb
134
+ - lib/calabash-cucumber/keyboard_helpers.rb
150
135
  - lib/calabash-cucumber/launch/simulator_helper.rb
151
136
  - lib/calabash-cucumber/operations.rb
152
137
  - lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64
@@ -215,7 +200,9 @@ files:
215
200
  - lib/calabash-cucumber/resources/touch_ios4_iphone.base64
216
201
  - lib/calabash-cucumber/resources/touch_ios5_ipad.base64
217
202
  - lib/calabash-cucumber/resources/touch_ios5_iphone.base64
203
+ - lib/calabash-cucumber/tests_helpers.rb
218
204
  - lib/calabash-cucumber/version.rb
205
+ - lib/calabash-cucumber/wait_helpers.rb
219
206
  - scripts/data/.GlobalPreferences.plist
220
207
  - scripts/data/com.apple.Accessibility.plist
221
208
  - scripts/reset_simulator.scpt
@@ -234,9 +221,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
221
  required_rubygems_version: !ruby/object:Gem::Requirement
235
222
  none: false
236
223
  requirements:
237
- - - ! '>='
224
+ - - ! '>'
238
225
  - !ruby/object:Gem::Version
239
- version: '0'
226
+ version: 1.3.1
240
227
  requirements: []
241
228
  rubyforge_project:
242
229
  rubygems_version: 1.8.23
@@ -1,13 +0,0 @@
1
- module Calabash module Cucumber
2
-
3
- module ColorHelper
4
- def colorize(text, color_code)
5
- "\e[#{color_code}m#{text}\e[0m"
6
- end
7
-
8
- def red(text); colorize(text, 31); end
9
- def green(text); colorize(text, 32); end
10
- def blue(text); colorize(text, 34); end
11
- end
12
-
13
- end end