suspenders 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- suspenders (1.0.0)
4
+ suspenders (1.0.1)
5
5
  bundler (>= 1.1)
6
+ hub (~> 1.10.2)
6
7
  rails (= 3.2.6)
7
8
 
8
9
  GEM
@@ -56,6 +57,7 @@ GEM
56
57
  gherkin (2.9.3)
57
58
  json (>= 1.4.6)
58
59
  hike (1.2.1)
60
+ hub (1.10.2)
59
61
  i18n (0.6.0)
60
62
  journey (1.0.4)
61
63
  json (1.6.6)
data/NEWS.md CHANGED
@@ -1,3 +1,10 @@
1
+ 1.1.0 (August 3, 2012)
2
+
3
+ * Add --github option.
4
+ * Add --webkit option.
5
+ * Remove cruft when generating controllers.
6
+ * Add Spork and Guard.
7
+
1
8
  1.0.1 (August 2, 2012)
2
9
 
3
10
  * Fix broken install on Ruby 1.8.
data/README.md CHANGED
@@ -27,29 +27,27 @@ which will be appended to the default generated projectname/Gemfile.
27
27
 
28
28
  It includes application gems like:
29
29
 
30
- * [Paperclip](https://github.com/thoughtbot/paperclip) for file uploads
31
- * [Formtastic](https://github.com/justinfrench/formtastic) for better forms
32
30
  * [Airbrake](https://github.com/airbrake/airbrake) for exception notification
33
- * [Flutie](https://github.com/thoughtbot/flutie) for default CSS styles
34
31
  * [Bourbon](https://github.com/thoughtbot/bourbon) for classy sass mixins
35
32
  * [Clearance](https://github.com/thoughtbot/clearance) for authentication
33
+ * [Flutie](https://github.com/thoughtbot/flutie) for default CSS styles
34
+ * [Formtastic](https://github.com/justinfrench/formtastic) for better forms
35
+ * [Paperclip](https://github.com/thoughtbot/paperclip) for file uploads
36
36
 
37
37
  And testing gems like:
38
38
 
39
+ * [Bourne](https://github.com/thoughtbot/bourne) and Mocha for stubbing and spying
39
40
  * [Cucumber, Capybara, and Capybara Webkit](http://robots.thoughtbot.com/post/4583605733/capybara-webkit) for integration testing, including Javascript behavior
40
- * [RSpec](https://github.com/rspec/rspec) for awesome, readable isolation testing
41
41
  * [Factory Girl](https://github.com/thoughtbot/factory_girl) for easier creation of test data
42
+ * [RSpec](https://github.com/rspec/rspec) for awesome, readable isolation testing
42
43
  * [Shoulda Matchers](http://github.com/thoughtbot/shoulda-matchers) for frequently needed Rails and RSpec matchers
43
44
  * [Timecop](https://github.com/jtrupiano/timecop) for dealing with time
44
- * [Bourne](https://github.com/thoughtbot/bourne) and Mocha for stubbing and spying
45
- * [email_spec](https://github.com/bmabey/email-spec) for testing emails.
46
45
 
47
46
  Other goodies
48
47
  -------------
49
48
 
50
49
  Suspenders also comes with:
51
50
 
52
- * [jQuery](https://github.com/jquery/jquery) for Javascript pleasantry
53
51
  * Rails' flashes set up and in application layout.
54
52
  * A few nice time formats.
55
53
 
@@ -65,6 +63,17 @@ This has the same effect as running:
65
63
  heroku create app-staging --remote staging
66
64
  heroku create app-production --remote production
67
65
 
66
+ Github
67
+ ------
68
+
69
+ You can optionally create a Github repository:
70
+
71
+ suspenders app --github organization/project
72
+
73
+ This has the same effect as running:
74
+
75
+ hub create organization/project
76
+
68
77
  Clearance
69
78
  ---------
70
79
 
@@ -72,6 +81,14 @@ You can optionally not include Clearance:
72
81
 
73
82
  suspenders app --clearance false
74
83
 
84
+ Capybara Webkit
85
+ ---------------
86
+
87
+ You can optionally not include Capybara Webkit (which depends on QT being
88
+ installed on your machine):
89
+
90
+ suspenders app --webkit false
91
+
75
92
  Dependencies
76
93
  ------------
77
94
 
@@ -0,0 +1,10 @@
1
+ @disable-bundler
2
+ Feature: Skipping Clearance
3
+
4
+ Scenario: --clearance=false
5
+ When I suspend a project called "test_project" with:
6
+ | argument | value |
7
+ | --clearance | false |
8
+ And I cd to the "test_project" root
9
+ Then "clearance" should not be installed
10
+ And I can cleanly rake the project
@@ -0,0 +1,8 @@
1
+ @disable-bundler
2
+ Feature: Creating a Github repo
3
+
4
+ Scenario: --github=organization/project
5
+ When I suspend a project called "test_project" with:
6
+ | argument | value |
7
+ | --github | organization/project |
8
+ Then the "organization/project" Github repo should exist
@@ -0,0 +1,9 @@
1
+ @disable-bundler
2
+ Feature: Creating a Heroku app
3
+
4
+ Scenario: --heroku=true
5
+ When I suspend a project called "test_project" with:
6
+ | argument | value |
7
+ | --heroku | true |
8
+ Then the "test_project-staging" Heroku app should exist
9
+ And the "test_project-production" Heroku app should exist
@@ -53,3 +53,21 @@ Then 'I can cleanly rake the project' do
53
53
  Then I see a successful response in the shell
54
54
  }
55
55
  end
56
+
57
+ Then /^"(.*)" should not be installed$/ do |gem_name|
58
+ in_current_dir do
59
+ system("bundle show #{gem_name} 2>&1 > /dev/null").should be_false
60
+ end
61
+ end
62
+
63
+ Then /^"(.*)" should not be included in "(.*)"$/ do |content, file_path|
64
+ check_file_content file_path, content, false
65
+ end
66
+
67
+ Then /^the "([^"]*)" Heroku app should exist$/ do |app_name|
68
+ FakeHeroku.should have_created_app(app_name)
69
+ end
70
+
71
+ Then /^the "([^"]*)" Github repo should exist$/ do |repo_name|
72
+ FakeGithub.should have_created_repo(repo_name)
73
+ end
@@ -1,15 +1,10 @@
1
1
  Before do
2
2
  ENV['TESTING'] = 'true'
3
- end
4
-
5
- Before do
6
3
  @aruba_timeout_seconds = 560
7
4
  end
8
5
 
9
6
  After do
10
7
  FakeHeroku.clear!
11
- end
12
-
13
- After do
14
- FileUtils.rm_rf('test_project')
8
+ FakeGithub.clear!
9
+ FileUtils.rm_rf 'test_project'
15
10
  end
@@ -0,0 +1,21 @@
1
+ class FakeGithub
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'hub_commands'), File.dirname(__FILE__))
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run!
9
+ File.open(RECORDER, 'a') do |file|
10
+ file.write @args.join(' ')
11
+ end
12
+ end
13
+
14
+ def self.clear!
15
+ FileUtils.rm_rf RECORDER
16
+ end
17
+
18
+ def self.has_created_repo?(repo_name)
19
+ File.open(RECORDER, 'r').read.include?("create #{repo_name}")
20
+ end
21
+ end
@@ -12,7 +12,7 @@ class FakeHeroku
12
12
  end
13
13
 
14
14
  def self.clear!
15
- FileUtils.rm_rf(RECORDER)
15
+ FileUtils.rm_rf RECORDER
16
16
  end
17
17
 
18
18
  def self.has_created_app?(app_name)
@@ -0,0 +1,11 @@
1
+ @disable-bundler
2
+ Feature: Skipping Capybara Webkit
3
+
4
+ Scenario: --webkit=false
5
+ When I suspend a project called "test_project" with:
6
+ | argument | value |
7
+ | --webkit | false |
8
+ And I cd to the "test_project" root
9
+ Then "capybara-webkit" should not be installed
10
+ And "webkit" should not be included in "features/support/env.rb"
11
+ And I can cleanly rake the project
@@ -55,24 +55,40 @@ module Suspenders
55
55
  end
56
56
 
57
57
  def use_postgres_config_template
58
- template 'postgresql_database.yml.erb', 'config/database.yml', :force => true
58
+ template 'postgresql_database.yml.erb', 'config/database.yml',
59
+ :force => true
59
60
  end
60
61
 
61
62
  def create_database
62
63
  bundle_command 'exec rake db:create'
63
64
  end
64
65
 
65
- def include_custom_gems
66
+ def add_custom_gems
66
67
  additions_path = find_in_source_paths 'Gemfile_additions'
67
68
  new_gems = File.open(additions_path).read
68
- inject_into_file 'Gemfile', "\n#{new_gems}", :after => /gem 'jquery-rails'/
69
+ inject_into_file 'Gemfile', "\n#{new_gems}",
70
+ :after => /gem 'jquery-rails'/
71
+ end
72
+
73
+ def add_clearance_gem
74
+ inject_into_file 'Gemfile', "\ngem 'clearance'",
75
+ :after => /gem 'jquery-rails'/
76
+ end
77
+
78
+ def add_capybara_webkit_gem
79
+ inject_into_file 'Gemfile', "\n gem 'capybara-webkit', '~> 0.11.0'",
80
+ :after => /gem 'cucumber-rails', '1.3.0'/
69
81
  end
70
82
 
71
83
  def configure_rspec
72
84
  generators_config = <<-RUBY
73
- config.generators do |generate|
74
- generate.test_framework :rspec
75
- end
85
+ config.generators do |generate|
86
+ generate.test_framework :rspec
87
+ generate.helper false
88
+ generate.stylesheets false
89
+ generate.javascript_engine false
90
+ generate.view_specs false
91
+ end
76
92
  RUBY
77
93
  inject_into_class 'config/application.rb', 'Application', generators_config
78
94
  end
@@ -86,18 +102,27 @@ module Suspenders
86
102
 
87
103
  def generate_rspec
88
104
  generate 'rspec:install'
105
+ inject_into_file '.rspec', " --drb", :after => '--color'
89
106
  replace_in_file 'spec/spec_helper.rb',
90
107
  '# config.mock_with :mocha', 'config.mock_with :mocha'
91
108
  end
92
109
 
93
- def generate_cucumber
110
+ def generate_cucumber(options = {})
94
111
  generate 'cucumber:install', '--rspec', '--capybara'
95
- inject_into_file 'features/support/env.rb',
96
- %{Capybara.save_and_open_page_path = 'tmp'\n} +
97
- %{Capybara.javascript_driver = :webkit\n},
98
- :before => %{Capybara.default_selector = :css}
99
112
  inject_into_file 'config/cucumber.yml',
100
- ' -r features', :after => %{default: <%= std_opts %> features}
113
+ ' -drb -r features', :after => %{default: <%= std_opts %> features}
114
+ copy_file 'features_support_env.rb', 'features/support/env.rb',
115
+ :force => true
116
+
117
+ if options[:webkit]
118
+ inject_into_file 'features/support/env.rb',
119
+ "\n Capybara.javascript_driver = :webkit",
120
+ :after => /Capybara.default_selector = :css/
121
+ end
122
+ end
123
+
124
+ def setup_guard_spork
125
+ copy_file 'Guardfile', 'Guardfile'
101
126
  end
102
127
 
103
128
  def generate_clearance
@@ -137,11 +162,7 @@ module Suspenders
137
162
  end
138
163
 
139
164
  def create_heroku_apps
140
- path_additions = ''
141
- if ENV['TESTING']
142
- support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
143
- path_addition = "PATH=#{support_bin}:$PATH"
144
- end
165
+ path_addition = override_path_for_tests
145
166
  run "#{path_addition} heroku create #{app_name}-production --remote=production"
146
167
  run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
147
168
  end
@@ -152,6 +173,11 @@ module Suspenders
152
173
  inject_into_file('README.md', "#{documentation}\n", :before => 'Most importantly')
153
174
  end
154
175
 
176
+ def create_github_repo(repo_name)
177
+ path_addition = override_path_for_tests
178
+ run "#{path_addition} hub create #{repo_name}"
179
+ end
180
+
155
181
  def copy_miscellaneous_files
156
182
  copy_file 'errors.rb', 'config/initializers/errors.rb'
157
183
  copy_file 'time_formats.rb', 'config/initializers/time_formats.rb'
@@ -177,6 +203,10 @@ module Suspenders
177
203
  route "root :to => 'Clearance::Sessions#new'"
178
204
  end
179
205
 
206
+ def remove_routes_comment_lines
207
+ replace_in_file 'config/routes.rb', /Application\.routes\.draw do.*end/m, "Application.routes.draw do\nend"
208
+ end
209
+
180
210
  def set_attr_accessibles_on_user
181
211
  inject_into_file 'app/models/user.rb',
182
212
  ' attr_accessible :email, :password\n',
@@ -197,8 +227,13 @@ module Suspenders
197
227
  end
198
228
  end
199
229
 
200
- def add_clearance_gem
201
- inject_into_file 'Gemfile', "\ngem 'clearance'", :after => /gem 'jquery-rails'/
230
+ private
231
+
232
+ def override_path_for_tests
233
+ if ENV['TESTING']
234
+ support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
235
+ "PATH=#{support_bin}:$PATH"
236
+ end
202
237
  end
203
238
  end
204
239
  end
@@ -3,17 +3,23 @@ require 'rails/generators/rails/app/app_generator'
3
3
 
4
4
  module Suspenders
5
5
  class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :clearance, :type => :boolean, :aliases => '-C', :default => true,
7
+ :desc => 'Add the Clearance Rails authentication library'
8
+
6
9
  class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
7
10
  :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
8
11
 
12
+ class_option :heroku, :type => :boolean, :aliases => '-H', :default => false,
13
+ :desc => 'Create staging and production Heroku apps'
14
+
15
+ class_option :github, :type => :string, :aliases => '-G', :default => nil,
16
+ :desc => 'Create Github repository and add remote origin pointed to repo'
17
+
9
18
  class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
10
19
  :desc => 'Skip Test::Unit files'
11
20
 
12
- class_option :heroku, :type => :boolean, :aliases => '-H', :default => false,
13
- :desc => 'Create staging and production heroku apps'
14
-
15
- class_option :clearance, :type => :boolean, :aliases => '-C', :default => true,
16
- :desc => 'Add the clearance Rails authentication library'
21
+ class_option :webkit, :type => :boolean, :aliases => '-W', :default => true,
22
+ :desc => 'Add the Capybara Webkit Javascript integration testing library'
17
23
 
18
24
  def finish_template
19
25
  invoke :suspenders_customization
@@ -33,9 +39,11 @@ module Suspenders
33
39
  invoke :setup_stylesheets
34
40
  invoke :copy_miscellaneous_files
35
41
  invoke :customize_error_pages
42
+ invoke :remove_routes_comment_lines
36
43
  invoke :setup_root_route
37
44
  invoke :setup_git
38
45
  invoke :create_heroku_apps
46
+ invoke :create_github_repo
39
47
  invoke :outro
40
48
  end
41
49
 
@@ -74,18 +82,26 @@ module Suspenders
74
82
  end
75
83
 
76
84
  def customize_gemfile
77
- build :include_custom_gems
85
+ build :add_custom_gems
86
+
78
87
  if options[:clearance]
79
88
  build :add_clearance_gem
80
89
  end
90
+
91
+ if options[:webkit]
92
+ build :add_capybara_webkit_gem
93
+ end
94
+
81
95
  bundle_command 'install'
82
96
  end
83
97
 
84
98
  def setup_database
85
99
  say 'Setting up database'
100
+
86
101
  if 'postgresql' == options[:database]
87
102
  build :use_postgres_config_template
88
103
  end
104
+
89
105
  build :create_database
90
106
  end
91
107
 
@@ -94,7 +110,8 @@ module Suspenders
94
110
  build :configure_rspec
95
111
  build :configure_action_mailer
96
112
  build :generate_rspec
97
- build :generate_cucumber
113
+ build :generate_cucumber, :webkit => options[:webkit]
114
+ build :setup_guard_spork
98
115
  build :add_email_validator
99
116
  build :setup_default_rake_task
100
117
  build :setup_clearance
@@ -104,6 +121,7 @@ module Suspenders
104
121
  if options[:clearance]
105
122
  build :generate_clearance
106
123
  build :include_clearance_matchers
124
+
107
125
  if using_active_record?
108
126
  build :set_attr_accessibles_on_user
109
127
  end
@@ -122,13 +140,20 @@ module Suspenders
122
140
  end
123
141
 
124
142
  def create_heroku_apps
125
- if options['heroku']
126
- say 'Creating heroku apps'
143
+ if options[:heroku]
144
+ say 'Creating Heroku apps'
127
145
  build :create_heroku_apps
128
146
  build :document_heroku
129
147
  end
130
148
  end
131
149
 
150
+ def create_github_repo
151
+ if options[:github]
152
+ say 'Creating Github repo'
153
+ build :create_github_repo, options[:github]
154
+ end
155
+ end
156
+
132
157
  def setup_gitignore
133
158
  build :gitignore_files
134
159
  end
@@ -147,6 +172,10 @@ module Suspenders
147
172
  build :customize_error_pages
148
173
  end
149
174
 
175
+ def remove_routes_comment_lines
176
+ build :remove_routes_comment_lines
177
+ end
178
+
150
179
  def setup_root_route
151
180
  if options[:clearance]
152
181
  say 'Setting up a root route'