gimbal 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb14177d6e09326cfeaf9f4f0fbd508699aa90df
4
- data.tar.gz: 74bb02704c34a677007ac224383a889e3177a362
3
+ metadata.gz: d6a4a087627c5a4359e58b9f758b27faeccf2709
4
+ data.tar.gz: f6bdc796fcbf1ac58efd2e9ee97cb9893803a341
5
5
  SHA512:
6
- metadata.gz: 079270e680949bf446fbbbf9ac54490a9d948123f2bc3a4759f3c90ffc32a1bb6685a9b5dd15d97d8c83f48cb941efb62d312841bf3f8b0ff32ff2b3cbcf377b
7
- data.tar.gz: ea125f4c050cc32e2840d4b1f9050e2cc5404e79fa31955636eed626f75caee190274e460c801222121d9b3ca6fb51caf0ba0cfe5450927bb015c1a214f8abbb
6
+ metadata.gz: dfbf4f726e4f23e2003f5f24fb4b4ff35adc8426adf78c67f211841c9459effc48338dd987e62599e6dfe7e573ad1fb8cf9e528dc03e00145d457258a7131d65
7
+ data.tar.gz: 4332a53e6bac1eb0ea799031044e54cd45778760a07d68d8e1bc503d9e485050546e93aaf9c31b4de33fc5a98a175f3332b2b27ee343ebcd8c3d79ea13b7170d
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.3
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm: 2.2.3
3
+ cache: bundler
4
+ sudo: false
5
+ before_install:
6
+ - "echo '--colour' > ~/.rspec"
7
+ - git config --global user.name 'Travis CI'
8
+ - git config --global user.email 'travis-ci@example.com'
9
+ install: bundle install
10
+ notifications:
11
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md CHANGED
@@ -1 +1,26 @@
1
- # gimbal
1
+ # gimbal [![Build Status](https://travis-ci.org/pacso/gimbal.svg?branch=master)](https://travis-ci.org/pacso/gimbal)
2
+
3
+ Gimbal is the base Rails application I use when starting new projects. It was mostly copied from thoughtbot's Suspenders project, but modified for my needs.
4
+
5
+ ## Installation
6
+
7
+ Install the `gimbal` gem:
8
+
9
+ gem install gimbal
10
+
11
+ Then use it:
12
+
13
+ gimbal projectname
14
+
15
+ This will create a Rails app in `projectname` directory using the latest version of Rails.
16
+
17
+ ## Git
18
+
19
+ You can optionally create a GitHub repository for your new Rails app. It requires that you have Hub on your system:
20
+
21
+ curl http://hub.github.com/standalone -sLo ~/bin/hub && chmod +x ~/bin/hub
22
+ gimbal app --github organisation/project
23
+
24
+ Which does the same thing as running:
25
+
26
+ hub create organisation/project
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:rspec)
6
+
7
+ desc 'Run the test suite'
8
+ task :default => :rspec
data/bin/bundler ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'bundler' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('bundler', 'bundler')
data/bin/erubis ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'erubis' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('erubis', 'erubis')
data/bin/htmldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/ldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
data/bin/nokogiri ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'nokogiri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('nokogiri', 'nokogiri')
data/bin/rackup ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rackup' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rack', 'rackup')
data/bin/rails ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rails' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('railties', 'rails')
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
data/bin/setup ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Run this script immediately after cloning the codebase.
4
+
5
+ # Exit if any subcommand fails
6
+ set -e
7
+
8
+ # Set up Ruby dependencies via Bundler
9
+ bundle install
10
+
11
+ # Add binstubs to PATH in ~/.zshenv like this:
12
+ # export PATH=".git/safe/../../bin:$PATH"
13
+ mkdir -p .git/safe
data/bin/sprockets ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'sprockets' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('sprockets', 'sprockets')
data/bin/thor ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'thor' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('thor', 'thor')
data/gimbal.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
 
11
11
  s.description = <<-HERE
12
12
  Based on Suspenders from thoughtbot, Gimbal is a base Rails project I use
13
- to steamline the beginning of my Rails projects.
13
+ to streamline the beginning of my Rails projects.
14
14
  HERE
15
15
 
16
16
  s.email = 'jon.pascoe@me.com'
@@ -0,0 +1,33 @@
1
+ module Gimbal
2
+ module Actions
3
+ def replace_in_file(relative_path, find, replace)
4
+ path = File.join(destination_root, relative_path)
5
+ contents = IO.read(path)
6
+ unless contents.gsub!(find, replace)
7
+ raise "#{find.inspect} not found in #{relative_path}"
8
+ end
9
+ File.open(path, "w") { |file| file.write(contents) }
10
+ end
11
+
12
+ def action_mailer_host(rails_env, host)
13
+ config = "config.action_mailer.default_url_options = { host: #{host} }"
14
+ configure_environment(rails_env, config)
15
+ end
16
+
17
+ def configure_application_file(config)
18
+ inject_into_file(
19
+ "config/application.rb",
20
+ "\n\n #{config}",
21
+ before: "\n end"
22
+ )
23
+ end
24
+
25
+ def configure_environment(rails_env, config)
26
+ inject_into_file(
27
+ "config/environments/#{rails_env}.rb",
28
+ "\n\n #{config}",
29
+ before: "\nend"
30
+ )
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,147 @@
1
+ require 'forwardable'
2
+
3
+ module Gimbal
4
+ class AppBuilder < Rails::AppBuilder
5
+ include Gimbal::Actions
6
+ extend Forwardable
7
+
8
+ def replace_gemfile
9
+ remove_file 'Gemfile'
10
+ template 'Gemfile.erb', 'Gemfile'
11
+ end
12
+
13
+ def set_ruby_to_version_being_used
14
+ create_file '.ruby-version', "#{Gimbal::RUBY_VERSION}\n"
15
+ end
16
+
17
+ def init_git
18
+ run 'git init'
19
+ end
20
+
21
+ def raise_on_missing_assets_in_test
22
+ inject_into_file(
23
+ "config/environments/test.rb",
24
+ "\n config.assets.raise_runtime_errors = true",
25
+ after: "Rails.application.configure do",
26
+ )
27
+ end
28
+
29
+ def raise_on_delivery_errors
30
+ replace_in_file 'config/environments/development.rb',
31
+ 'raise_delivery_errors = false', 'raise_delivery_errors = true'
32
+ end
33
+
34
+ def set_dev_mail_delivery_method
35
+ inject_into_file(
36
+ "config/environments/development.rb",
37
+ "\n config.action_mailer.delivery_method = :letter_opener",
38
+ after: "config.action_mailer.raise_delivery_errors = true",
39
+ )
40
+ end
41
+
42
+ def add_bullet_gem_configuration
43
+ config = <<-RUBY
44
+ config.after_initialize do
45
+ Bullet.enable = true
46
+ Bullet.bullet_logger = true
47
+ Bullet.rails_logger = true
48
+ end
49
+
50
+ RUBY
51
+
52
+ inject_into_file(
53
+ "config/environments/development.rb",
54
+ config,
55
+ after: "config.action_mailer.delivery_method = :letter_opener\n",
56
+ )
57
+ end
58
+
59
+ def raise_on_unpermitted_parameters
60
+ config = <<-RUBY
61
+ config.action_controller.action_on_unpermitted_parameters = :raise
62
+ RUBY
63
+
64
+ inject_into_class "config/application.rb", "Application", config
65
+ end
66
+
67
+ def use_mysql_config_template
68
+ template 'mysql_database.yml.erb', 'config/database.yml', force: true
69
+ end
70
+
71
+ def configure_spec_support_features
72
+ empty_directory_with_keep_file 'spec/features'
73
+ empty_directory_with_keep_file 'spec/factories'
74
+ empty_directory_with_keep_file 'spec/support/features'
75
+ end
76
+
77
+ def configure_action_mailer_in_specs
78
+ copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
79
+ end
80
+
81
+ def gitignore_files
82
+ remove_file '.gitignore'
83
+ copy_file 'gimbal_gitignore', '.gitignore'
84
+ %w(app/views/pages spec/lib spec/controllers spec/helpers spec/support/matchers spec/support/mixins spec/support/shared_examples).each do |dir|
85
+ run "mkdir #{dir}"
86
+ run "touch #{dir}/.keep"
87
+ end
88
+ end
89
+
90
+ def generate_rspec
91
+ generate 'rspec:install'
92
+ end
93
+
94
+ def enable_database_cleaner
95
+ copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
96
+ end
97
+
98
+ def set_up_factory_girl_for_rspec
99
+ copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
100
+ end
101
+
102
+ def generate_factories_file
103
+ copy_file "factories.rb", "spec/factories.rb"
104
+ end
105
+
106
+ def provide_shoulda_matchers_config
107
+ copy_file(
108
+ "shoulda_matchers_config_rspec.rb",
109
+ "spec/support/shoulda_matchers.rb"
110
+ )
111
+ end
112
+
113
+ def configure_rspec
114
+ remove_file "spec/rails_helper.rb"
115
+ remove_file "spec/spec_helper.rb"
116
+ copy_file "rails_helper.rb", "spec/rails_helper.rb"
117
+ copy_file "spec_helper.rb", "spec/spec_helper.rb"
118
+ end
119
+
120
+ def create_database
121
+ bundle_command 'exec rake db:create db:migrate'
122
+ end
123
+
124
+ def create_github_repo(repo_name)
125
+ run "hub create #{repo_name}"
126
+ end
127
+
128
+ def setup_spring
129
+ bundle_command "exec spring binstub --all"
130
+ end
131
+ end
132
+
133
+ def setup_default_rake_task
134
+ append_file 'Rakefile' do
135
+ <<-EOS
136
+ task(:default).clear
137
+ task default: [:spec]
138
+ if defined? RSpec
139
+ task(:spec).clear
140
+ RSpec::Core::RakeTask.new(:spec) do |t|
141
+ t.verbose = false
142
+ end
143
+ end
144
+ EOS
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,126 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Gimbal
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, type: :string, aliases: "-d", default: "mysql",
7
+ desc: "Configure for selected database (options: #{DATABASES.join("/")})"
8
+
9
+ class_option :github, type: :string, aliases: "-G", default: nil,
10
+ desc: "Create Github repository and add remote origin pointed to repo"
11
+
12
+ class_option :skip_test_unit, type: :boolean, aliases: "-T", default: true,
13
+ desc: "Skip Test::Unit files"
14
+
15
+ class_option :skip_turbolinks, type: :boolean, default: true,
16
+ desc: "Skip turbolinks gem"
17
+
18
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
19
+ desc: "Don't run bundle install"
20
+
21
+ def finish_template
22
+ say 'Finishing template'
23
+ invoke :gimbal_customisation
24
+ super
25
+ end
26
+
27
+ def gimbal_customisation
28
+ say 'Gimbal Customisation'
29
+ invoke :customise_gemfile
30
+ invoke :setup_development_environment
31
+ invoke :setup_test_environment
32
+ invoke :setup_production_environment
33
+ invoke :configure_app
34
+ invoke :setup_git
35
+ invoke :setup_database
36
+ invoke :create_github_repo
37
+ invoke :setup_spring
38
+ end
39
+
40
+ def customise_gemfile
41
+ say 'Customising gemfile'
42
+ build :replace_gemfile
43
+ build :set_ruby_to_version_being_used
44
+
45
+ bundle_command 'install'
46
+ end
47
+
48
+ def setup_database
49
+ say 'Setting up database'
50
+
51
+ # if 'mysql' == options[:database]
52
+ # build :use_mysql_config_template
53
+ # end
54
+
55
+ build :create_database
56
+ end
57
+
58
+ def setup_development_environment
59
+ say 'Setting up the development environment'
60
+ build :raise_on_delivery_errors
61
+ build :set_dev_mail_delivery_method
62
+ build :add_bullet_gem_configuration
63
+ build :raise_on_unpermitted_parameters
64
+ end
65
+
66
+ def setup_test_environment
67
+ say 'Setting up the test environment'
68
+ build :raise_on_missing_assets_in_test
69
+ build :set_up_factory_girl_for_rspec
70
+ build :generate_rspec
71
+ build :configure_rspec
72
+ build :enable_database_cleaner
73
+ build :provide_shoulda_matchers_config
74
+ build :configure_spec_support_features
75
+ build :configure_action_mailer_in_specs
76
+ end
77
+
78
+ def setup_production_environment
79
+ say 'Setting up the production environment'
80
+
81
+ end
82
+
83
+ def configure_app
84
+ say 'Configuring app'
85
+ build :setup_default_rake_task
86
+ end
87
+
88
+ def setup_git
89
+ if !options[:skip_git]
90
+ say 'Initializing git'
91
+ invoke :setup_gitignore
92
+ invoke :init_git
93
+ end
94
+ end
95
+
96
+ def setup_gitignore
97
+ build :gitignore_files
98
+ end
99
+
100
+ def setup_spring
101
+ say "Springifying binstubs"
102
+ build :setup_spring
103
+ end
104
+
105
+ def init_git
106
+ build :init_git
107
+ end
108
+
109
+ def create_github_repo
110
+ if !options[:skip_git] && options[:github]
111
+ say 'Creating Github repo'
112
+ build :create_github_repo, options[:github]
113
+ end
114
+ end
115
+
116
+ protected
117
+
118
+ def get_builder_class
119
+ Gimbal::AppBuilder
120
+ end
121
+
122
+ def using_active_record?
123
+ !options[:skip_active_record]
124
+ end
125
+ end
126
+ end
@@ -1,5 +1,5 @@
1
1
  module Gimbal
2
2
  RAILS_VERSION = '~> 4.2.0'
3
3
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
data/lib/gimbal.rb CHANGED
@@ -1 +1,4 @@
1
1
  require 'gimbal/version'
2
+ require 'gimbal/generators/app_generator'
3
+ require 'gimbal/actions'
4
+ require 'gimbal/app_builder'
@@ -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,15 @@
1
+ require 'spec_helper'
2
+
3
+ # RSpec.describe "GitHub" do
4
+ # before do
5
+ # drop_dummy_database
6
+ # remove_project_directory
7
+ # end
8
+ #
9
+ # it "creates a project with --github option" do
10
+ # repo_name = 'test'
11
+ # run_gimbal("--github=#{repo_name}")
12
+ #
13
+ # expect(FakeGithub).to have_created_repo(repo_name)
14
+ # end
15
+ # end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe "Create a new project with default config" do
4
+ before(:all) do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ run_gimbal
8
+ end
9
+
10
+ it 'ensures project specs pass' do
11
+ Dir.chdir(project_path) do
12
+ Bundler.with_clean_env do
13
+ expect(`rake`).to include('0 failures')
14
+ end
15
+ end
16
+ end
17
+
18
+ it "configs missing assets to raise in test" do
19
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
20
+
21
+ expect(test_config).to match(
22
+ /^ +config.assets.raise_runtime_errors = true$/,
23
+ )
24
+ end
25
+
26
+ it "configs raise_on_delivery errors in development" do
27
+ dev_config = IO.read("#{project_path}/config/environments/development.rb")
28
+
29
+ expect(dev_config).to match(
30
+ /^ +config.action_mailer.raise_delivery_errors = true$/,
31
+ )
32
+ end
33
+
34
+ it "configs development to send mail using letter_opener" do
35
+ dev_config = IO.read("#{project_path}/config/environments/development.rb")
36
+
37
+ expect(dev_config).to match(
38
+ /^ +config.action_mailer.delivery_method = :letter_opener/,
39
+ )
40
+ end
41
+
42
+ it "configs bullet gem in development" do
43
+ dev_config = IO.read("#{project_path}/config/environments/development.rb")
44
+
45
+ expect(dev_config).to match /^ +Bullet.enable = true$/
46
+ expect(dev_config).to match /^ +Bullet.bullet_logger = true$/
47
+ expect(dev_config).to match /^ +Bullet.rails_logger = true$/
48
+ end
49
+
50
+ it "raises on unpermitted parameters in all environments" do
51
+ result = IO.read("#{project_path}/config/application.rb")
52
+
53
+ expect(result).to match(
54
+ /^ +config.action_controller.action_on_unpermitted_parameters = :raise$/
55
+ )
56
+ end
57
+
58
+ it "adds support file for action mailer" do
59
+ expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
60
+ end
61
+
62
+ it "adds support file for factory girl" do
63
+ expect(File).to exist("#{project_path}/spec/support/factory_girl.rb")
64
+ end
65
+
66
+ it "adds support file for database cleaner" do
67
+ expect(File).to exist("#{project_path}/spec/support/database_cleaner.rb")
68
+ end
69
+
70
+ it "adds support file for database cleaner" do
71
+ expect(File).to exist("#{project_path}/spec/support/shoulda_matchers.rb")
72
+ end
73
+
74
+ it "creates .ruby-version from Gimbal .ruby-version" do
75
+ ruby_version_file = IO.read("#{project_path}/.ruby-version")
76
+
77
+ expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
78
+ end
79
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+
3
+ Bundler.require(:default, :test)
4
+
5
+ require (Pathname.new(__FILE__).dirname + '../lib/gimbal').expand_path
6
+
7
+ Dir['./spec/support/**/*.rb'].each { |file| require file }
8
+
9
+ RSpec.configure do |config|
10
+ config.include GimbalTestHelpers
11
+
12
+ config.before(:all) do
13
+ add_fakes_to_path
14
+ create_tmp_directory
15
+ end
16
+
17
+ config.before(:each) do
18
+ FakeGithub.clear!
19
+ end
20
+ 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.read(RECORDER) == "create #{repo_name}"
20
+ end
21
+ end
@@ -0,0 +1,58 @@
1
+ module GimbalTestHelpers
2
+ APP_NAME = 'dummy_app'
3
+
4
+ def remove_project_directory
5
+ FileUtils.rm_rf(project_path)
6
+ end
7
+
8
+ def create_tmp_directory
9
+ FileUtils.mkdir_p(tmp_path)
10
+ end
11
+
12
+ def run_gimbal(arguments = nil)
13
+ Dir.chdir(tmp_path) do
14
+ Bundler.with_clean_env do
15
+ add_fakes_to_path
16
+ `
17
+ #{gimbal_bin} #{APP_NAME} #{arguments}
18
+ `
19
+ end
20
+ end
21
+ end
22
+
23
+ def drop_dummy_database
24
+ if File.exist?(project_path)
25
+ Dir.chdir(project_path) do
26
+ Bundler.with_clean_env do
27
+ `rake db:drop`
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ def add_fakes_to_path
34
+ ENV["PATH"] = "#{support_bin}:#{ENV['PATH']}"
35
+ end
36
+
37
+ def project_path
38
+ @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
39
+ end
40
+
41
+ private
42
+
43
+ def tmp_path
44
+ @tmp_path ||= Pathname.new("#{root_path}/tmp")
45
+ end
46
+
47
+ def gimbal_bin
48
+ File.join(root_path, 'bin', 'gimbal')
49
+ end
50
+
51
+ def support_bin
52
+ File.join(root_path, 'spec', 'fakes', 'bin')
53
+ end
54
+
55
+ def root_path
56
+ File.expand_path('../../../', __FILE__)
57
+ end
58
+ end
@@ -0,0 +1,52 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "<%= Gimbal::RUBY_VERSION %>"
4
+
5
+ # gem "airbrake"
6
+ gem "autoprefixer-rails"
7
+ gem "coffee-rails", "~> 4.1.0"
8
+ # gem "delayed_job_active_record"
9
+ # gem "flutie"
10
+ # gem "high_voltage"
11
+ gem "jquery-rails"
12
+ # gem "newrelic_rpm", ">= 3.9.8"
13
+ gem "normalize-rails", "~> 3.0.0"
14
+ gem "mysql2"
15
+ # gem "puma"
16
+ # gem "rack-canonical-host"
17
+ gem "rails", "<%= Gimbal::RAILS_VERSION %>"
18
+ # gem "recipient_interceptor"
19
+ gem "sass-rails", "~> 5.0"
20
+ # gem "title"
21
+ gem "uglifier"
22
+
23
+ group :development do
24
+ gem "letter_opener"
25
+ gem "quiet_assets"
26
+ gem "spring"
27
+ gem "spring-commands-rspec"
28
+ gem "web-console"
29
+ end
30
+
31
+ group :development, :test do
32
+ gem "awesome_print"
33
+ gem "bullet"
34
+ # gem "bundler-audit", require: false
35
+ gem "byebug"
36
+ # gem "dotenv-rails"
37
+ gem "factory_girl_rails"
38
+ gem "i18n-tasks"
39
+ # gem "pry-rails"
40
+ gem "rspec-rails", "~> 3.3.0"
41
+ end
42
+
43
+ group :test do
44
+ # gem "capybara-webkit"
45
+ gem "database_cleaner"
46
+ # gem "formulaic"
47
+ gem "launchy"
48
+ gem "shoulda-matchers"
49
+ gem "simplecov", require: false
50
+ gem "timecop"
51
+ # gem "webmock"
52
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActionMailer::Base.deliveries.clear
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, js: true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,13 @@
1
+ !.keep
2
+ *.DS_Store
3
+ *.swo
4
+ *.swp
5
+ /.bundle
6
+ /.env.local
7
+ /coverage/*
8
+ /db/*.sqlite3
9
+ /log/*
10
+ /public/system
11
+ /public/assets
12
+ /tags
13
+ /tmp/*
File without changes
@@ -0,0 +1,22 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ abort("DATABASE_URL environment variable is set") if ENV["DATABASE_URL"]
5
+
6
+ require "rspec/rails"
7
+
8
+ Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
9
+
10
+ module Features
11
+ # Extend this module in spec/support/features/*.rb
12
+ # include Formulaic::Dsl
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.include Features, type: :feature
17
+ config.infer_base_class_for_anonymous_controllers = false
18
+ config.infer_spec_type_from_file_location!
19
+ config.use_transactional_fixtures = false
20
+ end
21
+
22
+ ActiveRecord::Migration.maintain_test_schema!
@@ -0,0 +1,6 @@
1
+ Shoulda::Matchers.configure do |config|
2
+ config.integrate do |with|
3
+ with.test_framework :rspec
4
+ with.library :rails
5
+ end
6
+ end
@@ -0,0 +1,23 @@
1
+ # if ENV.fetch("COVERAGE", false)
2
+ # require "simplecov"
3
+ # SimpleCov.start "rails"
4
+ # end
5
+
6
+ # require "webmock/rspec"
7
+
8
+ # http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.syntax = :expect
12
+ end
13
+
14
+ config.mock_with :rspec do |mocks|
15
+ mocks.syntax = :expect
16
+ mocks.verify_partial_doubles = true
17
+ end
18
+
19
+ config.example_status_persistence_file_path = "tmp/rspec_examples.txt"
20
+ config.order = :random
21
+ end
22
+
23
+ # WebMock.disable_net_connect!(allow_localhost: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimbal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Pascoe
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.2'
55
55
  description: |
56
56
  Based on Suspenders from thoughtbot, Gimbal is a base Rails project I use
57
- to steamline the beginning of my Rails projects.
57
+ to streamline the beginning of my Rails projects.
58
58
  email: jon.pascoe@me.com
59
59
  executables:
60
60
  - gimbal
@@ -64,12 +64,46 @@ extra_rdoc_files:
64
64
  - LICENSE
65
65
  files:
66
66
  - ".gitignore"
67
+ - ".ruby-version"
68
+ - ".travis.yml"
69
+ - Gemfile
67
70
  - LICENSE
68
71
  - README.md
72
+ - Rakefile
73
+ - bin/bundler
74
+ - bin/erubis
69
75
  - bin/gimbal
76
+ - bin/htmldiff
77
+ - bin/ldiff
78
+ - bin/nokogiri
79
+ - bin/rackup
80
+ - bin/rails
81
+ - bin/rake
82
+ - bin/rspec
83
+ - bin/setup
84
+ - bin/sprockets
85
+ - bin/thor
70
86
  - gimbal.gemspec
71
87
  - lib/gimbal.rb
88
+ - lib/gimbal/actions.rb
89
+ - lib/gimbal/app_builder.rb
90
+ - lib/gimbal/generators/app_generator.rb
72
91
  - lib/gimbal/version.rb
92
+ - spec/fakes/bin/hub
93
+ - spec/features/github_spec.rb
94
+ - spec/features/new_project_spec.rb
95
+ - spec/spec_helper.rb
96
+ - spec/support/fake_github.rb
97
+ - spec/support/gimbal.rb
98
+ - templates/Gemfile.erb
99
+ - templates/action_mailer.rb
100
+ - templates/database_cleaner_rspec.rb
101
+ - templates/factory_girl_rspec.rb
102
+ - templates/gimbal_gitignore
103
+ - templates/mysql_database.yml.erb
104
+ - templates/rails_helper.rb
105
+ - templates/shoulda_matchers_config_rspec.rb
106
+ - templates/spec_helper.rb
73
107
  homepage: http://github.com/pacso/gimbal
74
108
  licenses:
75
109
  - MIT
@@ -95,4 +129,10 @@ rubygems_version: 2.4.5.1
95
129
  signing_key:
96
130
  specification_version: 4
97
131
  summary: A Rails App Generator.
98
- test_files: []
132
+ test_files:
133
+ - spec/fakes/bin/hub
134
+ - spec/features/github_spec.rb
135
+ - spec/features/new_project_spec.rb
136
+ - spec/spec_helper.rb
137
+ - spec/support/fake_github.rb
138
+ - spec/support/gimbal.rb