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
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTM2YjFiMzYyNjc4ZWM3MTVlMzEyODEwNGNhNTljNGQ0NTNlZjQ4Mg==
4
+ ODNiNTM1NjE3MTcyODA2OGZlNTIyYjg1YzdkMDcxMjZkMGJhZjZmNg==
5
5
  data.tar.gz: !binary |-
6
- OWU2NGNhNzgyYWYwOGZmYjg5YTE1M2E2NGQxMjc5ZDEzNjU5N2MwZg==
6
+ NWY2OGQyMjI5YjdiMDg1NjQ2NGU3ZjUzOWYwZWEwZjA2ZGUyMmY2Zg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODI2YWRhYjhiZjg1NmFhYThkMGQ1ZmU3M2RiZjNjMTUxNTJkMmYxYWZmNjZi
10
- ZTJiMTJlOWI3NDY5OTQ3MWNlZjA5ZjMyM2U1Y2M2MjQ0OTUxZWNjOTkxMTIw
11
- NGU2OGU5MmUwYTQ1MTgzOGJjNDdiOTdhZmY0MDc3MzU4YjY4YjQ=
9
+ NzEyNTRkZmM4NGIxMmNlODcxNmU4MTBlNjU0ZjU5ZDg0M2UwM2E4Yzc3MjQx
10
+ ZWMzNzJiZTdkZWQwNDhlY2ZiY2EzMDc1YzE0ZTgzZjE4ZmJlYWYzMTc3Yzdm
11
+ YWNhNzAwYzY4MmM3MmVjNzNlNzFjMzI5ZDNhYmRiYTMzMmMxOGU=
12
12
  data.tar.gz: !binary |-
13
- MWFmZGRlYTAzNTdjMjg3ZWM2MDQyZTM2NzUzM2I4M2I4ZjE0NGU4YmQ5MTM1
14
- N2FlMTg4OGEzMDhlMWU0MTA2NzcyMjcwMDFkNzFmZTlmZGU5MTU3NjUyYjdk
15
- YTJiMjZjZDNjMDU3Nzg0Mzc4ZGY5NWZkZGJkNjE4YzhmY2ZkMTU=
13
+ YjRiNTZkN2JhMDlkNGE4MWI4Y2U0NWE3OTgxMDdhM2VkYTk0ZThiMTdhZTVm
14
+ NGIwY2EzNTRlZTNjMWRmNjU1NTI3Nzc3MzBhODI1MWVlM2M2YWJiMjNiOWNm
15
+ OTJkZGNjOTJhZWRhMGQ0MTc4ODQ1YmUzZDJkZWExNTUwY2RhODg=
data/bin/fwt CHANGED
@@ -1,115 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'thor'
3
- require 'xcodeproj'
4
- require 'erb'
5
2
 
6
- class FWT < Thor
7
-
8
- include Thor::Actions
9
-
10
- def self.source_root
11
- File.join(File.dirname(__FILE__), '..')
12
- end
13
-
14
- desc "new APP_PATH PREFIX", "Creates a new Future Workshops iOS project"
15
- def new(app_path, prefix)
16
-
17
- setup_cocoapods
18
-
19
- @app_name = File.basename(app_path)
20
- @prefix = prefix.upcase
21
- @path = app_path
22
- supporting_files = 'Supporting Files'
23
-
24
- @project = Xcodeproj::Project.new
25
- @project.root_object.build_configuration_list
3
+ require 'fwtoolkit'
26
4
 
27
- info_plist = "#{@app_name}-Info.plist"
28
- process_template("Info.plist.erb", info_plist, supporting_files)
29
-
30
- target = @project.new_target(:application, @app_name, :ios)
31
-
32
- add_system_framework('UIKit')
33
- add_system_framework('CoreGraphics')
34
-
35
- add_build_settings_to_target({
36
- 'INFOPLIST_FILE' => "$(SRCROOT)/#{@app_name}/#{@app_name}-Info.plist",
37
- 'GCC_PREFIX_HEADER' => "#{@app_name}/#{@app_name}-Prefix.pch",
38
- 'SKIP_INSTALL' => 'NO',
39
- 'IPHONEOS_DEPLOYMENT_TARGET' => '6.0',
40
- }, target)
41
-
42
- app_d_h = process_template("AppDelegate.h.erb", "#{@prefix}AppDelegate.h")
43
- app_d_m = process_template("AppDelegate.m.erb", "#{@prefix}AppDelegate.m")
44
- main_m = process_template("main.m.erb", "main.m", supporting_files)
45
- prefix_pch = process_template("Prefix.pch.erb", "#{@app_name}-Prefix.pch", supporting_files)
46
-
47
- target.add_file_references([app_d_m, main_m])
48
-
49
- # final save
50
- @project.save_as File.join(@path, "#{@app_name}.xcodeproj")
51
- @workspace = Xcodeproj::Workspace.new("#{@app_name}.xcodeproj")
52
- @workspace.save_as File.join(@path, "#{@app_name}.xcworkspace")
53
-
54
- # Ruby
55
- template 'templates/fwt/rvmrc.erb', File.join(@path, '.rvmrc')
56
- template 'templates/fwt/Gemfile.erb', File.join(@path, 'Gemfile')
57
- template 'templates/fwt/Rakefile.erb', File.join(@path, 'Rakefile')
58
- template 'templates/fwt/Podfile.erb', File.join(@path, 'Podfile')
59
- template 'templates/fwt/gitignore.erb', File.join(@path, '.gitignore')
60
-
61
- sleep 2 # flushing issues?
62
-
63
- inside(@path) do
64
- run "rvm gemset create #{@app_name}", {:capture => true}
65
- run "rvm gemset use #{@app_name}", {:capture => true}
66
- run 'bundle', {:capture => true}
67
- #run 'rake pod:clean_install', {:capture => true}
68
- run "rake frank:setup['#{@app_name}','#{@prefix}']", {:capture => true}
69
- end
70
- end
71
-
72
- private
73
- def add_build_settings_to_target(map, target)
74
- target.build_settings('Debug').merge! map
75
- target.build_settings('Release').merge! map
76
- end
77
-
78
- def add_system_framework(name)
79
- framework = @project.add_system_framework(name)
80
- target = @project.targets.first
81
- build_phase = target.frameworks_build_phase
82
- build_phase.add_file_reference framework
83
- end
84
-
85
- def setup_cocoapods
86
- unless Dir.exists?(File.join(Dir.home, '.cocoapods', 'fw'))
87
- run 'gem install cocoapods', {:capture => true}
88
- run 'pod repo add fw git@github.com:FutureWorkshops/FWTPodspecs.git', {:capture => true}
89
- end
90
- end
91
-
92
- def process_template(template_filename, destination_filename, destination_group = "", template_project = 'default_project')
93
- template "templates/fwt/#{template_project}/#{template_filename}", File.join(@path, @app_name, destination_filename)
94
- @project.new_file(File.join(@app_name, destination_filename), File.join(@app_name, destination_group))
95
- end
96
-
97
- end
98
-
99
- module Xcodeproj
100
- class Project
101
- def add_system_framework(name)
102
- path = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/#{name}.framework"
103
- if file = frameworks_group.files.select { |f| f.path == path }.first
104
- file
105
- else
106
- framework_ref = frameworks_group.new_file(path)
107
- framework_ref.name = "#{name}.framework"
108
- framework_ref.source_tree = 'SDKROOT'
109
- framework_ref
110
- end
111
- end
112
- end
113
- end
114
-
115
- FWT.start
5
+ FWToolkit::CLI.start(ARGV)
@@ -0,0 +1,60 @@
1
+ Feature: Installing cocoapods
2
+ As a lead developer
3
+ In order to work with cocoapods in my project
4
+ I want my system to be configured correctly
5
+
6
+ @slow @pods
7
+ Scenario: Install and configure cocoapods for a user without cocoapods installed
8
+ Given I'm using a clean gemset "fwtoolkit_test" containing fwtoolkit.gem
9
+ And I'm using a clean home directory
10
+ And I force aruba-double path-hijacking
11
+ And I double `pod`
12
+ And I double `sudo`
13
+ And I double `git`
14
+ When I successfully run `fwt pods setup`
15
+ Then the double `sudo gem install cocoapods` should have been run
16
+ And a directory named "homedir/.cocoapods/fw" should exist
17
+
18
+ @slow @pods
19
+ Scenario: Configure fw's cocoapods for a user that has cocoapods already installed
20
+ Given I'm using a clean gemset "fwtoolkit_test" containing fwtoolkit.gem
21
+ And I'm using a clean home directory
22
+ And I force aruba-double path-hijacking
23
+ And I double the gem "cocoapods"
24
+ And I double `pod`
25
+ And I double `sudo`
26
+ When I successfully run `fwt pods setup`
27
+ Then the stdout should contain:
28
+ """
29
+ Cocoapods is already installed
30
+ """
31
+ And a directory named "homedir/.cocoapods/fw" should exist
32
+
33
+ @slow @pods
34
+ Scenario: Configure fw's cocoapods for a user that has messed up his/her installation
35
+ Given I'm using a clean gemset "fwtoolkit_test" containing fwtoolkit.gem
36
+ And I'm using a clean home directory
37
+ And a directory named ".cocoapods/fw" inside the home directory
38
+ And I force aruba-double path-hijacking
39
+ And I double `gem`
40
+ And I double `sudo`
41
+ When I successfully run `fwt pods setup`
42
+ Then the double `sudo gem install cocoapods` should have been run
43
+ And the stdout should contain:
44
+ """
45
+ FW's podspec repository already installed
46
+ """
47
+
48
+ @slow @pods
49
+ Scenario: Configure a project with Cocoapods
50
+ Given a directory named "MyProject"
51
+ And I double `bundle`
52
+ And I cd to "MyProject"
53
+ And an empty file named "Gemfile"
54
+ And I cd to ".."
55
+ When I successfully run `fwt pods install MyProject`
56
+ Then the file "MyProject/Gemfile" should contain:
57
+ """
58
+ gem "Cocoapods"
59
+ """
60
+ And the double `bundle exec pod install` should have been run
@@ -0,0 +1,20 @@
1
+ Feature: Create frank model from core data
2
+ As a lead developer working on a project
3
+ I want to generate ruby classes that mirror my CoreData model
4
+ So I can refer to core data entities from my Frank tests
5
+
6
+ Background:
7
+ Given a configured installation of FWToolkit for "Tom the Dev" working for "Awesome Company"
8
+
9
+ @frank
10
+ Scenario: generate ruby model from CoreData
11
+ Given an initialized FW iOS project named "MyProject"
12
+ And the project "MyProject" contains a valid CoreData model
13
+ When I run `fwt test model MyProject`
14
+ Then I cd to "MyProject"
15
+ And the following files should exist:
16
+ | MyProject/Frank/features/support/views/my_objects_json.erb |
17
+ | MyProject/Frank/features/support/views/my_objects_xml.erb |
18
+ | MyProject/Frank/features/support/models/factories.rb |
19
+ | MyProject/Frank/features/support/models/Ent1.rb |
20
+ | MyProject/Frank/features/support/models/Ent2.rb |
@@ -0,0 +1,28 @@
1
+ Feature: Frankifie a project
2
+ As a lead developer working on a project
3
+ I want a quick way to set up my project with frank
4
+ So I can add BDD tests to it
5
+
6
+ Background:
7
+ Given a configured installation of FWToolkit for "Tom the Dev" working for "Awesome Company"
8
+
9
+ @frank @no-clobber @test @announce
10
+ Scenario: setup an existing project
11
+ Given an initialized FW iOS project named "MyProject"
12
+ When I successfully run `fwt test setup MyProject`
13
+ Then I cd to "MyProject"
14
+ And the following files should exist:
15
+ | MyProject/MyProject/AAAAppDelegate+Frank.h |
16
+ | MyProject/MyProject/AAAAppDelegate+Frank.m |
17
+ | MyProject/Frank/Features/step_definitions/launch_steps.rb |
18
+ | MyProject/Frank/Features/support/env.rb |
19
+ | MyProject/Frank/Features/support/mimic.rb |
20
+
21
+
22
+ @frank @slom
23
+ Scenario: try to setup a project that already has frank
24
+ Given an initialized FW iOS project named "MyProject"
25
+ And I successfully run `fwt test setup MyProject`
26
+ When I run `fwt test setup MyProject`
27
+ Then the output should contain "Frank is already set up for the project"
28
+
@@ -0,0 +1,29 @@
1
+ Feature: Create a git repo
2
+ As a lead devepoer
3
+ In order to work on my new project
4
+ I want my project folder to contain a git repo correctly initialised
5
+
6
+ @announce
7
+ Scenario: Create a new git repo on a folder with just a .gitignore
8
+ Given a directory named "my_project"
9
+ When I successfully run `fwt git new my_project`
10
+ Then an initialized git repository should exists inside a directory named "my_project"
11
+ And a file named "my_project/.gitignore" should exist
12
+
13
+ Scenario: Fail to create a git repo because one exists already
14
+ Given a directory named "my_project"
15
+ Given an initialized git repository inside a directory named "my_project"
16
+ Given a valid .gitignore file exists inside a directory named "my_project"
17
+ When I run `fwt git new my_project`
18
+ Then the stderr should contain:
19
+ """
20
+ There's already a repository at path
21
+ """
22
+ @slow
23
+ Scenario: Create a git repository on a folder with files in it
24
+ Given a directory named "my_project"
25
+ Given a valid .gitignore file exists inside a directory named "my_project"
26
+ Given the directory "my_project" contains an uncommitted file named "my_file.c"
27
+ When I successfully run `fwt git new my_project`
28
+ Then an initialized git repository should exists inside a directory named "my_project"
29
+ And the file named "my_file.c" should have been committed to the repository at path "my_project"
@@ -0,0 +1,25 @@
1
+ Feature: Create a new FW's project
2
+ As a lead developer
3
+ I want to use fwt to create a new project
4
+ So that the project folder has everything I need in terms of rvm/ci/xcode settings
5
+
6
+ Background:
7
+ Given a configured installation of FWToolkit for "Tom the Dev" working for "Awesome Company"
8
+
9
+ @announce
10
+ @wip @slow
11
+ Scenario: Create a new project
12
+ Given I'm using a clean gemset "fwtoolkit_test" containing fwtoolkit.gem
13
+ #Creating the xcode project it's been done on xcode.feature
14
+ And I double `bundle`
15
+ And I double `rvm`
16
+ And I double `gem`
17
+ And I double `pod`
18
+ When I run `fwt proj new MyProject AAA` interactively
19
+ And I wait for output to contain "I found more than one target in this project. Which is the main app target that you wish to Frankify"
20
+ And I type "1"
21
+ Then the following files should exist:
22
+ | MyProject/Podfile |
23
+ And the double `pod install` should have been run
24
+ And the double `rvm 1.9.3 do rvm --rvmrc --create ruby-1.9.3@MyProject` should have been run
25
+
@@ -0,0 +1,11 @@
1
+ require 'aruba-doubles'
2
+
3
+ World(Aruba::Api)
4
+
5
+ Given /^I force aruba-double path-hijacking$/ do
6
+ ArubaDoubles::Double.setup
7
+ end
8
+
9
+ Given /^I double the gem "([^"]*)"$/ do |gem_name|
10
+ install_fake_gem gem_name
11
+ end
@@ -0,0 +1,30 @@
1
+ require 'fwtoolkit/git_client'
2
+ require 'aruba/api'
3
+
4
+ Then /^the file named "([^"]*)" should have been committed to the repository at path "([^"]*)"$/ do |file, repo_path|
5
+ repo = GitClient::Repository.new(File.join(current_dir, repo_path))
6
+ status = repo.status
7
+ if status == nil
8
+ status.should be_nil
9
+ else
10
+ repo.status.values.any?{ |v| v.include?(file).should be_false }
11
+ end
12
+ end
13
+
14
+ Then /^an initialized git repository should exists inside a directory named "([^"]*)"$/ do |repo_path|
15
+ repo = GitClient::Repository.new(File.join(current_dir, repo_path))
16
+ repo.initialized?
17
+ end
18
+
19
+ Given /^an initialized git repository inside a directory named "([^"]*)"$/ do |repo_path|
20
+ repo = GitClient::Repository.new(File.join(current_dir, repo_path))
21
+ repo.init
22
+ end
23
+
24
+ Given /^a valid \.gitignore file exists inside a directory named "([^"]*)"$/ do |repo_path|
25
+ write_file File.join(repo_path, '.gitignore'), ".DB_Store\ntemp\ntmp"
26
+ end
27
+
28
+ Given /^the directory "([^"]*)" contains an uncommitted file named "([^"]*)"$/ do |repo_path, file_name|
29
+ write_file File.join(repo_path, file_name), ".DB_Store\ntemp\ntmp"
30
+ end
@@ -0,0 +1,50 @@
1
+ require 'aruba'
2
+
3
+ Given /^a configured installation of FWToolkit for "([^"]*)" working for "([^"]*)"$/ do |dev_name, company_name|
4
+ steps %Q{
5
+ Given I'm using a clean home directory
6
+ }
7
+ steps %Q{
8
+ And a directory named ".fwtoolkit" inside the home directory
9
+ And a file named "#{File.join(Dir.home, '.fwtoolkit', 'config')}" with:
10
+ """
11
+ developer_name: "#{dev_name}"
12
+ organization_name: "#{company_name}"
13
+ """
14
+ }
15
+ end
16
+
17
+ Given /^an initialized FW iOS project named "([^"]*)"$/ do |proj_name|
18
+ steps %Q{
19
+ Given I successfully run `fwt xcode new #{proj_name} AAA`
20
+ }
21
+ end
22
+
23
+ Given /^the project "([^"]*)" contains a valid CoreData model$/ do |proj_name|
24
+ steps %Q{
25
+ Given I cd to "#{proj_name}/#{proj_name}"
26
+ And a directory named "Model.xcdatamodeld"
27
+ And I cd to "Model.xcdatamodeld"
28
+ And a directory named "Model.xcdatamodel"
29
+ And I cd to "Model.xcdatamodel"
30
+ And a file named "contents" with:
31
+ """
32
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
33
+ <model name="" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1811" systemVersion="12D78" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
34
+ <entity name="AAAEnt1" syncable="YES">
35
+ <attribute name="attribute" optional="YES" attributeType="Float" defaultValueString="0.0" syncable="YES"/>
36
+ <relationship name="relationship" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="AAAEnt2" inverseName="relationship" inverseEntity="Ent2" syncable="YES"/>
37
+ </entity>
38
+ <entity name="AAAEnt2" syncable="YES">
39
+ <attribute name="attribute" optional="YES" attributeType="String" syncable="YES"/>
40
+ <relationship name="relationship" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="AAAEnt1" inverseName="relationship" inverseEntity="Ent1" syncable="YES"/>
41
+ </entity>
42
+ <elements>
43
+ <element name="AAAEnt1" positionX="160" positionY="192" width="128" height="75"/>
44
+ <element name="AAAEnt2" positionX="160" positionY="192" width="128" height="75"/>
45
+ </elements>
46
+ </model>
47
+ """
48
+ And I cd to "../../../.."
49
+ }
50
+ end
@@ -0,0 +1,11 @@
1
+ require 'aruba/api'
2
+ require 'aruba-doubles'
3
+
4
+ Given /^I'm using a clean gemset "([^"]*)" containing fwtoolkit.gem$/ do |gemset|
5
+ use_clean_gemset(gemset)
6
+ # Copying over the bundle generated cache to avoid failing a test for a network timeout
7
+ FileUtils.cp_r 'vendor/cache', File.join(ENV['GEM_HOME'], 'cache')
8
+ run_simple("sh -c 'cd ../..; gem build ./fwtoolkit.gemspec; gem install --no-ri --no-rdoc fwtoolkit-*.gem; rm fwtoolkit-*.gem'")
9
+ end
10
+
11
+
@@ -0,0 +1,8 @@
1
+
2
+ Given /^I'm using a clean home directory$/ do
3
+ create_fake_home 'homedir'
4
+ end
5
+
6
+ Given /^a directory named "([^"]*)" inside the home directory$/ do |subdir|
7
+ FileUtils.mkdir_p File.join(Dir.home, subdir)
8
+ end
@@ -0,0 +1,23 @@
1
+ require 'aruba/cucumber'
2
+ require 'aruba-doubles/cucumber'
3
+
4
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
5
+
6
+ lib_test_dir = File.join File.dirname(__FILE__), 'lib_test'
7
+ $LOAD_PATH.unshift(lib_test_dir) unless $LOAD_PATH.include?(lib_test_dir)
8
+
9
+ Before('@slow') do
10
+ @aruba_timeout_seconds = 60
11
+ end
12
+
13
+ #Before('@fake_fs') do
14
+ #FakeFS::FileSystem.clone "~/.rvm"
15
+ #FakeFS::FileSystem.clone '/tmp'
16
+ #FakeFS::FileSystem.clone "."
17
+ #FakeFS.activate!
18
+ #end
19
+
20
+ #After('@fake_fs') do
21
+ #FakeFS::FileSystem.clear
22
+ #FakeFS.deactivate!
23
+ #end
@@ -0,0 +1,30 @@
1
+ require 'fake_gem'
2
+
3
+ module Aruba
4
+ module Api
5
+ def create_fake_home(dir_name)
6
+ @@__arubafw_original_home = ENV["HOME"]
7
+ home_dir = File.expand_path File.join("tmp", "aruba", dir_name)
8
+ ENV["HOME"] = home_dir
9
+ FileUtils.mkdir_p home_dir
10
+ end
11
+
12
+ def restore_original_home
13
+ unless (defined?(@@__arubafw_original_home).nil? || @@__arubafw_original_home.nil?)
14
+ ENV['HOME'] = @@__arubafw_original_home
15
+ @@__arubafw_original_home = nil
16
+ end
17
+ end
18
+
19
+ def install_fake_gem(gem_name)
20
+ FakeGem.new(gem_name).install
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ World(Aruba::Api)
27
+
28
+ After do
29
+ restore_original_home
30
+ end
@@ -0,0 +1,28 @@
1
+ require 'aruba/api'
2
+
3
+ module Aruba
4
+ module Api
5
+ # The original version installs bundle and doesn't check if the gemset is clean, so we can't use it
6
+ alias_method :orig_use_clean_gemset, :use_clean_gemset unless method_defined?(:orig_use_clean_gemset)
7
+
8
+ def use_clean_gemset(gemset)
9
+ unset_bundler_env_vars
10
+ # orig_use_clean_gemset gemset
11
+ run_simple(%{rvm gemset create "#{gemset}"}, true)
12
+ if all_stdout =~ /'#{gemset}' gemset created \((.*)\)\./
13
+ gem_home = $1
14
+ set_env('GEM_HOME', gem_home)
15
+ set_env('GEM_PATH', gem_home)
16
+ set_env('BUNDLE_PATH', gem_home)
17
+
18
+ paths = (ENV['PATH'] || "").split(File::PATH_SEPARATOR)
19
+ paths.unshift(File.join(gem_home, 'bin'))
20
+ set_env('PATH', paths.uniq.join(File::PATH_SEPARATOR))
21
+ else
22
+ raise "I didn't understand rvm's output: #{all_stdout}"
23
+ end
24
+
25
+ run_simple(%{rvm --force gemset empty "#{gemset}"}, true)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ require "fileutils"
2
+ require "tmpdir"
3
+ require "rubygems/installer"
4
+
5
+ class FakeGem
6
+ DEFAULT_VERSION = "99.0.0"
7
+
8
+ include Gem::UserInteraction
9
+
10
+ def initialize(name, options={})
11
+ @name = name
12
+ @options = {:install_dir => Gem.dir}.merge(options)
13
+ @version = options.delete(:version) || DEFAULT_VERSION
14
+ end
15
+
16
+ def install
17
+ temp_path = File.join(Dir.tmpdir, "fakegem.#{Process.pid}")
18
+ FileUtils.mkdir_p(temp_path)
19
+ Dir.chdir(temp_path) do
20
+ build_gem
21
+ Gem::Installer.new(specification.file_name, @options).install
22
+ end
23
+ say "Fake gem #@name #@version is now installed"
24
+ end
25
+
26
+ private
27
+ def specification
28
+ @specification ||= Gem::Specification.new{ |s|
29
+ s.name = @name
30
+ s.version = @version
31
+ s.summary = "Fake #@name gem"
32
+ s.author = "Nobody"
33
+ s.email = "nobody@localhost"
34
+ s.description = "Fake gem"
35
+ s.homepage = "http://website.com"
36
+ s.has_rdoc = false
37
+ s.files = []
38
+ s.executables = []
39
+ s.require_paths = ["lib"]
40
+ }
41
+ end
42
+
43
+ def build_gem
44
+ FileUtils.mkdir_p("lib")
45
+ Gem::Builder.new(specification).build
46
+ end
47
+ end
@@ -0,0 +1,42 @@
1
+ Feature: Create new project
2
+ As a lead developer
3
+ I want to use fwt to create a new Xcode project
4
+ So that the structure of the project is compliant with FW's standards
5
+
6
+ Background:
7
+ Given a configured installation of FWToolkit for "Tom the Dev" working for "Awesome Company"
8
+
9
+ @xcode
10
+ Scenario: Create a new project
11
+ When I successfully run `fwt xcode new MyProject AAA`
12
+ Then I cd to "MyProject"
13
+ And the following directories should exist:
14
+ | MyProject.xcworkspace |
15
+ | MyProject/MyProject.xcodeproj |
16
+ | MyProject/MyProject/Supporting Files/Settings.bundle |
17
+ | MyProject/Myproject/Supporting Files/en.lproj |
18
+ | MyProject/MyprojectTests/Supporting Files/en.lproj |
19
+ And the following files should exist:
20
+ | MyProject/MyProject/AAAAppDelegate.h |
21
+ | MyProject/MyProject/AAAAppDelegate.m |
22
+ | MyProject/MyProject/Supporting Files/MyProject-Info.plist |
23
+ | MyProject/MyProject/Supporting Files/MyProject-Prefix.pch |
24
+ | MyProject/MyProject/Supporting Files/fw-shared.xcconfig |
25
+ | MyProject/MyProject/Supporting Files/main.m |
26
+ | MyProject/MyProject/Supporting Files/version.sh |
27
+ | MyProject/MyProjectTests/Supporting Files/MyProjectTests-Info.plist |
28
+ | MyProject/MyProjectTests/MyProjectTests.h |
29
+ | MyProject/MyProjectTests/MyProjectTests.m |
30
+ | MyProject/Resources/Default.png |
31
+ | MyProject/Resources/Default@2x.png |
32
+ | MyProject/Resources/Default-568h@2x.png |
33
+ And I successfully run `xcodebuild -scheme MyProject -workspace MyProject.xcworkspace -sdk iphonesimulator6.0`
34
+
35
+ @xcode
36
+ Scenario: Fails to create a new project is the project dir is not empty
37
+ Given a directory named "MyProject"
38
+ When I run `fwt xcode new MyProject AAA`
39
+ Then the stderr should contain:
40
+ """
41
+ Can't create the project. The directory
42
+ """