frank-cucumber 0.7.8 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,62 +1,4 @@
1
1
  Given /^I launch the app$/ do
2
-
3
-
4
2
  app_path = ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
5
-
6
- ####################
7
- # once you're setting APP_BUNDLE_PATH correctly you can get rid
8
- # of this detection/reporting code if you want
9
- #
10
- if app_path.nil?
11
- require 'frank-cucumber/app_bundle_locator'
12
- message = "APP_BUNDLE_PATH is not set. \n\nPlease set APP_BUNDLE_PATH (either an environment variable, or the ruby constant in support/env.rb) to the path of your Frankified target's iOS app bundle."
13
- possible_app_bundles = Frank::Cucumber::AppBundleLocator.new.guess_possible_app_bundles_for_dir( Dir.pwd )
14
- if possible_app_bundles && !possible_app_bundles.empty?
15
- message << "\n\nBased on your current directory, you probably want to use one of the following paths for your APP_BUNDLE_PATH:\n"
16
- message << possible_app_bundles.join("\n")
17
- end
18
-
19
- raise "\n\n"+("="*80)+"\n"+message+"\n"+("="*80)+"\n\n"
20
- end
21
- #
22
- ####################
23
-
24
-
25
-
26
- # kill the app if it's already running, just in case this helps
27
- # reduce simulator flakiness when relaunching the app. Use a timeout of 5 seconds to
28
- # prevent us hanging around for ages waiting for the ping to fail if the app isn't running
29
- begin
30
- Timeout::timeout(5) { press_home_on_simulator if frankly_ping }
31
- rescue Timeout::Error
32
- end
33
-
34
-
35
- require 'sim_launcher'
36
-
37
- if( ENV['USE_SIM_LAUNCHER_SERVER'] )
38
- simulator = SimLauncher::Client.for_iphone_app( app_path )
39
- else
40
- simulator = SimLauncher::DirectClient.for_iphone_app( app_path )
41
- end
42
-
43
- num_timeouts = 0
44
- loop do
45
- begin
46
- simulator.relaunch
47
- wait_for_frank_to_come_up
48
- break # if we make it this far without an exception then we're good to move on
49
-
50
- rescue Timeout::Error
51
- num_timeouts += 1
52
- puts "Encountered #{num_timeouts} timeouts while launching the app."
53
- if num_timeouts > 3
54
- raise "Encountered #{num_timeouts} timeouts in a row while trying to launch the app."
55
- end
56
- end
57
- end
58
-
59
- # TODO: do some kind of waiting check to see that your initial app UI is ready
60
- # e.g. Then "I wait to see the login screen"
61
-
3
+ launch_app app_path
62
4
  end
@@ -1,8 +1,10 @@
1
1
  require 'frank-cucumber/color_helper'
2
2
  require 'frank-cucumber/frank_helper'
3
+ require 'frank-cucumber/launcher'
3
4
 
4
5
  World(Frank::Cucumber::ColorHelper)
5
6
  World(Frank::Cucumber::FrankHelper)
7
+ World(Frank::Cucumber::Launcher)
6
8
 
7
9
  AfterConfiguration do
8
10
  require 'frank-cucumber/core_frank_steps'
@@ -121,12 +121,12 @@ end
121
121
 
122
122
  # alias
123
123
  When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |text_field, text_to_type|
124
- When %Q|I type "#{text_to_type}" into the "#{text_field}" text field|
124
+ step %Q|I type "#{text_to_type}" into the "#{text_field}" text field|
125
125
  end
126
126
 
127
127
  When /^I fill in text fields as follows:$/ do |table|
128
128
  table.hashes.each do |row|
129
- When %Q|I type "#{row['text']}" into the "#{row['field']}" text field|
129
+ step %Q|I type "#{row['text']}" into the "#{row['field']}" text field|
130
130
  end
131
131
  end
132
132
 
@@ -239,6 +239,7 @@ When /^I flip switch "([^\"]*)"$/ do |mark|
239
239
  touch("view:'UISwitch' marked:'#{mark}'")
240
240
  end
241
241
 
242
+
242
243
  Then /^switch "([^\"]*)" should be (on|off)$/ do |mark,expected_state|
243
244
  expected_state = expected_state == 'on'
244
245
 
@@ -5,6 +5,14 @@ module Frank module Cucumber
5
5
 
6
6
  module FrankHelper
7
7
 
8
+ class << self
9
+ # TODO: adding an ivar to the module itself is a big ugyl hack. We need a FrankDriver class, or similar
10
+ attr_accessor :selector_engine
11
+ def use_shelley_from_now_on
12
+ @selector_engine = 'shelley_compat'
13
+ end
14
+ end
15
+
8
16
  def touch( uiquery )
9
17
  views_touched = frankly_map( uiquery, 'touch' )
10
18
  raise "could not find anything matching [#{uiquery}] to touch" if views_touched.empty?
@@ -50,6 +58,7 @@ module FrankHelper
50
58
 
51
59
  before = Time.now
52
60
  res = post_to_uispec_server( 'app_exec', :operation => operation_map )
61
+
53
62
  #logger.debug( "MAP applying #{method_name} with args:( #{method_args.inspect} ) to 'Application Delegate' took #{Time.now - before} seconds" )
54
63
 
55
64
  res = JSON.parse( res )
@@ -64,9 +73,10 @@ module FrankHelper
64
73
  def frankly_map( query, method_name, *method_args )
65
74
  operation_map = {
66
75
  :method_name => method_name,
67
- :arguments => method_args
76
+ :arguments => method_args,
68
77
  }
69
- res = post_to_uispec_server( 'map', :query => query, :operation => operation_map )
78
+ selector_engine = Frank::Cucumber::FrankHelper.selector_engine || 'uiquery' # default to UIQuery for backwards compatibility
79
+ res = post_to_uispec_server( 'map', :query => query, :operation => operation_map, :selector_engine => selector_engine )
70
80
  res = JSON.parse( res )
71
81
  if res['outcome'] != 'SUCCESS'
72
82
  raise "frankly_map #{query} #{method_name} failed because: #{res['reason']}\n#{res['details']}"
@@ -109,18 +119,28 @@ module FrankHelper
109
119
  if frankly_ping
110
120
  num_consec_failures = 0
111
121
  num_consec_successes += 1
112
- print (num_consec_successes == 1 ) ? "\n" : "\r"
113
- print "FRANK!".slice(0,num_consec_successes)
114
122
  else
115
123
  num_consec_successes = 0
116
124
  num_consec_failures += 1
117
- print (num_consec_failures == 1 ) ? "\n" : "\r"
118
- print "PING FAILED" + "!"*num_consec_failures
125
+ if num_consec_failures >= 5 # don't show small timing errors
126
+ print (num_consec_failures == 5 ) ? "\n" : "\r"
127
+ print "PING FAILED" + "!"*num_consec_failures
128
+ end
119
129
  end
120
130
  STDOUT.flush
121
131
  sleep 0.2
122
132
  end
123
- puts ''
133
+
134
+ if num_consec_successes < 6
135
+ print (num_consec_successes == 1 ) ? "\n" : "\r"
136
+ print "FRANK!".slice(0,num_consec_successes)
137
+ STDOUT.flush
138
+ puts ''
139
+ end
140
+
141
+ if num_consec_failures >= 5
142
+ puts ''
143
+ end
124
144
  end
125
145
 
126
146
  unless frankly_is_accessibility_enabled
@@ -0,0 +1,54 @@
1
+ module Frank module Cucumber
2
+
3
+ module Launcher
4
+
5
+ def launch_app(app_path)
6
+ if app_path.nil?
7
+ require 'frank-cucumber/app_bundle_locator'
8
+ message = "APP_BUNDLE_PATH is not set. \n\nPlease set APP_BUNDLE_PATH (either an environment variable, or the ruby constant in support/env.rb) to the path of your Frankified target's iOS app bundle."
9
+ possible_app_bundles = Frank::Cucumber::AppBundleLocator.new.guess_possible_app_bundles_for_dir( Dir.pwd )
10
+ if possible_app_bundles && !possible_app_bundles.empty?
11
+ message << "\n\nBased on your current directory, you probably want to use one of the following paths for your APP_BUNDLE_PATH:\n"
12
+ message << possible_app_bundles.join("\n")
13
+ end
14
+
15
+ raise "\n\n"+("="*80)+"\n"+message+"\n"+("="*80)+"\n\n"
16
+ end
17
+
18
+
19
+ # kill the app if it's already running, just in case this helps
20
+ # reduce simulator flakiness when relaunching the app. Use a timeout of 5 seconds to
21
+ # prevent us hanging around for ages waiting for the ping to fail if the app isn't running
22
+ begin
23
+ Timeout::timeout(5) { press_home_on_simulator if frankly_ping }
24
+ rescue Timeout::Error
25
+ end
26
+
27
+
28
+ require 'sim_launcher'
29
+
30
+ if( ENV['USE_SIM_LAUNCHER_SERVER'] )
31
+ simulator = SimLauncher::Client.for_iphone_app( app_path )
32
+ else
33
+ simulator = SimLauncher::DirectClient.for_iphone_app( app_path )
34
+ end
35
+
36
+ num_timeouts = 0
37
+ loop do
38
+ begin
39
+ simulator.relaunch
40
+ wait_for_frank_to_come_up
41
+ break # if we make it this far without an exception then we're good to move on
42
+
43
+ rescue Timeout::Error
44
+ num_timeouts += 1
45
+ puts "Encountered #{num_timeouts} timeouts while launching the app."
46
+ if num_timeouts > 3
47
+ raise "Encountered #{num_timeouts} timeouts in a row while trying to launch the app."
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end end
@@ -1,5 +1,5 @@
1
1
  module Frank
2
2
  module Cucumber
3
- VERSION = "0.7.8"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,104 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: frank-cucumber
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 8
10
- version: 0.7.8
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Pete Hodgson
14
9
  - Derek Longmuir
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-10-26 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2011-11-10 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: cucumber
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2153809540 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
33
23
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
24
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2153809540
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &2153808740 !ruby/object:Gem::Requirement
39
29
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 2
46
- - 0
47
- version: "2.0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
48
34
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: sim_launcher
52
35
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2153808740
37
+ - !ruby/object:Gem::Dependency
38
+ name: sim_launcher
39
+ requirement: &2153808120 !ruby/object:Gem::Requirement
54
40
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
62
45
  type: :runtime
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: plist
66
46
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2153808120
48
+ - !ruby/object:Gem::Dependency
49
+ name: plist
50
+ requirement: &2153807400 !ruby/object:Gem::Requirement
68
51
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
76
56
  type: :runtime
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: json
80
57
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *2153807400
59
+ - !ruby/object:Gem::Dependency
60
+ name: json
61
+ requirement: &2153806780 !ruby/object:Gem::Requirement
82
62
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
90
67
  type: :runtime
91
- version_requirements: *id005
68
+ prerelease: false
69
+ version_requirements: *2153806780
92
70
  description: Use cucumber to test native iOS apps via Frank
93
- email:
71
+ email:
94
72
  - gems@thepete.net
95
- executables:
73
+ executables:
96
74
  - frank-skeleton
97
75
  extensions: []
98
-
99
76
  extra_rdoc_files: []
100
-
101
- files:
77
+ files:
102
78
  - .gitignore
103
79
  - Gemfile
104
80
  - Rakefile
@@ -141,39 +117,30 @@ files:
141
117
  - lib/frank-cucumber/color_helper.rb
142
118
  - lib/frank-cucumber/core_frank_steps.rb
143
119
  - lib/frank-cucumber/frank_helper.rb
120
+ - lib/frank-cucumber/launcher.rb
144
121
  - lib/frank-cucumber/version.rb
145
122
  homepage: http://rubygems.org/gems/frank-cucumber
146
123
  licenses: []
147
-
148
124
  post_install_message:
149
125
  rdoc_options: []
150
-
151
- require_paths:
126
+ require_paths:
152
127
  - lib
153
- required_ruby_version: !ruby/object:Gem::Requirement
128
+ required_ruby_version: !ruby/object:Gem::Requirement
154
129
  none: false
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- hash: 3
159
- segments:
160
- - 0
161
- version: "0"
162
- required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
135
  none: false
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- hash: 3
168
- segments:
169
- - 0
170
- version: "0"
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
171
140
  requirements: []
172
-
173
141
  rubyforge_project:
174
- rubygems_version: 1.8.11
142
+ rubygems_version: 1.8.10
175
143
  signing_key:
176
144
  specification_version: 3
177
145
  summary: Use cucumber to test native iOS apps via Frank
178
146
  test_files: []
179
-