frank-cucumber 0.8.6 → 0.8.7

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.
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'bundler'
2
+ require 'rake/testtask'
2
3
  Bundler::GemHelper.install_tasks
3
4
 
4
5
  task :edit_version do
@@ -7,3 +8,10 @@ end
7
8
 
8
9
  task :ev => :edit_version
9
10
 
11
+ Rake::TestTask.new do |t|
12
+ t.libs << "test"
13
+ t.test_files = FileList['test/*_test.rb','test/*_acceptance.rb']
14
+ t.verbose = true
15
+ end
16
+
17
+ task :default => ["test"]
@@ -1,4 +1,20 @@
1
+ def app_path
2
+ ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
3
+ end
4
+
1
5
  Given /^I launch the app$/ do
2
- app_path = ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
6
+ # latest sdk and iphone by default
3
7
  launch_app app_path
4
8
  end
9
+
10
+ Given /^I launch the app using iOS (\d\.\d)$/ do |sdk|
11
+ # You can grab a list of the installed SDK with sim_launcher
12
+ # > run sim_launcher from the command line
13
+ # > open a browser to http://localhost:8881/showsdks
14
+ # > use one of the sdk you see in parenthesis (e.g. 4.2)
15
+ launch_app app_path, sdk
16
+ end
17
+
18
+ Given /^I launch the app using iOS (\d\.\d) and the (iphone|ipad) simulator$/ do |sdk, version|
19
+ launch_app app_path, sdk, version
20
+ end
Binary file
@@ -1,20 +1,37 @@
1
+ require 'sim_launcher'
2
+ require 'frank-cucumber/app_bundle_locator'
3
+
1
4
  module Frank module Cucumber
2
5
 
3
6
  module Launcher
4
-
5
- def launch_app(app_path)
7
+ attr_accessor :application_path, :sdk, :version
8
+
9
+ def simulator_client
10
+ @simulator_client ||= SimLauncher::Client.new(@application_path, @sdk, @version)
11
+ end
12
+
13
+ def simulator_direct_client
14
+ @simulator_direct_client ||= SimLauncher::DirectClient.new(@application_path, @sdk, @version)
15
+ end
16
+
17
+ def enforce(app_path, locator = Frank::Cucumber::AppBundleLocator.new)
6
18
  if app_path.nil?
7
- require 'frank-cucumber/app_bundle_locator'
8
19
  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 )
20
+ possible_app_bundles = locator.guess_possible_app_bundles_for_dir( Dir.pwd )
10
21
  if possible_app_bundles && !possible_app_bundles.empty?
11
22
  message << "\n\nBased on your current directory, you probably want to use one of the following paths for your APP_BUNDLE_PATH:\n"
12
23
  message << possible_app_bundles.join("\n")
13
24
  end
14
-
15
25
  raise "\n\n"+("="*80)+"\n"+message+"\n"+("="*80)+"\n\n"
16
26
  end
27
+ end
28
+
29
+ def launch_app(app_path, sdk = nil, version = 'iphone')
30
+ @application_path = app_path
31
+ @sdk = sdk
32
+ @version = version
17
33
 
34
+ enforce(app_path)
18
35
 
19
36
  # kill the app if it's already running, just in case this helps
20
37
  # reduce simulator flakiness when relaunching the app. Use a timeout of 5 seconds to
@@ -24,13 +41,10 @@ module Launcher
24
41
  rescue Timeout::Error
25
42
  end
26
43
 
27
-
28
- require 'sim_launcher'
29
-
30
44
  if( ENV['USE_SIM_LAUNCHER_SERVER'] )
31
- simulator = SimLauncher::Client.for_iphone_app( app_path )
45
+ simulator = simulator_client
32
46
  else
33
- simulator = SimLauncher::DirectClient.for_iphone_app( app_path )
47
+ simulator = simulator_direct_client
34
48
  end
35
49
 
36
50
  num_timeouts = 0
@@ -1,5 +1,5 @@
1
1
  module Frank
2
2
  module Cucumber
3
- VERSION = "0.8.6"
3
+ VERSION = "0.8.7"
4
4
  end
5
5
  end
@@ -0,0 +1,43 @@
1
+ require_relative 'test_helper.rb'
2
+
3
+ def wait_for_frank_to_come_up
4
+ # orig FrankHelper::wait_for_frank_to_come_up
5
+ # doing nothing
6
+ end
7
+
8
+ describe "frank cucumber launcher" do
9
+
10
+ describe "when the path is wrong" do
11
+
12
+ it 'throws exception when no app path is given' do
13
+ assert_raises(RuntimeError) do
14
+ enforce(nil)
15
+ end
16
+ end
17
+
18
+ it 'prints suggestions if available' do
19
+ mock_locator = Mock.new
20
+ mock_locator.expect :guess_possible_app_bundles_for_dir, ['suggestion_1'], ['']
21
+ begin
22
+ enforce(nil, mock_locator)
23
+ rescue RuntimeError => e
24
+ e.message.must_match "suggestion_1"
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "when starting the simulator with the specified params" do
30
+
31
+ before do
32
+ @simulator_direct_client = Mock.new
33
+ @simulator_direct_client.expect :relaunch, nil, []
34
+ end
35
+
36
+ it 'selects iphone mode by default' do
37
+ launch_app('test_path', 'X.Y')
38
+ @version.must_equal 'iphone'
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,10 @@
1
+ require 'stringio'
2
+ require 'minitest/autorun'
3
+ require 'minitest/mock'
4
+ require 'minitest/spec'
5
+ include MiniTest
6
+ require_relative '../lib/frank-cucumber/color_helper'
7
+ require_relative '../lib/frank-cucumber/frank_helper'
8
+ require_relative '../lib/frank-cucumber/launcher'
9
+ include Frank::Cucumber::Launcher
10
+ include Frank::Cucumber::FrankHelper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frank-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-12-02 00:00:00.000000000Z
13
+ date: 2011-12-22 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cucumber
17
- requirement: &2160510280 !ruby/object:Gem::Requirement
17
+ requirement: &70187491760960 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2160510280
25
+ version_requirements: *70187491760960
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2160490760 !ruby/object:Gem::Requirement
28
+ requirement: &70187491760440 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2160490760
36
+ version_requirements: *70187491760440
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sim_launcher
39
- requirement: &2160490260 !ruby/object:Gem::Requirement
39
+ requirement: &70187491760020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2160490260
47
+ version_requirements: *70187491760020
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: plist
50
- requirement: &2160489700 !ruby/object:Gem::Requirement
50
+ requirement: &70187491759560 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2160489700
58
+ version_requirements: *70187491759560
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: json
61
- requirement: &2160489260 !ruby/object:Gem::Requirement
61
+ requirement: &70187491759140 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2160489260
69
+ version_requirements: *70187491759140
70
70
  description: Use cucumber to test native iOS apps via Frank
71
71
  email:
72
72
  - gems@thepete.net
@@ -120,6 +120,8 @@ files:
120
120
  - lib/frank-cucumber/frank_helper.rb
121
121
  - lib/frank-cucumber/launcher.rb
122
122
  - lib/frank-cucumber/version.rb
123
+ - test/launcher_test.rb
124
+ - test/test_helper.rb
123
125
  homepage: http://rubygems.org/gems/frank-cucumber
124
126
  licenses: []
125
127
  post_install_message:
@@ -144,4 +146,6 @@ rubygems_version: 1.8.10
144
146
  signing_key:
145
147
  specification_version: 3
146
148
  summary: Use cucumber to test native iOS apps via Frank
147
- test_files: []
149
+ test_files:
150
+ - test/launcher_test.rb
151
+ - test/test_helper.rb