fwtoolkit 0.9.3 → 1.0.1

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.
Files changed (130) hide show
  1. checksums.yaml +8 -8
  2. data/bin/fwt +2 -112
  3. data/features/cocoapods/setup.feature +60 -0
  4. data/features/frank/model.feature +20 -0
  5. data/features/frank/setup.feature +28 -0
  6. data/features/git/create.feature +29 -0
  7. data/features/project/create.feature +25 -0
  8. data/features/step_definitions/aruba_steps.rb +11 -0
  9. data/features/step_definitions/git_steps.rb +30 -0
  10. data/features/step_definitions/project_steps.rb +50 -0
  11. data/features/step_definitions/rvm_steps.rb +11 -0
  12. data/features/step_definitions/system_steps.rb +8 -0
  13. data/features/support/env.rb +23 -0
  14. data/features/support/lib_test/aruba_fwt.rb +30 -0
  15. data/features/support/lib_test/aruba_mod.rb +28 -0
  16. data/features/support/lib_test/fake_gem.rb +47 -0
  17. data/features/xcode/create.feature +42 -0
  18. data/lib/fwtoolkit/cli/bootstrap.rb +75 -0
  19. data/lib/fwtoolkit/cli/ci.rb +52 -0
  20. data/lib/fwtoolkit/cli/cocoapods.rb +73 -0
  21. data/lib/fwtoolkit/cli/ext/thor.rb +35 -0
  22. data/lib/fwtoolkit/cli/frank.rb +113 -0
  23. data/lib/fwtoolkit/cli/fw_actions/template_dir.rb +59 -0
  24. data/lib/fwtoolkit/cli/fw_actions.rb +2 -0
  25. data/lib/fwtoolkit/cli/git.rb +42 -0
  26. data/lib/fwtoolkit/cli/ota.rb +109 -0
  27. data/lib/fwtoolkit/cli/ota_client/hockeyapp_client.rb +70 -0
  28. data/lib/fwtoolkit/cli/project.rb +83 -0
  29. data/lib/fwtoolkit/cli/thorutils.rb +14 -0
  30. data/lib/fwtoolkit/cli/xcode.rb +105 -0
  31. data/lib/fwtoolkit/cli.rb +27 -36
  32. data/lib/fwtoolkit/config/config.sample +8 -0
  33. data/lib/fwtoolkit/config.rb +41 -0
  34. data/lib/fwtoolkit/configfile.rb +36 -0
  35. data/lib/fwtoolkit/executable/executable.rb +45 -0
  36. data/lib/fwtoolkit/executable.rb +1 -0
  37. data/lib/fwtoolkit/ext/gem.rb +9 -0
  38. data/lib/fwtoolkit/ext/hash_yaml.rb +17 -0
  39. data/lib/fwtoolkit/git_client/git_client.rb +225 -0
  40. data/lib/fwtoolkit/git_client.rb +1 -0
  41. data/lib/fwtoolkit/projectfile.rb +50 -0
  42. data/lib/fwtoolkit/rake/ext/rake.rb +7 -0
  43. data/lib/fwtoolkit/rake/tasks/ci.rb +25 -0
  44. data/lib/fwtoolkit/rake/tasks/config.rb +13 -0
  45. data/lib/fwtoolkit/rake/tasks/ota.rb +31 -0
  46. data/lib/fwtoolkit/rake/tasks/project.rb +28 -0
  47. data/lib/fwtoolkit/rake/tasks/test.rb +59 -0
  48. data/lib/fwtoolkit/rake/tasks/xcode.rb +69 -0
  49. data/lib/fwtoolkit/rake/tasks.rb +20 -0
  50. data/lib/fwtoolkit/version.rb +1 -1
  51. data/lib/fwtoolkit.rb +4 -7
  52. data/spec/git_client_spec.rb +316 -0
  53. data/spec/project_config_spec.rb +40 -0
  54. data/spec/rake/project.rb +28 -0
  55. data/spec/rake/test.rb +85 -0
  56. data/spec/rake/xcode.rb +66 -0
  57. data/spec/support/aruba-doubles-rspec.rb +21 -0
  58. data/spec/support/ctx_rake.rb +23 -0
  59. data/spec/support/double_helper.rb +13 -0
  60. data/spec/support/project_generator.rb +45 -0
  61. data/templates/default_project/frank/%project_name%/%target_name%/%class_prefix%AppDelegate+Frank.h.tt +15 -0
  62. data/templates/{cucumber/AppDelegate+Frank.m.erb → default_project/frank/%project_name%/%target_name%/%class_prefix%AppDelegate+Frank.m.tt} +25 -21
  63. data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/example.feature +0 -0
  64. data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/step_definitions/launch_steps.rb +0 -0
  65. data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/support/env.rb +0 -0
  66. data/templates/{cucumber → default_project/frank/%project_name%/Frank}/features/support/mimic.rb +0 -0
  67. data/templates/default_project/frank/~template_config.rb +11 -0
  68. data/templates/default_project/frank_seed_core_data/%project_name%/Frank/features/support/models/%class_name%.rb.tt +30 -0
  69. data/templates/default_project/frank_seed_support/%project_name%/Frank/features/support/models/factories.rb.tt +10 -0
  70. data/templates/{cucumber → default_project/frank_seed_support/%project_name%/Frank}/features/support/views/my_objects_json.erb +0 -0
  71. data/templates/{cucumber → default_project/frank_seed_support/%project_name%/Frank}/features/support/views/my_objects_xml.erb +0 -0
  72. data/templates/{fwt/gitignore.erb → default_project/git/.gitignore} +0 -0
  73. data/templates/{fwt/rvmrc.erb → default_project/rvm/.rvmrc.tt} +2 -2
  74. data/templates/default_project/rvm/Gemfile +4 -0
  75. data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/project.pbxproj.tt +583 -0
  76. data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/project.xcworkspace/contents.xcworkspacedata.tt +7 -0
  77. data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/xcshareddata/xcschemes/%project_name%-Release.xcscheme.tt +105 -0
  78. data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/xcshareddata/xcschemes/%project_name%-Testing.xcscheme.tt +105 -0
  79. data/templates/default_project/xcode/%project_name%/%project_name%.xcodeproj/xcshareddata/xcschemes/%project_name%.xcscheme.tt +105 -0
  80. data/templates/default_project/xcode/%project_name%/%target_name%/%class_prefix%AppDelegate.h.tt +15 -0
  81. data/templates/default_project/xcode/%project_name%/%target_name%/%class_prefix%AppDelegate.m.tt +49 -0
  82. data/templates/{fwt/default_project/Info.plist.erb → default_project/xcode/%project_name%/%target_name%/Supporting Files/%project_name%-Info.plist} +0 -0
  83. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/%project_name%-Prefix.pch.tt +14 -0
  84. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/Settings.bundle/Root.plist +53 -0
  85. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/Settings.bundle/en.lproj/Root.strings +0 -0
  86. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/en.lproj/InfoPlist.strings +2 -0
  87. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/fw-shared.xcconfig +49 -0
  88. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/info.plist.h.tt +8 -0
  89. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/main.m.tt +18 -0
  90. data/templates/default_project/xcode/%project_name%/%target_name%/Supporting Files/version.sh +159 -0
  91. data/templates/default_project/xcode/%project_name%/%tests_target_name%/%project_name%Tests.h.tt +13 -0
  92. data/templates/default_project/xcode/%project_name%/%tests_target_name%/%project_name%Tests.m.tt +32 -0
  93. data/templates/default_project/xcode/%project_name%/%tests_target_name%/Supporting Files/%tests_target_name%-Info.plist +22 -0
  94. data/templates/default_project/xcode/%project_name%/%tests_target_name%/Supporting Files/en.lproj/InfoPlist.strings +2 -0
  95. data/templates/default_project/xcode/%project_name%/Default.png +0 -0
  96. data/templates/default_project/xcode/%project_name%/Resources/Default-568h@2x.png +0 -0
  97. data/templates/default_project/xcode/%project_name%/Resources/Default.png +0 -0
  98. data/templates/default_project/xcode/%project_name%/Resources/Default@2x.png +0 -0
  99. data/templates/default_project/xcode/%project_name%.xcworkspace/contents.xcworkspacedata.tt +7 -0
  100. data/templates/default_project/xcode/FWProjectfile.tt +14 -0
  101. data/templates/default_project/xcode/Podfile.tt +4 -0
  102. data/templates/default_project/xcode/Rakefile.tt +14 -0
  103. data/templates/default_project/xcode/cruise_config.rb +3 -0
  104. data/templates/default_project/xcode/~template_config.rb +5 -0
  105. metadata +187 -141
  106. data/lib/fwtoolkit/tasks/build.rb +0 -121
  107. data/lib/fwtoolkit/tasks/ci.rb +0 -30
  108. data/lib/fwtoolkit/tasks/cocoapods.rb +0 -32
  109. data/lib/fwtoolkit/tasks/frank.rb +0 -119
  110. data/lib/fwtoolkit/tasks/helper.rb +0 -16
  111. data/lib/fwtoolkit/tasks/services.rb +0 -41
  112. data/lib/fwtoolkit/tasks.rb +0 -24
  113. data/lib/fwtoolkit/test/frank_model.rb +0 -120
  114. data/lib/fwtoolkit/test/misc_steps.rb +0 -9
  115. data/lib/fwtoolkit/test/model_helper.rb +0 -94
  116. data/lib/fwtoolkit/test/network_steps.rb +0 -60
  117. data/lib/fwtoolkit/test/pickle_steps.rb +0 -101
  118. data/lib/fwtoolkit/test/timeout_helper.rb +0 -21
  119. data/lib/fwtoolkit/test/ui_helper.rb +0 -19
  120. data/lib/fwtoolkit/test/ui_steps.rb +0 -17
  121. data/templates/cucumber/AppDelegate+Frank.h.erb +0 -15
  122. data/templates/fwt/Gemfile.erb +0 -3
  123. data/templates/fwt/Podfile.erb +0 -4
  124. data/templates/fwt/Rakefile.erb +0 -24
  125. data/templates/fwt/default_project/AppDelegate.h.erb +0 -12
  126. data/templates/fwt/default_project/AppDelegate.m.erb +0 -20
  127. data/templates/fwt/default_project/Prefix.pch.erb +0 -6
  128. data/templates/fwt/default_project/main.m.erb +0 -15
  129. data/templates/models/factories.rb.erb +0 -10
  130. data/templates/models/model.rb.erb +0 -30
@@ -1,119 +0,0 @@
1
- require 'fwtoolkit/tasks/helper'
2
-
3
- module FWToolkit
4
- module Tasks
5
- class Frank < Thor
6
-
7
- include Rake::DSL if defined?(Rake::DSL)
8
- include Thor::Actions
9
-
10
- def self.source_root
11
- File.join(File.dirname(__FILE__), '..', '..', '..')
12
- end
13
-
14
- no_tasks do
15
- def install_tasks
16
- namespace :frank do
17
- desc 'Setup Frank'
18
- task :setup, [:target, :prefix] do |t, args|
19
- args.with_defaults(:prefix => '')
20
- setup(args[:target], args[:prefix])
21
- end
22
-
23
- desc 'Create Frank model files from CoreData'
24
- task :model, [:model_file, :prefix] do |t, args|
25
- args.with_defaults(:model_file => nil)
26
- args.with_defaults(:prefix => 'true')
27
- prefix = args[:prefix].eql? 'true'
28
- @no_prefix = !prefix
29
-
30
- # validation step - core_data_model should be of type .xcdatamodel
31
- output_dir = File.join('Frank', 'features', 'support', 'models')
32
- makedirs output_dir unless Dir.exists? output_dir
33
-
34
- model = CoreData::DataModel.new(File.join(args[:model_file], 'contents'))
35
- @models = model.entities
36
-
37
- @models.each do |entity|
38
- @model = entity
39
- @class_name = class_name(@model)
40
- factory_template = File.join 'templates', 'models', 'model.rb.erb'
41
- template(factory_template, File.join(output_dir, "#{class_name(@model).ruby_format}.rb"))
42
- end
43
-
44
- factory_template = File.join 'templates', 'models', 'factories.rb.erb'
45
- template(factory_template, File.join(output_dir, 'factories.rb'))
46
- end
47
-
48
- desc 'Run CI Frank with rerun option'
49
- task :ci_test_rerun_failures do |t|
50
- exception = FWToolkit::Tasks.run_rake_task("frank:ci_test")
51
- exception = FWToolkit::Tasks.run_rake_task("frank:ci_test_rerun") if exception
52
- raise exception if exception
53
- end
54
-
55
- Cucumber::Rake::Task.new(:ci_test, 'Run Frank acceptance tests with CI options') do |t|
56
- ENV['APP_BUNDLE_PATH'] = File.join( Dir.pwd, 'Frank/frankified_build/Frankified.app' )
57
- ENV['USE_SIM_LAUNCHER_SERVER'] = 'YES'
58
- artifacts_dir = FWToolkit::Tasks.cc_artifacts_dir
59
- t.cucumber_opts = "Frank/features --tags ~@wip --format pretty --format html --out '#{artifacts_dir}/frank_results.html' --format rerun --out '#{artifacts_dir}/frank_rerun.txt'"
60
- end
61
-
62
- Cucumber::Rake::Task.new(:ci_test_rerun, 'Run failed Frank acceptance tests with CI options') do |t|
63
- artifacts_dir = FWToolkit::Tasks.cc_artifacts_dir
64
- t.cucumber_opts = "@#{artifacts_dir}/frank_rerun.txt --format pretty --require Frank/features"
65
- end
66
-
67
- desc 'Run Frank acceptance tests'
68
- task :test, :cucumber_options do |t, args|
69
- args.with_defaults(:cucumber_options => 'Frank/features --tag ~@wip')
70
-
71
- ENV['APP_BUNDLE_PATH'] = File.join( Dir.pwd, 'Frank/frankified_build/Frankified.app' )
72
- ENV['USE_SIM_LAUNCHER_SERVER'] = nil
73
- run "cucumber #{args.cucumber_options}"
74
- end
75
-
76
- desc 'Run Frank acceptance tests for a tag'
77
- task :tag, :tag_name do |t, args|
78
- args.with_defaults(:tag_name => '')
79
- cucumber_options = "Frank/features --tag #{args.tag_name}"
80
-
81
- ENV['APP_BUNDLE_PATH'] = File.join( Dir.pwd, 'Frank/frankified_build/Frankified.app' )
82
- ENV['USE_SIM_LAUNCHER_SERVER'] = nil
83
- run "cucumber #{cucumber_options}"
84
- end
85
- end
86
- end
87
-
88
- def class_name(entity)
89
- @no_prefix ? entity.name : entity.name[3..-1]
90
- end
91
-
92
- def setup(target = nil, prefix = nil, project_directory = target, project_file = "#{target}.xcodeproj")
93
- run 'frank setup'
94
- features_dir = File.join('Frank', 'features')
95
- remove_file(File.join(features_dir, 'my_first.feature'))
96
-
97
- if target
98
- test_dir = File.join(FWToolkit::Tasks::BuildTask::TEMPLATES_DIR, 'cucumber')
99
- directory(File.join(FWToolkit::Tasks::BuildTask::TEMPLATES_DIR, 'cucumber', 'features'), features_dir, {:force => true})
100
-
101
- @prefix = prefix
102
- template 'templates/cucumber/AppDelegate+Frank.h.erb', File.join(project_directory, "#{prefix}AppDelegate+Frank.h")
103
- template 'templates/cucumber/AppDelegate+Frank.m.erb', File.join(project_directory, "#{prefix}AppDelegate+Frank.m")
104
-
105
- project = Xcodeproj::Project.new(project_file)
106
- project.new_file(File.join(project_directory, "#{prefix}AppDelegate+Frank.h"), project_directory)
107
- frank_app_d_m = project.new_file(File.join(project_directory, "#{prefix}AppDelegate+Frank.m"), project_directory)
108
-
109
- target = project.targets.select{|t| t.name.eql? target}[0]
110
- target.add_file_references([frank_app_d_m])
111
-
112
- project.save_as(project_file)
113
- end
114
- end
115
- end
116
-
117
- end
118
- end
119
- end
@@ -1,16 +0,0 @@
1
- module FWToolkit
2
- module Tasks
3
- def self.cc_artifacts_dir
4
- ENV['CC_BUILD_ARTIFACTS'] ? ENV['CC_BUILD_ARTIFACTS'] : File.join(Dir.pwd, 'artifacts')
5
- end
6
-
7
- def self.run_rake_task(name)
8
- begin
9
- Rake::Task[name].invoke
10
- rescue Exception => e
11
- return e
12
- end
13
- nil
14
- end
15
- end
16
- end
@@ -1,41 +0,0 @@
1
- module FWToolkit
2
- module Tasks
3
- class Services < Thor
4
-
5
- include Rake::DSL if defined?(Rake::DSL)
6
- include Thor::Actions
7
-
8
- no_tasks do
9
- def install_tasks
10
- namespace :services do
11
-
12
- task :environment do
13
- require 'fwtoolkit'
14
- Dir[File.join( Dir.pwd, 'Frank/features/support/models/*.rb')].each {|file| require file }
15
- Dir[File.join( Dir.pwd, 'Frank/features/support/views/*.rb')].each {|file| require file }
16
- end
17
-
18
- desc 'Seed objects into the service'
19
- task :seed => [:environment] do
20
-
21
- end
22
-
23
- require 'daemons'
24
- desc 'Run a service'
25
- task :run, [:service_name] => [:environment, :seed] do |t, args|
26
- args.with_defaults(:service_name => 'mimic', :seeds_name => nil)
27
-
28
- require File.join( Dir.pwd, "Frank/features/support/#{args.service_name}.rb")
29
- say "Service #{args.service_name} running"
30
- loop do
31
- sleep(5)
32
- end
33
- end
34
-
35
- end
36
- end
37
- end
38
-
39
- end
40
- end
41
- end
@@ -1,24 +0,0 @@
1
- require 'thor'
2
-
3
- require 'fwtoolkit/tasks/build'
4
- require 'fwtoolkit/tasks/cocoapods'
5
- require 'fwtoolkit/tasks/frank'
6
- require 'fwtoolkit/tasks/services'
7
- require 'fwtoolkit/tasks/ci'
8
-
9
- FWToolkit::Tasks::Cocoapods.new.install_tasks
10
- FWToolkit::Tasks::Frank.new.install_tasks
11
- FWToolkit::Tasks::Services.new.install_tasks
12
- FWToolkit::Tasks::CI.new.install_tasks
13
-
14
- # monkey patching string to add the ruby_format method
15
- # used in frank:model tasks
16
- class String
17
- def ruby_format
18
- self.gsub(/(.)([A-Z])/,'\1_\2').downcase
19
- end
20
-
21
- def ruby_format!
22
- replace ruby_format
23
- end
24
- end
@@ -1,120 +0,0 @@
1
- require 'pickle'
2
-
3
- module FWToolkit
4
- module Test
5
- class FrankCache
6
- @@klass_to_objects = {}
7
- @@id_to_object = {}
8
-
9
- def self.clean_up
10
- @@klass_to_objects = {}
11
- @@id_to_object = {}
12
- end
13
-
14
- def self.add_object(object)
15
- object.id = object.object_id
16
-
17
- # add to id to object hash
18
- @@id_to_object[object.object_id.to_s] = object
19
-
20
- # add to klass to object hash
21
- @@klass_to_objects[object.class.name] = [] unless @@klass_to_objects[object.class.name]
22
- @@klass_to_objects[object.class.name] << object
23
- end
24
-
25
- def self.all_objects(klass)
26
- @@klass_to_objects[klass.name] ? @@klass_to_objects[klass.name] : []
27
- end
28
-
29
- def self.find(id)
30
- @@id_to_object[id.to_s]
31
- end
32
-
33
- def self.find_first(klass, conditions)
34
- self.find_all(klass, conditions).first
35
- end
36
-
37
- def self.find_all(klass, conditions)
38
- objects = []
39
- FWToolkit::Test::FrankCache.all_objects(klass).each do |o|
40
- match = true
41
- conditions.keys.each do |k|
42
- value = eval("o.#{k}")
43
- if((value.class.name.eql? "String") and (not value.eql? conditions[k]))
44
- match = false
45
- break
46
- elsif((value.class.name.eql? "Fixnum") and (not value == conditions[k].to_i))
47
- match = false
48
- break
49
- end
50
- end
51
- objects << o if match
52
- end
53
- objects
54
- end
55
- end
56
-
57
- class FrankModel
58
-
59
- attr_accessor :id, :core_data_entity
60
-
61
- module PickleAdapter
62
- include Pickle::Adapter::Base
63
-
64
- # Gets a list of the available models for this adapter
65
- def self.model_classes
66
- klasses = ::FWToolkit::Test::FrankModel.__send__(:descendants)
67
- end
68
-
69
- # get a list of column names for a given class
70
- def self.column_names(klass)
71
- klass.new.methods
72
- end
73
-
74
- # Get an instance by id of the model
75
- def self.get_model(klass, id)
76
- FWToolkit::Test::FrankCache.find(id)
77
- end
78
-
79
- # Find the first instance matching conditions
80
- def self.find_first_model(klass, conditions)
81
- FWToolkit::Test::FrankCache.find_first(klass, conditions)
82
- end
83
-
84
- # Find all models matching conditions
85
- def self.find_all_models(klass, conditions)
86
- FWToolkit::Test::FrankCache.find_all(klass, conditions)
87
- end
88
-
89
- # Create a model using attributes
90
- def self.create_model(klass, attributes)
91
- puts "create_model"
92
- end
93
- end
94
-
95
- def self.object_in_cache(id)
96
- FWToolkit::Test::FrankCache.find(id)
97
- end
98
-
99
- def self.all_objects
100
- FWToolkit::Test::FrankCache.all_objects(self)
101
- end
102
-
103
- def save!
104
- FWToolkit::Test::FrankCache.add_object(self)
105
- end
106
-
107
- def self.find(id)
108
- FWToolkit::Test::FrankCache.find(id)
109
- end
110
-
111
- def self.find_first(conditions={})
112
- FWToolkit::Test::FrankCache.find_first(self, conditions)
113
- end
114
-
115
- def self.find_all(conditions={})
116
- FWToolkit::Test::FrankCache.find_all(self, conditions)
117
- end
118
- end
119
- end
120
- end
@@ -1,9 +0,0 @@
1
- # This file is generated by FWToolkit and is covered by the license at
2
- #
3
- require 'fwtoolkit/test/model_helper'
4
-
5
- Given /^the app is (online|offline)$/ do |val|
6
- online = (val.eql? "online")
7
- fwt_app_exec("setRKObjectManagerIsOnline:", online)
8
- sleep 5
9
- end
@@ -1,94 +0,0 @@
1
- require 'json'
2
- require 'frank-cucumber/gateway'
3
- require 'cfpropertylist'
4
-
5
- module FWToolkit
6
- module Test
7
- module ModelHelpers
8
-
9
- def fwt_app_exec(method_name, *method_args)
10
- operation_map = Frank::Cucumber::Gateway.build_operation_map(method_name,method_args)
11
-
12
- res = frank_server.send_post(
13
- 'app_exec',
14
- :operation => operation_map
15
- )
16
-
17
- return Frank::Cucumber::Gateway.evaluate_frankly_response( res, "app_exec #{method_name}" )
18
- end
19
-
20
- def fwt_simulator_applications_dir
21
- File.join(Dir.home, 'Library', 'Application Support', 'iPhone Simulator', fwt_ios_sdk, 'Applications')
22
- end
23
-
24
- def fwt_kill_simulator
25
- `killall "iPhone Simulator"`
26
- end
27
-
28
- def fwt_simulator_reset_data(sdk)
29
- fwt_kill_simulator
30
- FileUtils.rm_rf(fwt_simulator_applications_dir)
31
- end
32
-
33
- def fwt_launch_app(device='iphone')
34
- launch_app fwt_app_path, fwt_ios_sdk, device
35
- end
36
-
37
- def fwt_ios_sdk
38
- raise "IOS_SDK not defined. Please define this in your env.rb, i.e. IOS_SDK='5.1'" unless defined?(IOS_SDK)
39
- IOS_SDK
40
- end
41
-
42
- def fwt_app_path
43
- ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
44
- end
45
-
46
- def fwt_app_path
47
- raise "APP_BUNDLE_PATH not defined. Please define this in your env.rb, i.e. APP_BUNDLE_PATH='File.expand_path( '../../../frankified_build/Frankified.app', __FILE__ )'" unless defined?(APP_BUNDLE_PATH)
48
- raise "File defined in APP_BUNDLE_PATH (#{APP_BUNDLE_PATH}) does not exist" unless File.exists?(APP_BUNDLE_PATH)
49
- APP_BUNDLE_PATH
50
- end
51
-
52
- def fwt_seed_app(model_names=[])
53
- puts "Deprecated: fwt_seed_app(). Please use fwt_seed_app_with_pickle_models(). Will be changed in 0.6.0 to accept objects."
54
- fwt_seed_app_with_pickle_models(model_names)
55
- end
56
-
57
- def fwt_seed_app_with_pickle_models(model_names=[])
58
- objects = model_names.collect{|n| model!(n)}
59
- fwt_seed_app_with_objects(objects)
60
- end
61
-
62
- def fwt_seed_app_with_objects(objects = [])
63
- fwt_app_exec("seedCoreData:", objects.to_json)
64
- end
65
-
66
- def fwt_set_user_defaults(bundle_identifier, user_defaults)
67
- app_dir = Dir.entries(fwt_simulator_applications_dir)
68
- app_dir.delete "."
69
- app_dir.delete ".."
70
- plist_file = File.join(fwt_simulator_applications_dir, app_dir.first, 'Library', 'Preferences', "#{bundle_identifier}.plist")
71
-
72
- plist = CFPropertyList::List.new(:file => plist_file)
73
- data = CFPropertyList.native_types(plist.value)
74
- data.merge! user_defaults
75
- plist.value = CFPropertyList.guess(data)
76
- plist.save(plist_file, CFPropertyList::List::FORMAT_BINARY)
77
- end
78
- end
79
- end
80
- end
81
- World(FWToolkit::Test::ModelHelpers)
82
-
83
-
84
- # add as_json to Array
85
- class Array
86
- def to_json(*)
87
- contents = ""
88
- self.each_index do |i|
89
- contents << self[i].to_json
90
- contents << ',' unless i == self.length - 1
91
- end
92
- "[#{contents}]"
93
- end
94
- end
@@ -1,60 +0,0 @@
1
- module FWToolkit
2
- module Test
3
- module NetworkHelpers
4
-
5
- #Given /^the network simulates a 3G connection
6
- #ipfw add pipe 1 all from any to any out
7
- #ipfw add pipe 2 all from any to any in
8
- #ipfw pipe 1 config bw 64Kbit/s
9
- #ipfw pipe 2 config bw 128Kbit/s
10
-
11
- def ipfw_reset_rule_number
12
- @@ipfw_rule_number = 1
13
- end
14
-
15
- def ipfw_exit_unless_clean
16
- ipfw_list = `sudo ipfw list`
17
- if ipfw_list =~ /^(?!65535 allow ip from any to any$).*/
18
- puts 'The firewall table contains rules other than the default. Run `sudo ipfw flush` before rerunning cucumber if you don\'t need these rules.'
19
- exit -1
20
- end
21
- end
22
-
23
- def ipfw_deny(host='localhost')
24
- `sudo ipfw add #{@@ipfw_rule_number} deny tcp from any to #{host}`
25
- @@ipfw_rule_number += 1
26
- end
27
-
28
- def ipfw_flush
29
- `sudo ipfw flush`
30
- end
31
- end
32
- end
33
- end
34
- World(FWToolkit::Test::NetworkHelpers)
35
-
36
- # Check IPFW because we flush firewall rules at the end of each scenario
37
- # If we have anything but the default rule, warn the user and exit
38
- Before do
39
- ipfw_exit_unless_clean
40
- ipfw_reset_rule_number
41
- end
42
-
43
- After do
44
- ipfw_flush
45
- end
46
-
47
- #
48
- # Steps
49
- #
50
- Given /^the network has no connection$/ do
51
- ipfw_deny
52
- end
53
-
54
- Then /^the network is returned to its original state$/ do
55
- ipfw_flush
56
- end
57
-
58
-
59
-
60
-
@@ -1,101 +0,0 @@
1
- # this file generated by script/generate pickle
2
- require 'pickle/world'
3
-
4
- # create a model
5
- Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
6
- create_model(name, fields)
7
- end
8
-
9
- # create n models
10
- Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
11
- count.to_i.times { create_model(plural_factory.singularize, fields) }
12
- end
13
-
14
- # create models from a table
15
- Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
16
- create_models_from_table(plural_factory, table)
17
- end
18
-
19
- # find a model
20
- Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
21
- find_model!(name, fields)
22
- end
23
-
24
- # not find a model
25
- Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
26
- find_model(name, fields).should be_nil
27
- end
28
-
29
- # find models with a table
30
- Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
31
- find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
32
- end
33
-
34
- # find exactly n models
35
- Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
36
- find_models(plural_factory.singularize, fields).size.should == count.to_i
37
- end
38
-
39
- # assert equality of models
40
- Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
41
- model!(a).should == model!(b)
42
- end
43
-
44
- # assert model is in another model's has_many assoc
45
- Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
46
- model!(owner).send(association).should include(model!(target))
47
- end
48
-
49
- # assert model is not in another model's has_many assoc
50
- Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
51
- model!(owner).send(association).should_not include(model!(target))
52
- end
53
-
54
- # assert model is another model's has_one/belongs_to assoc
55
- Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
56
- model!(owner).send(association).should == model!(target)
57
- end
58
-
59
- # assert model is not another model's has_one/belongs_to assoc
60
- Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
61
- model!(owner).send(association).should_not == model!(target)
62
- end
63
-
64
- # assert model.predicate?
65
- Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
66
- if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
67
- model!(name).should send("have_#{predicate.gsub(' ', '_')}")
68
- else
69
- model!(name).should send("be_#{predicate.gsub(' ', '_')}")
70
- end
71
- end
72
-
73
- # assert not model.predicate?
74
- Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
75
- if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
76
- model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
77
- else
78
- model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
79
- end
80
- end
81
-
82
- # model.attribute.should eql(value)
83
- # model.attribute.should_not eql(value)
84
- Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
85
- actual_value = model(name).send(attribute)
86
- expectation = expectation.gsub(' ', '_')
87
-
88
- case expected
89
- when 'nil', 'true', 'false'
90
- actual_value.send(expectation, send("be_#{expected}"))
91
- when /^[+-]?[0-9_]+(\.\d+)?$/
92
- actual_value.send(expectation, eql(expected.to_f))
93
- else
94
- actual_value.to_s.send(expectation, eql(eval(expected)))
95
- end
96
- end
97
-
98
- # assert size of association
99
- Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
100
- model!(name).send(association).size.should == size.to_i
101
- end
@@ -1,21 +0,0 @@
1
- Around('~@slow') do |scenario, block|
2
- timeout_seconds = 300
3
- begin
4
- Timeout.timeout(timeout_seconds) do
5
- block.call
6
- end
7
- rescue Timeout::Error
8
- puts "Your test was killed after #{timeout_seconds}"
9
- end
10
- end
11
-
12
- Around('@slow') do |scenario, block|
13
- timeout_seconds = 1200
14
- begin
15
- Timeout.timeout(timeout_seconds) do
16
- block.call
17
- end
18
- rescue Timeout::Error
19
- puts "Your slow test was killed after #{timeout_seconds}"
20
- end
21
- end
@@ -1,19 +0,0 @@
1
- module FWToolkit
2
- module Test
3
- module UIHelpers
4
- def fwt_set_textfield_text(text_field_mark, text_to_type)
5
- text_field_selector = "textField marked:'#{text_field_mark}'"
6
- if element_exists(text_field_selector)
7
- touch( text_field_selector )
8
- else
9
- raise "Could not find [#{text_field_mark}], it does not exist."
10
- end
11
-
12
- frankly_map( text_field_selector, 'becomeFirstResponder' )
13
- frankly_map( text_field_selector, 'setText:', text_to_type )
14
- frankly_map( text_field_selector, 'endEditing:', true )
15
- end
16
- end
17
- end
18
- end
19
- World(FWToolkit::Test::UIHelpers)
@@ -1,17 +0,0 @@
1
- # This file is generated by FWToolkit and is covered by the license at
2
- #
3
-
4
- require 'fwtoolkit/test/ui_helper.rb'
5
-
6
- When /^I touch the "(.*?)" button on the alert view$/ do |arg1|
7
- touch("view:'UIAlertButton' marked:'#{arg1}'")
8
- end
9
-
10
- When /^I type "([^\"]*)"$/ do |cmd|
11
- type_into_keyboard(cmd, :append_return => false)
12
- end
13
-
14
- Then /^"([^\"]*)" is disabled$/ do |mark|
15
- raise "#{mark} is not disabled" unless frankly_map("view marked:'#{mark}'", 'isEnabled')
16
- end
17
-
@@ -1,15 +0,0 @@
1
- //
2
- // <%= @prefix %>AppDelegate+Frank.h
3
- // FWToolkit
4
- //
5
- // Created by Matt Brooke-Smith on 14/10/2012.
6
- // Copyright (c) 2012 Future Workshops. All rights reserved.
7
- //
8
-
9
- #import "<%= @prefix %>AppDelegate.h"
10
-
11
- @interface <%= @prefix %>AppDelegate (Frank)
12
-
13
- - (void) seedCoreData:(NSString *)json;
14
-
15
- @end
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'fwtoolkit'
@@ -1,4 +0,0 @@
1
- platform :ios, '6.0'
2
-
3
- pod 'RestKit/ObjectMapping', '0.10.3.fw.2'
4
- pod 'RestKit/Network', '0.10.3.fw.2'