calabash-cucumber 0.9.41 → 0.9.42

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- calabash-cucumber (0.9.36)
4
+ calabash-cucumber (0.9.41)
5
5
  CFPropertyList
6
6
  cucumber
7
7
  json
8
8
  net-http-persistent
9
- pbxproject
10
9
  sim_launcher
11
10
  slowhandcuke
12
11
 
@@ -29,7 +28,6 @@ GEM
29
28
  json (1.6.5)
30
29
  libxml-ruby (2.2.2)
31
30
  net-http-persistent (2.5.2)
32
- pbxproject (0.2.4)
33
31
  rack (1.4.1)
34
32
  rack-protection (1.2.0)
35
33
  rack
data/bin/CalabashSetup ADDED
Binary file
data/bin/calabash-ios CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'fileutils'
4
4
  require 'CFPropertyList'
5
5
  require 'rexml/document'
6
- require 'pbxproject'
7
6
 
8
7
 
9
8
  require File.join(File.dirname(__FILE__),"calabash-ios-helpers")
@@ -3,85 +3,41 @@ require 'rexml/rexml'
3
3
  require "rexml/document"
4
4
 
5
5
 
6
- def dup_scheme(project_name, pbx_dir, target)
7
-
8
- userdata_dirs = Dir.foreach("#{pbx_dir}/xcuserdata").find_all { |x|
9
- /\.xcuserdatad$/.match(x)
10
- }
11
-
12
- target_name = target.name.value
13
-
14
- if target_name.start_with?'"' and target_name.end_with?'"'
15
- target_name = target_name[1..target_name.length-2]
16
- end
17
-
18
- userdata_dirs.each do |userdata_dir|
19
- scheme_to_find = "#{target_name}.xcscheme"
20
- cal_scheme_to_find = "#{target_name}-cal.xcscheme"
21
- schemes = Dir.foreach("#{pbx_dir}/xcuserdata/#{userdata_dir}/xcschemes")
22
- scheme = schemes.find do |s|
23
- scheme_to_find == s
24
- end
25
- cal_scheme = schemes.find do |s|
26
- cal_scheme_to_find == s
27
- end
28
-
29
- if scheme.nil?
30
- puts "-"*10 + "Warning" + "-"*10
31
- puts "Unable to find scheme: #{target_name}.xcscheme."
32
- puts "You must manually create a scheme."
33
- puts "Make sure your scheme uses the Calabash build configuration."
34
- puts "-"*10 + "-------" + "-"*10
35
- else
36
- if not cal_scheme.nil?
37
- msg("Warning") do
38
- puts "Scheme: #{target_name}-cal.xcscheme already exists."
39
- puts "Will not try to duplicate #{target_name}.xcscheme."
40
- end
41
- else
42
- msg("Action") do
43
- puts "Duplicating scheme #{target_name}.xcscheme as #{target_name}-cal.xcscheme"
44
-
45
- doc = REXML::Document.new(File.new("#{pbx_dir}/xcuserdata/#{userdata_dir}/xcschemes/#{scheme}"))
46
-
47
- doc.elements.each("Scheme/LaunchAction") do |la|
48
- la.attributes["buildConfiguration"] = "Calabash"
49
- end
50
- doc.elements.each("Scheme/ArchiveAction") do |la|
51
- la.attributes["buildConfiguration"] = "Calabash"
52
- end
53
- doc.elements.each("Scheme/AnalyzeAction") do |la|
54
- la.attributes["buildConfiguration"] = "Calabash"
55
- end
56
- doc.elements.each("Scheme/ProfileAction") do |la|
57
- la.attributes["buildConfiguration"] = "Calabash"
58
- end
59
- f=File.open("#{pbx_dir}/xcuserdata/#{userdata_dir}/xcschemes/#{target_name}-cal.xcscheme", "w")
60
- doc.write f
61
- f.close
6
+ def detect_accessibility_support
7
+ dirs = Dir.glob(File.join(File.expand_path("~/Library"),"Application Support","iPhone Simulator","*.*","Library","Preferences"))
8
+ dirs.each do |sim_pref_dir|
9
+ fp = File.expand_path("#{sim_pref_dir}/com.apple.Accessibility.plist")
10
+ out = `defaults read "#{fp}" ApplicationAccessibilityEnabled`
11
+
12
+ if not(File.exists?(fp)) || out.split("\n")[0] == "0"
13
+ msg("Warn") do
14
+ puts "Accessibility is not enabled for simulator: #{sim_pref_dir}"
15
+ puts "Enabled accessibility as described here:"
16
+ puts "https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide"
17
+ puts "Alternatively run command:"
18
+ puts "calabash-ios sim acc"
62
19
  end
63
- end
64
20
  end
65
21
 
66
22
  end
67
- "#{target_name}-cal"
68
23
  end
69
24
 
70
-
71
25
  def calabash_setup(args)
72
26
  puts "Checking if Xcode is running..."
73
27
  res = `ps x -o pid,command | grep -v grep | grep Xcode.app/Contents/MacOS/Xcode`
74
28
  if res==""
75
29
  puts "Xcode not running."
76
30
  project_name, project_path, xpath = find_project_files(args)
77
- target = setup_project(project_name, project_path, xpath)
78
- scheme = dup_scheme(project_name, xpath, target)
31
+ setup_project(project_name, project_path, xpath)
32
+
33
+ detect_accessibility_support
34
+
79
35
  msg("Setup done") do
80
36
 
81
- puts "Please validate by running the #{scheme} scheme"
37
+ puts "Please validate by running the -cal target"
82
38
  puts "from Xcode."
83
39
  puts "When starting the iOS Simulator using the"
84
- puts "new scheme: #{project_name}-cal, you should see:\n\n"
40
+ puts "new -cal target, you should see:\n\n"
85
41
  puts ' "Started LPHTTP server on port 37265"'
86
42
  puts "\nin the application log in Xcode."
87
43
  puts "\n\n"
@@ -211,8 +167,6 @@ def setup_project(project_name, project_path, path)
211
167
  end
212
168
  exit 1
213
169
  end
214
- pbx = PBXProject::PBXProject.new(:file => proj_file)
215
- pbx.parse
216
170
 
217
171
  pwd = FileUtils.pwd
218
172
  FileUtils.cd project_path
@@ -229,181 +183,11 @@ def setup_project(project_name, project_path, path)
229
183
 
230
184
  file = download_calabash(project_path)
231
185
 
232
-
233
- file_ref = pbx.sections['PBXFileReference'].find do |fr|
234
- /calabash\.framework/.match(fr.path)
235
- end
236
-
237
- if file_ref
238
- msg("Error") do
239
- puts "Your project already contains a file reference to calabash.framework."
240
- puts "I was not expecting this. Aborting."
241
- end
242
- exit 1
243
- end
244
-
245
186
  msg("Info") do
246
187
  puts "Setting up project file for calabash-ios."
247
188
  end
248
189
 
249
190
 
250
- ## Augment
251
- f = PBXProject::PBXTypes::PBXFileReference.new(:path => file, :lastKnownFileType => "wrapper.framework", :sourceTree => '"<group>"')
252
- f.comment = "calabash.framework"
253
- pbx.add_item f
254
- bf = PBXProject::PBXTypes::PBXBuildFile.new(:comment => "calabash.framework in Frameworks", :fileRef => f.guid)
255
- bf.comment = "calabash.framework in Frameworks"
256
- pbx.add_item bf
257
-
258
- group = pbx.find_item :name => "Frameworks", :type => PBXProject::PBXTypes::PBXGroup
259
- group.add_children f
260
-
261
- build_phase_entry = PBXProject::PBXTypes::BasicValue.new(:value => bf.guid, :comment => bf.comment)
262
- pbx.sections['PBXFrameworksBuildPhase'][0].files << build_phase_entry
263
-
264
-
265
-
266
-
267
-
268
- targets = pbx.sections['PBXNativeTarget']
269
- target = nil
270
- if targets.count == 0
271
- msg("Error") do
272
- puts "Unable to find targets in project."
273
- puts "Aborting..."
274
- end
275
- exit 1
276
- elsif (targets.count == 1)
277
- target = targets[0]
278
- else
279
- preferred_target = targets.find { |t| t.name.value == project_name }
280
- msg("Question") do
281
- puts "You have several targets..."
282
- target_names = targets.map do |t|
283
- n = t.name.value
284
- if n.length>2 and n.end_with?'"' and n.start_with?'"'
285
- n = n[1..n.length-2]
286
- end
287
- n
288
- end
289
-
290
- puts target_names.join("\n")
291
-
292
- found = nil
293
- until found do
294
- puts "Please specify which is your production app target."
295
- puts "Please enter target name."
296
- puts "Hit Enter for default choice: #{preferred_target.name.value}" unless preferred_target.nil?
297
- answer = STDIN.gets.chomp
298
- if (preferred_target and answer == '')
299
- target = preferred_target
300
- found = true
301
- else
302
- target = found = targets.find { |t| t.name.value == answer || t.name.value=="\"#{answer}\""}
303
- end
304
- end
305
- end
306
- end
307
-
308
- #CFNetwork
309
- cfnet = pbx.find_item :name => "CFNetwork.framework", :type => PBXProject::PBXTypes::PBXFileReference
310
-
311
- if cfnet
312
- msg("Warning") do
313
- puts "You are already using CFNetwork.framework"
314
- puts "Please make sure you have added it to your target #{target.name.value}."
315
- end
316
- else
317
- f = PBXProject::PBXTypes::PBXFileReference.new(:path => "System/Library/Frameworks/CFNetwork.framework", :lastKnownFileType => "wrapper.framework", :sourceTree => 'SDKROOT')
318
- f.comment = "CFNetwork.framework"
319
- f.name = f.comment
320
- pbx.add_item f
321
- bf = PBXProject::PBXTypes::PBXBuildFile.new(:comment => "CFNetwork.framework in Frameworks", :fileRef => f.guid)
322
- bf.comment = "CFNetwork.framework in Frameworks"
323
- pbx.add_item bf
324
- group.add_children f
325
- build_phase_entry = PBXProject::PBXTypes::BasicValue.new(:value => bf.guid, :comment => bf.comment)
326
- pbx.sections['PBXFrameworksBuildPhase'][0].files << build_phase_entry
327
- end
328
-
329
-
330
- ##project level build conf
331
- project_bc_id = pbx.sections['PBXProject'][0].buildConfigurationList.value
332
- project_bc_list = pbx.find_item :guid => project_bc_id, :type => PBXProject::PBXTypes::XCConfigurationList
333
- project_bc_ref = project_bc_list.buildConfigurations.find { |bc| bc.comment =="Debug" }
334
- project_bc_id = project_bc_ref.value
335
- project_bc = pbx.find_item :guid => project_bc_id, :type => PBXProject::PBXTypes::XCBuildConfiguration
336
- project_cal_build_settings = project_bc.buildSettings.clone
337
- project_bc.buildSettings.each do |k, v|
338
- project_cal_build_settings[k] = v.clone
339
- end
340
-
341
- project_cal_bc = PBXProject::PBXTypes::XCBuildConfiguration.new(:name => "Calabash")
342
- project_cal_bc.buildSettings = project_cal_build_settings
343
- project_cal_bc.comment = "Calabash"
344
-
345
- ##target level build conf
346
- bc_list_id = target.buildConfigurationList.value
347
- bc_list = pbx.find_item :guid => bc_list_id, :type => PBXProject::PBXTypes::XCConfigurationList
348
- bc_ref = bc_list.buildConfigurations.find { |bc| bc.comment =="Debug" }
349
- bc_id = bc_ref.value
350
- bc = pbx.find_item :guid => bc_id, :type => PBXProject::PBXTypes::XCBuildConfiguration
351
- cal_build_settings = bc.buildSettings.clone
352
-
353
- bc.buildSettings.each do |k, v|
354
- cal_build_settings[k] = v.clone
355
- end
356
-
357
- ld_flags = cal_build_settings['OTHER_LDFLAGS'] || []
358
- if not ld_flags.is_a?Array
359
- ld_flags = [ld_flags]
360
- end
361
- danger = ld_flags.find_all {|f| /-ObjC/i.match(f.value) || /-all_load/i.match(f.value)}
362
-
363
- unless danger.empty?
364
- msg("Error") do
365
- puts "Detected Other Linker Flag: #{(danger.map {|d| d.value}).join(", ")}"
366
- puts "calabash-ios setup does not yet support this scenario"
367
- puts "(why? karl@lesspainful.com)"
368
- puts "You must manually setup ios see:"
369
- puts "https://github.com/calabash/calabash-ios"
370
- end
371
- exit 1
372
- end
373
-
374
- ld_flags << PBXProject::PBXTypes::BasicValue.new(:value => '"-force_load"')
375
- ld_flags << PBXProject::PBXTypes::BasicValue.new(:value => '"$(SRCROOT)/calabash.framework/calabash"')
376
- ld_flags << PBXProject::PBXTypes::BasicValue.new(:value => '"-lstdc++"')
377
-
378
-
379
- cal_build_settings['OTHER_LDFLAGS'] = ld_flags
380
-
381
- cal_bc = PBXProject::PBXTypes::XCBuildConfiguration.new(:name => "Calabash")
382
- cal_bc.buildSettings = cal_build_settings
383
- cal_bc.comment = "Calabash"
384
-
385
- targets.each do |target|
386
- bc_list_id = target.buildConfigurationList.value
387
- bc_list = pbx.find_item :guid => bc_list_id, :type => PBXProject::PBXTypes::XCConfigurationList
388
- bc_list.buildConfigurations << PBXProject::PBXTypes::BasicValue.new(:value => cal_bc.guid, :comment => "Calabash")
389
- end
390
-
391
- project_bc_list.buildConfigurations << PBXProject::PBXTypes::BasicValue.new(:value => project_cal_bc.guid, :comment => "Calabash")
392
-
393
- pbx.sections['XCBuildConfiguration']<<project_cal_bc
394
- pbx.sections['XCBuildConfiguration']<<cal_bc
395
-
396
- pbx.sections['XCBuildConfiguration'].each do |bc|
397
- sp = bc.buildSettings["FRAMEWORK_SEARCH_PATHS"] || []
398
- if not sp.is_a?Array
399
- sp = [sp]
400
- end
401
- inherit = sp.find { |x| x.value == '"$(inherited)"' }
402
- srcroot = sp.find { |x| x.value == "\"$(SRCROOT)\""}
403
- sp << PBXProject::PBXTypes::BasicValue.new(:value => '"$(inherited)"') unless inherit
404
- sp << PBXProject::PBXTypes::BasicValue.new(:value => "\"$(SRCROOT)\"") unless srcroot
405
- bc.buildSettings["FRAMEWORK_SEARCH_PATHS"] = sp
406
- end
407
191
  FileUtils.cd pwd
408
192
 
409
193
  ##Backup
@@ -413,9 +197,10 @@ def setup_project(project_name, project_path, path)
413
197
  puts "Saved as #{proj_file}.bak"
414
198
  end
415
199
 
200
+ path_to_setup = File.join(File.dirname(__FILE__), 'CalabashSetup')
201
+ setup_cmd = "#{path_to_setup} #{path} #{project_name}"
202
+ system(setup_cmd)
416
203
 
417
- pbx.write_to :file => proj_file
418
- return target
419
204
  end
420
205
 
421
206
 
@@ -445,7 +230,7 @@ def validate_setup(args)
445
230
  sim_dirs = sim_dirs.concat(Dir.glob(File.join(dd_dir, "Build", "Products", "Calabash-iphonesimulator", "*.app")))
446
231
  if sim_dirs.empty?
447
232
  msg = ["Have you built your app for simulator?"]
448
- msg << "You should build the -cal scheme and your normal scheme"
233
+ msg << "You should build the -cal target and your normal target"
449
234
  msg << "(with configuration Debug)."
450
235
  msg << "Searched dir: #{dd_dir}/Build/Products"
451
236
  msg("Error") do
@@ -454,7 +239,7 @@ def validate_setup(args)
454
239
  exit 1
455
240
  elsif sim_dirs.count != 2
456
241
  msg = ["Have you built your app for simulator?"]
457
- msg << "You should build the -cal scheme and your normal scheme"
242
+ msg << "You should build the -cal target and your normal target"
458
243
  msg << "(with configuration Debug)."
459
244
  msg << "Searched dir: #{dd_dir}/Build/Products"
460
245
  msg("Error") do
@@ -22,6 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency( "sim_launcher" )
23
23
  s.add_dependency( "slowhandcuke" )
24
24
  s.add_dependency( "net-http-persistent" )
25
- s.add_dependency( "pbxproject" )
26
25
 
27
26
  end
@@ -47,10 +47,10 @@ module Calabash
47
47
  msg << "To fix there are a couple of options:\n"
48
48
  msg << "Option 1) Make sure you are running this command from your project directory, "
49
49
  msg << "i.e., the directory containing your .xcodeproj file."
50
- msg << "In Xcode, build your calabash target or scheme for simulator."
50
+ msg << "In Xcode, build your calabash target for simulator."
51
51
  msg << "Check that your app can be found in\n #{File.expand_path("~/Library/Developer/Xcode/DerivedData")}"
52
52
  msg << "\n\nOption 2). In features/support/launch.rb set APP_BUNDLE_PATH to"
53
- msg << "the path where Xcode has built your Calabash target or scheme."
53
+ msg << "the path where Xcode has built your Calabash target."
54
54
  msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
55
55
  raise msg.join("\n")
56
56
  end
@@ -80,7 +80,7 @@ module Calabash
80
80
  msg << "Have you built your app for simulator?."
81
81
  msg << "Searched dir: #{dd_dir}/Build/Products"
82
82
  msg << "Please build your app from Xcode"
83
- msg << "You should build the -cal scheme or your calabash target."
83
+ msg << "You should build the -cal target."
84
84
  msg << ""
85
85
  msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/launch.rb"
86
86
  msg << "This should point to the location of your built app linked with calabash.\n"
@@ -91,7 +91,7 @@ module Calabash
91
91
  msg = ["Error... Unable to find APP_BUNDLE_PATH."]
92
92
  msg << "Cannot find a built app that is linked with calabash.framework"
93
93
  msg << "Please build your app from Xcode"
94
- msg << "You should build the -cal scheme or your calabash target."
94
+ msg << "You should build your calabash target."
95
95
  msg << ""
96
96
  msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/launch.rb"
97
97
  msg << "This should point to the location of your built app linked with calabash.\n"
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = "0.9.41"
3
+ VERSION = "0.9.42"
4
4
  FRAMEWORK_VERSION = "0.9.36"
5
5
  end
6
6
  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.41
4
+ version: 0.9.42
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-07 00:00:00.000000000 Z
12
+ date: 2012-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
16
- requirement: &70211827084720 !ruby/object:Gem::Requirement
16
+ requirement: &70347693454980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70211827084720
24
+ version_requirements: *70347693454980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &70211827084100 !ruby/object:Gem::Requirement
27
+ requirement: &70347693450760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70211827084100
35
+ version_requirements: *70347693450760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: CFPropertyList
38
- requirement: &70211827083620 !ruby/object:Gem::Requirement
38
+ requirement: &70347693450320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70211827083620
46
+ version_requirements: *70347693450320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sim_launcher
49
- requirement: &70211827082960 !ruby/object:Gem::Requirement
49
+ requirement: &70347693449560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70211827082960
57
+ version_requirements: *70347693449560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: slowhandcuke
60
- requirement: &70211827082240 !ruby/object:Gem::Requirement
60
+ requirement: &70347693448840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70211827082240
68
+ version_requirements: *70347693448840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: net-http-persistent
71
- requirement: &70211827080280 !ruby/object:Gem::Requirement
71
+ requirement: &70347693448380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,18 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70211827080280
80
- - !ruby/object:Gem::Dependency
81
- name: pbxproject
82
- requirement: &70211827079460 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: *70211827079460
79
+ version_requirements: *70347693448380
91
80
  description: calabash-cucumber drives tests for native iOS apps. You must link your
92
81
  app with calabash-ios-server framework to execute tests.
93
82
  email:
@@ -103,6 +92,7 @@ files:
103
92
  - Gemfile.lock
104
93
  - LICENSE
105
94
  - Rakefile
95
+ - bin/CalabashSetup
106
96
  - bin/calabash-ios
107
97
  - bin/calabash-ios-generate.rb
108
98
  - bin/calabash-ios-helpers.rb
@@ -120,7 +110,6 @@ files:
120
110
  - features-skeleton/support/hooks.rb
121
111
  - features-skeleton/support/launch.rb
122
112
  - lib/calabash-cucumber.rb
123
- - lib/calabash-cucumber/calabash_helper.rb
124
113
  - lib/calabash-cucumber/calabash_steps.rb
125
114
  - lib/calabash-cucumber/color_helper.rb
126
115
  - lib/calabash-cucumber/cucumber.rb
@@ -1,13 +0,0 @@
1
- require 'pbxproject'
2
-
3
- module Calabash module Cucumber
4
-
5
- module ProjectHelper
6
-
7
- def self.setup_project(path)
8
- puts path
9
- end
10
-
11
-
12
- end
13
- end end