intersect_rails_composer 0.0.2
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.
- checksums.yaml +7 -0
- data/README.textile +433 -0
- data/bin/intersect_rails_composer +7 -0
- data/lib/rails_wizard/command.rb +204 -0
- data/lib/rails_wizard/config.rb +88 -0
- data/lib/rails_wizard/diagnostics.rb +68 -0
- data/lib/rails_wizard/recipe.rb +114 -0
- data/lib/rails_wizard/recipes.rb +56 -0
- data/lib/rails_wizard/template.rb +111 -0
- data/lib/rails_wizard.rb +7 -0
- data/recipes/apps4.rb +150 -0
- data/recipes/controllers.rb +75 -0
- data/recipes/core.rb +14 -0
- data/recipes/email.rb +110 -0
- data/recipes/example.rb +70 -0
- data/recipes/extras.rb +187 -0
- data/recipes/frontend.rb +45 -0
- data/recipes/gems.rb +277 -0
- data/recipes/git.rb +20 -0
- data/recipes/init.rb +136 -0
- data/recipes/models.rb +109 -0
- data/recipes/prelaunch.rb +119 -0
- data/recipes/railsapps.rb +277 -0
- data/recipes/readme.rb +85 -0
- data/recipes/routes.rb +45 -0
- data/recipes/saas.rb +218 -0
- data/recipes/setup.rb +134 -0
- data/recipes/testing.rb +276 -0
- data/recipes/views.rb +57 -0
- data/spec/rails_wizard/config_spec.rb +108 -0
- data/spec/rails_wizard/recipe_spec.rb +115 -0
- data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
- data/spec/rails_wizard/recipes_spec.rb +41 -0
- data/spec/rails_wizard/template_spec.rb +92 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/rails_directory.rb +17 -0
- data/spec/support/template_runner.rb +28 -0
- data/spec/test_recipes/test_recipe_in_file.rb +9 -0
- data/templates/helpers.erb +135 -0
- data/templates/layout.erb +232 -0
- data/templates/recipe.erb +13 -0
- data/version.rb +3 -0
- metadata +210 -0
data/recipes/setup.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb
|
3
|
+
|
4
|
+
## Ruby on Rails
|
5
|
+
HOST_OS = RbConfig::CONFIG['host_os']
|
6
|
+
say_wizard "Your operating system is #{HOST_OS}."
|
7
|
+
say_wizard "You are using Ruby version #{RUBY_VERSION}."
|
8
|
+
say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
|
9
|
+
|
10
|
+
## Is sqlite3 in the Gemfile?
|
11
|
+
gemfile = File.read(destination_root() + '/Gemfile')
|
12
|
+
sqlite_detected = gemfile.include? 'sqlite3'
|
13
|
+
|
14
|
+
## Web Server
|
15
|
+
prefs[:dev_webserver] = multiple_choice "Web server for development?", [["WEBrick (default)", "webrick"],
|
16
|
+
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :dev_webserver
|
17
|
+
prefs[:prod_webserver] = multiple_choice "Web server for production?", [["Same as development", "same"],
|
18
|
+
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :prod_webserver
|
19
|
+
if prefs[:prod_webserver] == 'same'
|
20
|
+
case prefs[:dev_webserver]
|
21
|
+
when 'thin'
|
22
|
+
prefs[:prod_webserver] = 'thin'
|
23
|
+
when 'unicorn'
|
24
|
+
prefs[:prod_webserver] = 'unicorn'
|
25
|
+
when 'puma'
|
26
|
+
prefs[:prod_webserver] = 'puma'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
## Database Adapter
|
31
|
+
prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"],
|
32
|
+
["MySQL", "mysql"], ["MongoDB", "mongodb"]] unless prefs.has_key? :database
|
33
|
+
case prefs[:database]
|
34
|
+
when 'mongodb'
|
35
|
+
unless sqlite_detected
|
36
|
+
prefs[:orm] = multiple_choice "How will you connect to MongoDB?", [["Mongoid","mongoid"]] unless prefs.has_key? :orm
|
37
|
+
else
|
38
|
+
say_wizard "WARNING! SQLite gem detected in the Gemfile"
|
39
|
+
say_wizard "If you wish to use MongoDB you must skip Active Record."
|
40
|
+
say_wizard "If using rails_apps_composer, choose 'skip Active Record'."
|
41
|
+
say_wizard "If using Rails Composer or an application template, use the '-O' flag as in 'rails new foo -O'."
|
42
|
+
prefs[:fail] = multiple_choice "Abort or continue?", [["abort", "abort"], ["continue", "continue"]]
|
43
|
+
if prefer :fail, 'abort'
|
44
|
+
raise StandardError.new "SQLite detected in the Gemfile. Use '-O' or '--skip-activerecord' as in 'rails new foo -O' if you don't want ActiveRecord and SQLite"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
## Template Engine
|
50
|
+
prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim (experimental)", "slim"]] unless prefs.has_key? :templates
|
51
|
+
|
52
|
+
## Testing Framework
|
53
|
+
if recipes.include? 'testing'
|
54
|
+
prefs[:unit_test] = multiple_choice "Unit testing?", [["Test::Unit", "test_unit"], ["RSpec", "rspec"], ["MiniTest", "minitest"]] unless prefs.has_key? :unit_test
|
55
|
+
prefs[:integration] = multiple_choice "Integration testing?", [["None", "none"], ["RSpec with Capybara", "rspec-capybara"],
|
56
|
+
["Cucumber with Capybara", "cucumber"], ["Turnip with Capybara", "turnip"], ["MiniTest with Capybara", "minitest-capybara"]] unless prefs.has_key? :integration
|
57
|
+
prefs[:continuous_testing] = multiple_choice "Continuous testing?", [["None", "none"], ["Guard", "guard"]] unless prefs.has_key? :continuous_testing
|
58
|
+
prefs[:fixtures] = multiple_choice "Fixture replacement?", [["None","none"], ["Factory Girl","factory_girl"], ["Machinist","machinist"], ["Fabrication","fabrication"]] unless prefs.has_key? :fixtures
|
59
|
+
end
|
60
|
+
|
61
|
+
## Front-end Framework
|
62
|
+
if recipes.include? 'frontend'
|
63
|
+
prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], ["Zurb Foundation 4.0", "foundation4"],
|
64
|
+
["Twitter Bootstrap 3.0", "bootstrap3"], ["Twitter Bootstrap 2.3", "bootstrap2"], ["Simple CSS", "simple"]] unless prefs.has_key? :frontend
|
65
|
+
end
|
66
|
+
|
67
|
+
## Email
|
68
|
+
if recipes.include? 'email'
|
69
|
+
prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"],
|
70
|
+
["SendGrid","sendgrid"], ["Mandrill","mandrill"]] unless prefs.has_key? :email
|
71
|
+
else
|
72
|
+
prefs[:email] = 'none'
|
73
|
+
end
|
74
|
+
|
75
|
+
## Authentication and Authorization
|
76
|
+
if recipes.include? 'models'
|
77
|
+
prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication
|
78
|
+
case prefs[:authentication]
|
79
|
+
when 'devise'
|
80
|
+
if prefer :orm, 'mongoid'
|
81
|
+
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"]] unless prefs.has_key? :devise_modules
|
82
|
+
else
|
83
|
+
if rails_4?
|
84
|
+
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"],
|
85
|
+
["Devise with Confirmable module","confirmable"],
|
86
|
+
["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules
|
87
|
+
else
|
88
|
+
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"],
|
89
|
+
["Devise with Confirmable module","confirmable"]] unless prefs.has_key? :devise_modules
|
90
|
+
end
|
91
|
+
end
|
92
|
+
when 'omniauth'
|
93
|
+
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"],
|
94
|
+
["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
|
95
|
+
end
|
96
|
+
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]] unless prefs.has_key? :authorization
|
97
|
+
end
|
98
|
+
|
99
|
+
## Form Builder
|
100
|
+
prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder
|
101
|
+
|
102
|
+
## MVC
|
103
|
+
if (recipes.include? 'models') && (recipes.include? 'controllers') && (recipes.include? 'views') && (recipes.include? 'routes')
|
104
|
+
if prefer :authorization, 'cancan'
|
105
|
+
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
106
|
+
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Admin Dashboard", "admin_app"]] unless prefs.has_key? :starter_app
|
107
|
+
elsif prefer :authentication, 'devise'
|
108
|
+
if prefer :orm, 'mongoid'
|
109
|
+
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
110
|
+
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Subdomains", "subdomains_app"]] unless prefs.has_key? :starter_app
|
111
|
+
else
|
112
|
+
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
113
|
+
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
|
114
|
+
end
|
115
|
+
elsif prefer :authentication, 'omniauth'
|
116
|
+
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
|
117
|
+
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
|
118
|
+
else
|
119
|
+
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"]] unless prefs.has_key? :starter_app
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# save diagnostics before anything can fail
|
124
|
+
create_file "README", "RECIPES\n#{recipes.sort.inspect}\n"
|
125
|
+
append_file "README", "PREFERENCES\n#{prefs.inspect}"
|
126
|
+
|
127
|
+
__END__
|
128
|
+
|
129
|
+
name: setup
|
130
|
+
description: "Make choices for your application."
|
131
|
+
author: RailsApps
|
132
|
+
|
133
|
+
run_after: [git, railsapps]
|
134
|
+
category: configuration
|
data/recipes/testing.rb
ADDED
@@ -0,0 +1,276 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/testing.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
say_wizard "recipe running after 'bundle install'"
|
6
|
+
### TEST/UNIT ###
|
7
|
+
if prefer :unit_test, 'test_unit'
|
8
|
+
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
|
9
|
+
|
10
|
+
config.generators do |g|
|
11
|
+
#{"g.test_framework :test_unit, fixture_replacement: :fabrication" if prefer :fixtures, 'fabrication'}
|
12
|
+
#{"g.fixture_replacement :fabrication, dir: 'test/fabricators'" if prefer :fixtures, 'fabrication'}
|
13
|
+
end
|
14
|
+
|
15
|
+
RUBY
|
16
|
+
end
|
17
|
+
end
|
18
|
+
### RSPEC ###
|
19
|
+
if prefer :unit_test, 'rspec'
|
20
|
+
say_wizard "recipe installing RSpec"
|
21
|
+
generate 'rspec:install'
|
22
|
+
copy_from_repo 'spec/spec_helper.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
|
23
|
+
generate 'email_spec:steps' if prefer :integration, 'cucumber'
|
24
|
+
inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
|
25
|
+
inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
|
26
|
+
config.include(EmailSpec::Helpers)
|
27
|
+
config.include(EmailSpec::Matchers)
|
28
|
+
RUBY
|
29
|
+
end
|
30
|
+
run 'rm -rf test/' # Removing test folder (not needed for RSpec)
|
31
|
+
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
|
32
|
+
|
33
|
+
# don't generate RSpec tests for views and helpers
|
34
|
+
config.generators do |g|
|
35
|
+
#{"g.test_framework :rspec" if prefer :fixtures, 'none'}
|
36
|
+
#{"g.test_framework :rspec, fixture: true" unless prefer :fixtures, 'none'}
|
37
|
+
#{"g.fixture_replacement :factory_girl, dir: 'spec/factories'" if prefer :fixtures, 'factory_girl'}
|
38
|
+
#{"g.fixture_replacement :machinist" if prefer :fixtures, 'machinist'}
|
39
|
+
#{"g.fixture_replacement :fabrication" if prefer :fixtures, 'fabrication'}
|
40
|
+
g.view_specs false
|
41
|
+
g.helper_specs false
|
42
|
+
end
|
43
|
+
|
44
|
+
RUBY
|
45
|
+
end
|
46
|
+
## RSPEC AND MONGOID
|
47
|
+
if prefer :orm, 'mongoid'
|
48
|
+
# remove ActiveRecord artifacts
|
49
|
+
gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
|
50
|
+
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
|
51
|
+
# remove either possible occurrence of "require rails/test_unit/railtie"
|
52
|
+
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
|
53
|
+
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
|
54
|
+
# configure RSpec to use matchers from the mongoid-rspec gem
|
55
|
+
create_file 'spec/support/mongoid.rb' do
|
56
|
+
<<-RUBY
|
57
|
+
RSpec.configure do |config|
|
58
|
+
config.include Mongoid::Matchers
|
59
|
+
end
|
60
|
+
RUBY
|
61
|
+
end
|
62
|
+
end
|
63
|
+
## RSPEC AND DEVISE
|
64
|
+
if prefer :authentication, 'devise'
|
65
|
+
# add Devise test helpers
|
66
|
+
create_file 'spec/support/devise.rb' do
|
67
|
+
<<-RUBY
|
68
|
+
RSpec.configure do |config|
|
69
|
+
config.include Devise::TestHelpers, :type => :controller
|
70
|
+
end
|
71
|
+
RUBY
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
### CUCUMBER ###
|
76
|
+
if prefer :integration, 'cucumber'
|
77
|
+
say_wizard "recipe installing Cucumber"
|
78
|
+
generate "cucumber:install --capybara#{' --rspec' if prefer :unit_test, 'rspec'}#{' -D' if prefer :orm, 'mongoid'}"
|
79
|
+
# make it easy to run Cucumber for single features without adding "--require features" to the command line
|
80
|
+
gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
|
81
|
+
create_file 'features/support/email_spec.rb' do <<-RUBY
|
82
|
+
require 'email_spec/cucumber'
|
83
|
+
RUBY
|
84
|
+
end
|
85
|
+
## CUCUMBER AND MONGOID
|
86
|
+
if prefer :orm, 'mongoid'
|
87
|
+
gsub_file 'features/support/env.rb', /transaction/, "truncation"
|
88
|
+
inject_into_file 'features/support/env.rb', :after => 'begin' do
|
89
|
+
"\n DatabaseCleaner.orm = 'mongoid'"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
generate 'fabrication:cucumber_steps' if prefer :fixtures, 'fabrication'
|
93
|
+
end
|
94
|
+
## TURNIP
|
95
|
+
if prefer :integration, 'turnip'
|
96
|
+
append_file '.rspec', '-r turnip/rspec'
|
97
|
+
inject_into_file 'spec/spec_helper.rb', "require 'turnip/capybara'\n", :after => "require 'rspec/rails'\n"
|
98
|
+
create_file 'spec/acceptance/steps/.gitkeep'
|
99
|
+
end
|
100
|
+
## FIXTURE REPLACEMENTS
|
101
|
+
if prefer :fixtures, 'machinist'
|
102
|
+
say_wizard "generating blueprints file for 'machinist'"
|
103
|
+
generate 'machinist:install'
|
104
|
+
end
|
105
|
+
### GUARD
|
106
|
+
if prefer :continuous_testing, 'guard'
|
107
|
+
say_wizard "recipe initializing Guard"
|
108
|
+
run 'bundle exec guard init'
|
109
|
+
end
|
110
|
+
### GIT ###
|
111
|
+
git :add => '-A' if prefer :git, true
|
112
|
+
git :commit => '-qm "rails_apps_composer: testing framework"' if prefer :git, true
|
113
|
+
end # after_bundler
|
114
|
+
|
115
|
+
after_everything do
|
116
|
+
say_wizard "recipe running after everything"
|
117
|
+
### RSPEC ###
|
118
|
+
if prefer :unit_test, 'rspec'
|
119
|
+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
|
120
|
+
say_wizard "copying RSpec files from the rails3-devise-rspec-cucumber examples"
|
121
|
+
repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
|
122
|
+
copy_from_repo 'spec/factories/users.rb', :repo => repo
|
123
|
+
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
124
|
+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
|
125
|
+
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
|
126
|
+
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
|
127
|
+
remove_file 'spec/views/home/index.html.erb_spec.rb'
|
128
|
+
remove_file 'spec/views/home/index.html.haml_spec.rb'
|
129
|
+
remove_file 'spec/views/users/show.html.erb_spec.rb'
|
130
|
+
remove_file 'spec/views/users/show.html.haml_spec.rb'
|
131
|
+
remove_file 'spec/helpers/home_helper_spec.rb'
|
132
|
+
remove_file 'spec/helpers/users_helper_spec.rb'
|
133
|
+
end
|
134
|
+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
|
135
|
+
say_wizard "copying RSpec files from the rails3-bootstrap-devise-cancan examples"
|
136
|
+
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
|
137
|
+
copy_from_repo 'spec/factories/users.rb', :repo => repo
|
138
|
+
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
139
|
+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
|
140
|
+
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
|
141
|
+
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
|
142
|
+
remove_file 'spec/views/home/index.html.erb_spec.rb'
|
143
|
+
remove_file 'spec/views/home/index.html.haml_spec.rb'
|
144
|
+
remove_file 'spec/views/users/show.html.erb_spec.rb'
|
145
|
+
remove_file 'spec/views/users/show.html.haml_spec.rb'
|
146
|
+
remove_file 'spec/helpers/home_helper_spec.rb'
|
147
|
+
remove_file 'spec/helpers/users_helper_spec.rb'
|
148
|
+
end
|
149
|
+
## RSPEC AND OMNIAUTH
|
150
|
+
if (prefer :authentication, 'omniauth') && (prefer :starter_app, 'users_app')
|
151
|
+
say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples"
|
152
|
+
repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
|
153
|
+
copy_from_repo 'spec/factories/users.rb', :repo => repo
|
154
|
+
copy_from_repo 'spec/controllers/sessions_controller_spec.rb', :repo => repo
|
155
|
+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
|
156
|
+
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
|
157
|
+
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
|
158
|
+
end
|
159
|
+
## SUBDOMAINS
|
160
|
+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app')
|
161
|
+
say_wizard "copying RSpec files from the rails3-subdomains examples"
|
162
|
+
repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
|
163
|
+
copy_from_repo 'spec/factories/users.rb', :repo => repo
|
164
|
+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
|
165
|
+
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
|
166
|
+
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
|
167
|
+
end
|
168
|
+
## GIT
|
169
|
+
git :add => '-A' if prefer :git, true
|
170
|
+
git :commit => '-qm "rails_apps_composer: rspec files"' if prefer :git, true
|
171
|
+
end
|
172
|
+
### CUCUMBER ###
|
173
|
+
if prefer :integration, 'cucumber'
|
174
|
+
## CUCUMBER AND DEVISE (USERS APP)
|
175
|
+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
|
176
|
+
say_wizard "copying Cucumber scenarios from the rails3-devise-rspec-cucumber examples"
|
177
|
+
repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
|
178
|
+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
|
179
|
+
copy_from_repo 'features/users/sign_in.feature', :repo => repo
|
180
|
+
copy_from_repo 'features/users/sign_out.feature', :repo => repo
|
181
|
+
copy_from_repo 'features/users/sign_up.feature', :repo => repo
|
182
|
+
copy_from_repo 'features/users/user_edit.feature', :repo => repo
|
183
|
+
copy_from_repo 'features/users/user_show.feature', :repo => repo
|
184
|
+
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
|
185
|
+
copy_from_repo 'features/support/paths.rb', :repo => repo
|
186
|
+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
187
|
+
gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address."
|
188
|
+
inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do
|
189
|
+
<<-RUBY
|
190
|
+
Scenario: User has not confirmed account
|
191
|
+
Given I exist as an unconfirmed user
|
192
|
+
And I am not logged in
|
193
|
+
When I sign in with valid credentials
|
194
|
+
Then I see an unconfirmed account message
|
195
|
+
And I should be signed out
|
196
|
+
RUBY
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
## CUCUMBER AND DEVISE (ADMIN APP)
|
201
|
+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
|
202
|
+
say_wizard "copying Cucumber scenarios from the rails3-bootstrap-devise-cancan examples"
|
203
|
+
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
|
204
|
+
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
|
205
|
+
copy_from_repo 'features/users/sign_in.feature', :repo => repo
|
206
|
+
copy_from_repo 'features/users/sign_out.feature', :repo => repo
|
207
|
+
copy_from_repo 'features/users/sign_up.feature', :repo => repo
|
208
|
+
copy_from_repo 'features/users/user_edit.feature', :repo => repo
|
209
|
+
copy_from_repo 'features/users/user_show.feature', :repo => repo
|
210
|
+
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
|
211
|
+
copy_from_repo 'features/support/paths.rb', :repo => repo
|
212
|
+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
213
|
+
gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address."
|
214
|
+
inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do
|
215
|
+
<<-RUBY
|
216
|
+
Scenario: User has not confirmed account
|
217
|
+
Given I exist as an unconfirmed user
|
218
|
+
And I am not logged in
|
219
|
+
When I sign in with valid credentials
|
220
|
+
Then I see an unconfirmed account message
|
221
|
+
And I should be signed out
|
222
|
+
RUBY
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
## CUCUMBER AND DEVISE (SUBDOMAINS APP)
|
227
|
+
if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app')
|
228
|
+
say_wizard "copying RSpec files from the rails3-subdomains examples"
|
229
|
+
repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
|
230
|
+
copy_from_repo 'features/users/sign_in.feature', :repo => repo
|
231
|
+
copy_from_repo 'features/users/sign_out.feature', :repo => repo
|
232
|
+
copy_from_repo 'features/users/sign_up.feature', :repo => repo
|
233
|
+
copy_from_repo 'features/users/user_edit.feature', :repo => repo
|
234
|
+
copy_from_repo 'features/users/user_show.feature', :repo => repo
|
235
|
+
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
|
236
|
+
copy_from_repo 'features/support/paths.rb', :repo => repo
|
237
|
+
end
|
238
|
+
## GIT
|
239
|
+
git :add => '-A' if prefer :git, true
|
240
|
+
git :commit => '-qm "rails_apps_composer: cucumber files"' if prefer :git, true
|
241
|
+
end
|
242
|
+
### FABRICATION ###
|
243
|
+
if prefer :fixtures, 'fabrication'
|
244
|
+
say_wizard "replacing FactoryGirl fixtures with Fabrication"
|
245
|
+
remove_file 'spec/factories/users.rb'
|
246
|
+
remove_file 'spec/fabricators/user_fabricator.rb'
|
247
|
+
create_file 'spec/fabricators/user_fabricator.rb' do
|
248
|
+
<<-RUBY
|
249
|
+
Fabricator(:user) do
|
250
|
+
name 'Test User'
|
251
|
+
email 'example@example.com'
|
252
|
+
password 'changeme'
|
253
|
+
password_confirmation 'changeme'
|
254
|
+
# required if the Devise Confirmable module is used
|
255
|
+
# confirmed_at Time.now
|
256
|
+
end
|
257
|
+
RUBY
|
258
|
+
end
|
259
|
+
if prefer :integration, 'cucumber'
|
260
|
+
gsub_file 'features/step_definitions/user_steps.rb', /@user = FactoryGirl.create\(:user, email: @visitor\[:email\]\)/, '@user = Fabricate(:user, email: @visitor[:email])'
|
261
|
+
end
|
262
|
+
if File.exist?('spec/controllers/users_controller_spec.rb')
|
263
|
+
gsub_file 'spec/controllers/users_controller_spec.rb', /@user = FactoryGirl.create\(:user\)/, '@user = Fabricate(:user)'
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end # after_everything
|
267
|
+
|
268
|
+
__END__
|
269
|
+
|
270
|
+
name: testing
|
271
|
+
description: "Add testing framework."
|
272
|
+
author: RailsApps
|
273
|
+
|
274
|
+
requires: [setup, gems]
|
275
|
+
run_after: [setup, gems]
|
276
|
+
category: testing
|
data/recipes/views.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/views.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
say_wizard "recipe running after 'bundle install'"
|
6
|
+
### DEVISE ###
|
7
|
+
if prefer :authentication, 'devise'
|
8
|
+
copy_from_repo 'app/views/devise/shared/_links.html.erb'
|
9
|
+
unless prefer :form_builder, 'simple_form'
|
10
|
+
copy_from_repo 'app/views/devise/registrations/edit.html.erb'
|
11
|
+
copy_from_repo 'app/views/devise/registrations/new.html.erb'
|
12
|
+
else
|
13
|
+
copy_from_repo 'app/views/devise/registrations/edit-simple_form.html.erb', :prefs => 'simple_form'
|
14
|
+
copy_from_repo 'app/views/devise/registrations/new-simple_form.html.erb', :prefs => 'simple_form'
|
15
|
+
copy_from_repo 'app/views/devise/sessions/new-simple_form.html.erb', :prefs => 'simple_form'
|
16
|
+
copy_from_repo 'app/helpers/application_helper-simple_form.rb', :prefs => 'simple_form'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
### HOME ###
|
20
|
+
copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'users_app'
|
21
|
+
copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'admin_app'
|
22
|
+
copy_from_repo 'app/views/home/index-subdomains_app.html.erb', :prefs => 'subdomains_app'
|
23
|
+
### USERS ###
|
24
|
+
if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
|
25
|
+
## INDEX
|
26
|
+
if prefer :starter_app, 'admin_app'
|
27
|
+
copy_from_repo 'app/views/users/index-admin_app.html.erb', :prefs => 'admin_app'
|
28
|
+
unless prefer :form_builder, 'simple_form'
|
29
|
+
copy_from_repo 'app/views/users/_user.html.erb'
|
30
|
+
else
|
31
|
+
copy_from_repo 'app/views/users/_user-simple_form.html.erb', :prefs => 'simple_form'
|
32
|
+
end
|
33
|
+
else
|
34
|
+
copy_from_repo 'app/views/users/index.html.erb'
|
35
|
+
end
|
36
|
+
## SHOW
|
37
|
+
copy_from_repo 'app/views/users/show.html.erb'
|
38
|
+
copy_from_repo 'app/views/users/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
|
39
|
+
## EDIT
|
40
|
+
copy_from_repo 'app/views/users/edit-omniauth.html.erb', :prefs => 'omniauth'
|
41
|
+
end
|
42
|
+
### PROFILES ###
|
43
|
+
copy_from_repo 'app/views/profiles/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
|
44
|
+
### GIT ###
|
45
|
+
git :add => '-A' if prefer :git, true
|
46
|
+
git :commit => '-qm "rails_apps_composer: views"' if prefer :git, true
|
47
|
+
end # after_bundler
|
48
|
+
|
49
|
+
__END__
|
50
|
+
|
51
|
+
name: views
|
52
|
+
description: "Add views needed for starter apps."
|
53
|
+
author: RailsApps
|
54
|
+
|
55
|
+
requires: [setup, gems, models, controllers]
|
56
|
+
run_after: [setup, gems, models, controllers]
|
57
|
+
category: mvc
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RailsWizard::Config do
|
4
|
+
describe '#initialize' do
|
5
|
+
let(:defaults) { nil }
|
6
|
+
subject{ RailsWizard::Config.new(YAML.load(@schema), defaults) }
|
7
|
+
it 'should add a question key for each key of the schema' do
|
8
|
+
@schema = <<-YAML
|
9
|
+
- test:
|
10
|
+
type: string
|
11
|
+
YAML
|
12
|
+
subject.questions.should be_key('test')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should instantiate the correct question type for each question' do
|
16
|
+
@schema = <<-YAML
|
17
|
+
- string:
|
18
|
+
type: string
|
19
|
+
- boolean:
|
20
|
+
type: boolean
|
21
|
+
- multiple_choice:
|
22
|
+
type: multiple_choice
|
23
|
+
YAML
|
24
|
+
subject.questions['string'].should be_kind_of(RailsWizard::Config::Prompt)
|
25
|
+
subject.questions['boolean'].should be_kind_of(RailsWizard::Config::TrueFalse)
|
26
|
+
subject.questions['multiple_choice'].should be_kind_of(RailsWizard::Config::MultipleChoice)
|
27
|
+
end
|
28
|
+
|
29
|
+
# it 'should error on invalid question type' do
|
30
|
+
# @schema = <<-YAML
|
31
|
+
# - invalid
|
32
|
+
# type: invalid
|
33
|
+
# YAML
|
34
|
+
# lambda{ subject }.should raise_error(ArgumentError)
|
35
|
+
# end
|
36
|
+
|
37
|
+
describe '#compile' do
|
38
|
+
let(:lines) { subject.compile.split("\n") }
|
39
|
+
before do
|
40
|
+
@schema = <<-YAML
|
41
|
+
- string:
|
42
|
+
type: string
|
43
|
+
prompt: Give me a string?
|
44
|
+
if: is_true
|
45
|
+
- boolean:
|
46
|
+
type: boolean
|
47
|
+
prompt: Yes or no?
|
48
|
+
unless: is_false
|
49
|
+
if_recipe: awesome
|
50
|
+
- multiple_choice:
|
51
|
+
type: multiple_choice
|
52
|
+
choices: [[ABC, abc], [DEF, def]]
|
53
|
+
unless_recipe: awesome
|
54
|
+
YAML
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should include all questions' do
|
58
|
+
lines.size.should == 4
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should handle "if"' do
|
62
|
+
lines[1].should be_include("config['is_true']")
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should handle "unless"' do
|
66
|
+
lines[2].should be_include("!config['is_false']")
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should handle "if_recipe"' do
|
70
|
+
lines[2].should be_include("recipe?('awesome')")
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should handle "unelss_recipe"' do
|
74
|
+
lines[3].should be_include("!recipe?('awesome')")
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'with defaults' do
|
78
|
+
let(:defaults) { { 'multiple_choice' => 'def' }}
|
79
|
+
|
80
|
+
it 'should process defaults' do
|
81
|
+
lines[0].should == 'config = {"multiple_choice"=>"def"}'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe RailsWizard::Config::Prompt do
|
87
|
+
subject{ RailsWizard::Config::Prompt }
|
88
|
+
it 'should compile to a prompt' do
|
89
|
+
subject.new({'prompt' => "What's your favorite color?"}).question.should == 'ask_wizard("What\'s your favorite color?")'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe RailsWizard::Config::TrueFalse do
|
94
|
+
subject{ RailsWizard::Config::TrueFalse }
|
95
|
+
it 'should compile to a yes? question' do
|
96
|
+
subject.new({'prompt' => 'Yes yes?'}).question.should == 'yes_wizard?("Yes yes?")'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe RailsWizard::Config::MultipleChoice do
|
101
|
+
subject{ RailsWizard::Config::MultipleChoice }
|
102
|
+
it 'should compile into a multiple_choice' do
|
103
|
+
subject.new({'prompt' => 'What kind of fruit?', 'choices' => [['Apples', 'apples'], ['Bananas', 'bananas']]}).question.should ==
|
104
|
+
'multiple_choice("What kind of fruit?", [["Apples", "apples"], ["Bananas", "bananas"]])'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|