railslove-suspenders 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +9 -0
  2. data/.travis.yml +6 -0
  3. data/CONTRIBUTING.md +38 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +94 -0
  6. data/LICENSE +21 -0
  7. data/NEWS.md +99 -0
  8. data/README.md +125 -0
  9. data/Rakefile +8 -0
  10. data/bin/railslove-suspenders +16 -0
  11. data/features/github_repo.feature +8 -0
  12. data/features/heroku_true.feature +9 -0
  13. data/features/rake_clean.feature +15 -0
  14. data/features/step_definitions/suspenders_steps.rb +68 -0
  15. data/features/support/bin/heroku +5 -0
  16. data/features/support/bin/hub +5 -0
  17. data/features/support/env.rb +10 -0
  18. data/features/support/fake_github.rb +21 -0
  19. data/features/support/fake_heroku.rb +21 -0
  20. data/lib/railslove-suspenders/actions.rb +40 -0
  21. data/lib/railslove-suspenders/app_builder.rb +335 -0
  22. data/lib/railslove-suspenders/generators/app_generator.rb +202 -0
  23. data/lib/railslove-suspenders/version.rb +4 -0
  24. data/railslove-suspenders.gemspec +33 -0
  25. data/templates/Gemfile_clean +42 -0
  26. data/templates/Procfile +2 -0
  27. data/templates/README.md.erb +9 -0
  28. data/templates/_flashes.html.haml +3 -0
  29. data/templates/_javascript.html.haml +3 -0
  30. data/templates/background_jobs_rspec.rb +19 -0
  31. data/templates/bin_setup +11 -0
  32. data/templates/config_locales_en.yml +11 -0
  33. data/templates/database_cleaner_rspec.rb +21 -0
  34. data/templates/disable_xml_params.rb +3 -0
  35. data/templates/email_validator.rb +7 -0
  36. data/templates/errors.rb +28 -0
  37. data/templates/factories_spec.rb +14 -0
  38. data/templates/factories_spec_rake_task.rb +9 -0
  39. data/templates/factory_girl_syntax_rspec.rb +3 -0
  40. data/templates/import_scss_styles +3 -0
  41. data/templates/javascripts/prefilled_input.js +59 -0
  42. data/templates/postgresql_database.yml.erb +11 -0
  43. data/templates/rack_timeout.rb +1 -0
  44. data/templates/rspec +3 -0
  45. data/templates/sample.env +2 -0
  46. data/templates/simplecov_init.rb +3 -0
  47. data/templates/smtp.rb +10 -0
  48. data/templates/strong_parameters.rb +1 -0
  49. data/templates/stylesheets/_shame.css.sass +0 -0
  50. data/templates/stylesheets/application.css.sass +14 -0
  51. data/templates/stylesheets/base/_colors.css.sass +7 -0
  52. data/templates/stylesheets/base/_dimension.css.sass +2 -0
  53. data/templates/stylesheets/base/_element_defaults.css.sass +5 -0
  54. data/templates/stylesheets/base/_global_mixins.css.sass +3 -0
  55. data/templates/stylesheets/base/_icon_font.css.sass +0 -0
  56. data/templates/stylesheets/base/_sprites.css.sass +0 -0
  57. data/templates/stylesheets/base/_typography.css.sass +3 -0
  58. data/templates/suspenders_gitignore +10 -0
  59. data/templates/suspenders_layout.html.haml +12 -0
  60. data/templates/unicorn.rb +26 -0
  61. metadata +175 -0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.swp
3
+ .bundle
4
+ .rake_tasks
5
+ /bin/*
6
+ !bin/railslove-suspenders
7
+ pkg
8
+ test_project
9
+ tmp/aruba
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ notifications:
6
+ email: false
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Push to your fork and submit a pull request.
15
+
16
+
17
+ At this point you're waiting on us. We like to at least comment on, if not
18
+ accept, pull requests within three business days (and, typically, one business
19
+ day). We may suggest some changes or improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted,
22
+ taken straight from the Ruby on Rails guide:
23
+
24
+ * Use Rails idioms and helpers
25
+ * Include tests that fail without your code, and pass with it
26
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
27
+ whatever is affected by your contribution
28
+
29
+ Syntax:
30
+
31
+ * Two spaces, no tabs.
32
+ * No trailing whitespace. Blank lines should not have any space.
33
+ * Prefer &&/|| over and/or.
34
+ * my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
35
+ * a = b and not a=b.
36
+ * Follow the conventions you see used in the source already.
37
+
38
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ railslove-suspenders (0.1.0)
5
+ bundler (~> 1.3)
6
+ hub (~> 1.10)
7
+ rails (= 3.2.13)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (3.2.13)
13
+ actionpack (= 3.2.13)
14
+ mail (~> 2.5.3)
15
+ actionpack (3.2.13)
16
+ activemodel (= 3.2.13)
17
+ activesupport (= 3.2.13)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.4)
21
+ rack (~> 1.4.5)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.2.1)
25
+ activemodel (3.2.13)
26
+ activesupport (= 3.2.13)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.13)
29
+ activemodel (= 3.2.13)
30
+ activesupport (= 3.2.13)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.13)
34
+ activemodel (= 3.2.13)
35
+ activesupport (= 3.2.13)
36
+ activesupport (3.2.13)
37
+ i18n (= 0.6.1)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ builder (3.0.4)
41
+ erubis (2.7.0)
42
+ hike (1.2.3)
43
+ hub (1.10.6)
44
+ i18n (0.6.1)
45
+ journey (1.0.4)
46
+ json (1.8.0)
47
+ mail (2.5.4)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.23)
51
+ multi_json (1.7.6)
52
+ polyglot (0.3.3)
53
+ rack (1.4.5)
54
+ rack-cache (1.2)
55
+ rack (>= 0.4)
56
+ rack-ssl (1.3.3)
57
+ rack
58
+ rack-test (0.6.2)
59
+ rack (>= 1.0)
60
+ rails (3.2.13)
61
+ actionmailer (= 3.2.13)
62
+ actionpack (= 3.2.13)
63
+ activerecord (= 3.2.13)
64
+ activeresource (= 3.2.13)
65
+ activesupport (= 3.2.13)
66
+ bundler (~> 1.0)
67
+ railties (= 3.2.13)
68
+ railties (3.2.13)
69
+ actionpack (= 3.2.13)
70
+ activesupport (= 3.2.13)
71
+ rack-ssl (~> 1.3.2)
72
+ rake (>= 0.8.7)
73
+ rdoc (~> 3.4)
74
+ thor (>= 0.14.6, < 2.0)
75
+ rake (10.0.4)
76
+ rdoc (3.12.2)
77
+ json (~> 1.4)
78
+ sprockets (2.2.2)
79
+ hike (~> 1.2)
80
+ multi_json (~> 1.0)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ thor (0.18.1)
84
+ tilt (1.4.1)
85
+ treetop (1.4.14)
86
+ polyglot
87
+ polyglot (>= 0.3.1)
88
+ tzinfo (0.3.37)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ railslove-suspenders!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2012 Mike Burns and thoughtbot, inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/NEWS.md ADDED
@@ -0,0 +1,99 @@
1
+ 1.3.0 (May 13, 2013)
2
+
3
+ * Switch web server from Thin to Unicorn
4
+ * Set up database before setting up RSpec so that the rspec:install task works
5
+ * Add Delayed::Job
6
+ * Clean up cruft from ActionMailer delivery configuration
7
+ * strong_parameters now raises an error in development
8
+ * Enforce Ruby 1.9.2+ in the gemspec
9
+
10
+ 1.2.2 (March 14, 2013)
11
+
12
+ * Fix Syntax error in staging/production environment config files.
13
+ * Make Factory Girl available to development environment for generators and
14
+ `rails console`.
15
+
16
+ 1.2.1 (February 28, 2013)
17
+
18
+ * Use Ruby 1.9.3 and 2.0
19
+ * Update staging and production email delivery
20
+ * Remove Spork and Guard
21
+ * Add better_errors and binding_of_caller gems
22
+ * Fix ActiveRecord attributes' blacklist
23
+ * Add Flutie to Gemfile
24
+
25
+ 1.2.0 (February 13, 2013)
26
+
27
+ * Upgrade Rails from 3.2.8 to 3.2.12 to keep pace with security patches.
28
+ * Improve staging environment on Heroku with staging `ENV` variables and
29
+ overriding the recipient in staging email delivery.
30
+ * Remove Flutie, use Bourbon.
31
+ * Wrap all HTTP requests in a 5 second timeout.
32
+ * Don't use `attr_accessible` whitelists. Instead, configure Strong Parameters.
33
+ * Provide a `bin/setup` script.
34
+ * Force RSpec's `expect` syntax.
35
+ * Remove remaining references to Cucumber, complete RSpec + Capybara conversion.
36
+ * Improve Foreman/`.env`/`Procfile` interactions.
37
+
38
+ 1.1.5 (October 22, 2012)
39
+
40
+ * Ignore `.env`.
41
+ * Link to thoughtbot/guides in generated README.
42
+ * Remove Cucumber in favor of RSpec + Capybara.
43
+ * Deliver emails in staging environment to an overriden email or set of emails.
44
+ * Encode database as UTF8.
45
+ * Bundle with binstubs using 37signals' directory convention.
46
+ * Configure time formats using localization.
47
+ * Add Ruby version to Gemfile.
48
+ * Add fast-failing spec that tests validity of factories.
49
+ * Use SimpleCov for C0 coverage.
50
+ * Configure RSpec with `--profile` flag to find slow-running specs.
51
+
52
+ 1.1.4 (September 4, 2012)
53
+
54
+ * Always store UTC in the DB.
55
+ * Use Rails 3.2.8.
56
+
57
+ 1.1.3 (August 7, 2012)
58
+
59
+ * Fix broken Gemfile additions where capybara stole cucumber's `require: false`
60
+
61
+ 1.1.2 (August 6, 2012)
62
+
63
+ * Fix broken rake.
64
+ * Use Heroku-compliant asset pipeline settings.
65
+
66
+ 1.1.1 (August 3, 2012)
67
+
68
+ * Fix broken newline interpolation
69
+
70
+ 1.1.0 (August 3, 2012)
71
+
72
+ * Add --github option.
73
+ * Add --webkit option.
74
+ * Remove cruft when generating controllers.
75
+ * Add Spork and Guard.
76
+
77
+ 1.0.1 (August 2, 2012)
78
+
79
+ * Fix broken install on Ruby 1.8.
80
+ * Remove db/schema.rb from .gitignore.
81
+ * Remove Factory Girl step definitions.
82
+
83
+ 1.0.0 (June 29, 2012)
84
+
85
+ * Ignore `bin/`, `.rake_tasks`, `.bundle/`, and `.gem/`.
86
+ * Create a root route only with `--clearance`.
87
+ * Do not autocommit after generate.
88
+ * Style static error pages.
89
+ * Cucumber requires everything under `features/`, regardless of pwd.
90
+ * Added gems:
91
+ * `foreman`
92
+ * `therubyracer`
93
+ * Removed gems:
94
+ * `copycopter_client`
95
+ * `heroku`
96
+ * `ruby-debug`
97
+ * `sass`
98
+ * `sprockets-redirect`
99
+ * `email_spec`
data/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # Railslove Suspenders
2
+ <!-- [![Build Status](https://secure.travis-ci.org/thoughtbot/suspenders.png?branch=master)](http://travis-ci.org/thoughtbot/suspenders) -->
3
+
4
+ Suspenders is the base Rails application used at [railslove](http://railslove.com) originally developed at [thoughtbot](http://thoughtbot.com/community).
5
+
6
+ Installation
7
+ ------------
8
+
9
+ First install the suspenders gem:
10
+
11
+ gem install railslove-suspenders
12
+
13
+ Then run:
14
+
15
+ railslove-suspenders projectname
16
+
17
+ This will create a Rails 3.2 app in `projectname`. This script creates a
18
+ new git repository. It is not meant to be used against an existing repo.
19
+
20
+ Gemfile
21
+ -------
22
+
23
+ To see the latest and greatest gems, look at Suspenders'
24
+ [templates/Gemfile_clean](templates/Gemfile_clean),
25
+ which will be appended to the default generated projectname/Gemfile.
26
+
27
+ It includes application gems like:
28
+
29
+ * [Airbrake](https://github.com/airbrake/airbrake) for exception notification
30
+ * [Smurfville](https://github.com/railslove/smurfville) for dynamic color guide and more
31
+ * [Compass](https://github.com/chriseppstein/compass) for css3 mixins
32
+
33
+ And testing gems like:
34
+
35
+ * [Mocha](https://github.com/freerange/mocha) for stubbing and spying
36
+ * [Capybara](https://github.com/jnicklas/capybara) and
37
+ [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
38
+ integration testing
39
+ * [Factory Girl](https://github.com/thoughtbot/factory_girl) for test data
40
+ * [RSpec](https://github.com/rspec/rspec) for unit testing
41
+ * [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for common
42
+ RSpec matchers
43
+ * [Timecop](https://github.com/jtrupiano/timecop-console) for testing time
44
+
45
+ Other goodies
46
+ -------------
47
+
48
+ Suspenders also comes with:
49
+
50
+ * Override recipient emails in staging environment.
51
+ * Rails' flashes set up and in application layout.
52
+ * A few nice time formats set up for localization.
53
+ * [Heroku-recommended asset pipeline
54
+ settings](https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar/).
55
+
56
+ Heroku
57
+ ------
58
+
59
+ You can optionally create Heroku staging and production apps:
60
+
61
+ suspenders app --heroku true
62
+
63
+ This has the same effect as running:
64
+
65
+ heroku create app-staging --remote staging
66
+ heroku create app-production --remote production
67
+
68
+ Github
69
+ ------
70
+
71
+ You can optionally create a Github repository:
72
+
73
+ suspenders app --github organization/project
74
+
75
+ This has the same effect as running:
76
+
77
+ hub create organization/project
78
+
79
+ Dependencies
80
+ ------------
81
+
82
+ Suspenders requires Ruby 1.9.2 or greater.
83
+
84
+ Some gems included in Suspenders have native extensions. You should have GCC
85
+ installed on your machine before generating an app with Suspenders.
86
+
87
+ Use [OS X GCC Installer](https://github.com/kennethreitz/osx-gcc-installer/) for
88
+ Snow Leopard (OS X 10.6).
89
+
90
+ Use [Command Line Tools for XCode](https://developer.apple.com/downloads/index.action)
91
+ for Lion (OS X 10.7) or Mountain Lion (OS X 10.8).
92
+
93
+ We use [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
94
+ full-stack Javascript integration testing. It requires QT. Instructions for
95
+ installing QT are
96
+ [here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).
97
+
98
+ PostgreSQL needs to be installed and running for the `db:create` rake task.
99
+
100
+ Issues
101
+ ------
102
+
103
+ If you have problems, please create a
104
+ [Github Issue](https://github.com/thoughtbot/suspenders/issues).
105
+
106
+ Contributing
107
+ ------------
108
+
109
+ Please see CONTRIBUTING.md for details.
110
+
111
+ Credits
112
+ -------
113
+
114
+ ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
115
+
116
+ Suspenders is maintained and funded by
117
+ [thoughtbot, inc](http://thoughtbot.com/community).
118
+
119
+ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
120
+
121
+ License
122
+ -------
123
+
124
+ Suspenders is Copyright © 2008-2013 thoughtbot. It is free software, and may be
125
+ redistributed under the terms specified in the LICENSE file.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ # require 'cucumber/rake/task'
4
+
5
+ # Cucumber::Rake::Task.new
6
+
7
+ # desc 'Run the test suite'
8
+ # task :default => ['cucumber']
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'railslove-suspenders', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'railslove-suspenders', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'railslove-suspenders', 'app_builder'), File.dirname(__FILE__))
6
+
7
+ if ['create', '--create'].include? ARGV[0]
8
+ ARGV.shift
9
+ puts "[WARNING] the suspenders create argument is deprecated. Just use `suspenders #{ARGV.join}` instead"
10
+ end
11
+
12
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
13
+ RailsloveSuspenders::AppGenerator.source_root templates_root
14
+ RailsloveSuspenders::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
15
+
16
+ RailsloveSuspenders::AppGenerator.start
@@ -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
@@ -0,0 +1,15 @@
1
+ @disable-bundler
2
+ Feature: Rake works in the suspended project
3
+ Background:
4
+ Given I ensure no databases exist for "test_project"
5
+
6
+ Scenario: Running rake in the suspended project
7
+ When I suspend a project called "test_project"
8
+ And I cd to the "test_project" root
9
+ Then I can cleanly rake the project
10
+
11
+ Scenario: Making a spec then running rake
12
+ When I suspend a project called "test_project"
13
+ And I cd to the "test_project" root
14
+ And I generate "model post title:string"
15
+ Then I can cleanly rake the project
@@ -0,0 +1,68 @@
1
+ require 'aruba/cucumber'
2
+
3
+ When 'I run rake' do
4
+ in_current_dir do
5
+ run_simple 'bundle exec rake'
6
+ end
7
+ end
8
+
9
+ When 'I run the rake task "$task_name"' do |task_name|
10
+ in_current_dir do
11
+ run_simple "bundle exec rake #{task_name}"
12
+ end
13
+ end
14
+
15
+ When 'I generate "$generator_with_args"' do |generator_with_args|
16
+ in_current_dir do
17
+ run_simple "bundle exec rails generate #{generator_with_args}"
18
+ end
19
+ end
20
+
21
+ When 'I ensure no databases exist for "$project_name"' do |project_name|
22
+ run "dropdb #{project_name}_development"
23
+ run "dropdb #{project_name}_test"
24
+ end
25
+
26
+ When 'I suspend a project called "$project_name"' do |project_name|
27
+ suspenders_bin = File.expand_path(File.join('..', '..', 'bin', 'suspenders'), File.dirname(__FILE__))
28
+ run_simple "#{suspenders_bin} #{project_name}"
29
+ end
30
+
31
+ When /^I suspend a project called "([^"]*)" with:$/ do |project_name, arguments_table|
32
+ suspenders_bin = File.expand_path(File.join('..', '..', 'bin', 'suspenders'), File.dirname(__FILE__))
33
+ arguments = arguments_table.hashes.inject([]) do |accum, argument|
34
+ accum << "#{argument['argument']}=#{argument['value']}"
35
+ end.join
36
+ run_simple "#{suspenders_bin} #{project_name} #{arguments}"
37
+ end
38
+
39
+ When 'I cd to the "$test_project" root' do |dirname|
40
+ cd dirname
41
+ end
42
+
43
+ Then 'I can cleanly rake the project' do
44
+ steps %{
45
+ And I run the rake task "db:create"
46
+ And I run the rake task "db:migrate"
47
+ And I run the rake task "db:test:prepare"
48
+ And I run rake
49
+ }
50
+ end
51
+
52
+ Then /^"(.*)" should not be installed$/ do |gem_name|
53
+ in_current_dir do
54
+ system("bundle show #{gem_name} 2>&1 > /dev/null").should be_false
55
+ end
56
+ end
57
+
58
+ Then /^"(.*)" should not be included in "(.*)"$/ do |content, file_path|
59
+ check_file_content file_path, content, false
60
+ end
61
+
62
+ Then /^the "([^"]*)" Heroku app should exist$/ do |app_name|
63
+ FakeHeroku.should have_created_app(app_name)
64
+ end
65
+
66
+ Then /^the "([^"]*)" Github repo should exist$/ do |repo_name|
67
+ FakeGithub.should have_created_repo(repo_name)
68
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_heroku'), File.dirname(__FILE__))
4
+
5
+ FakeHeroku.new(ARGV).run!
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_github'), File.dirname(__FILE__))
4
+
5
+ FakeGithub.new(ARGV).run!
@@ -0,0 +1,10 @@
1
+ Before do
2
+ ENV['TESTING'] = 'true'
3
+ @aruba_timeout_seconds = 560
4
+ end
5
+
6
+ After do
7
+ FakeHeroku.clear!
8
+ FakeGithub.clear!
9
+ FileUtils.rm_rf 'test_project'
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
@@ -0,0 +1,21 @@
1
+ class FakeHeroku
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_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_app?(app_name)
19
+ File.open(RECORDER, 'r').read.include?("create #{app_name}")
20
+ end
21
+ end
@@ -0,0 +1,40 @@
1
+ module RailsloveSuspenders
2
+ module Actions
3
+ def concat_file(source, destination)
4
+ contents = IO.read(find_in_source_paths(source))
5
+ append_file destination, contents
6
+ end
7
+
8
+ def replace_in_file(relative_path, find, replace)
9
+ path = File.join(destination_root, relative_path)
10
+ contents = IO.read(path)
11
+ unless contents.gsub!(find, replace)
12
+ raise "#{find.inspect} not found in #{relative_path}"
13
+ end
14
+ File.open(path, "w") { |file| file.write(contents) }
15
+ end
16
+
17
+ def action_mailer_host(rails_env, host)
18
+ host_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
19
+ configure_environment(rails_env, host_config)
20
+ end
21
+
22
+ def configure_environment(rails_env, config)
23
+ inject_into_file(
24
+ "config/environments/#{rails_env}.rb",
25
+ "\n\n #{config}",
26
+ before: "\nend"
27
+ )
28
+ end
29
+
30
+ def download_file(uri_string, destination)
31
+ uri = URI.parse(uri_string)
32
+ http = Net::HTTP.new(uri.host, uri.port)
33
+ http.use_ssl = true if uri_string =~ /^https/
34
+ request = Net::HTTP::Get.new(uri.path)
35
+ contents = http.request(request).body
36
+ path = File.join(destination_root, destination)
37
+ File.open(path, "w") { |file| file.write(contents) }
38
+ end
39
+ end
40
+ end