redmint_composer 2.3
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 +10 -0
- data/bin/redmint_composer +7 -0
- data/lib/rails_wizard.rb +7 -0
- data/lib/rails_wizard/command.rb +204 -0
- data/lib/rails_wizard/config.rb +88 -0
- data/lib/rails_wizard/diagnostics.rb +58 -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/recipes/admin.rb +42 -0
- data/recipes/analytics.rb +41 -0
- data/recipes/core.rb +32 -0
- data/recipes/deployment.rb +178 -0
- data/recipes/devise.rb +34 -0
- data/recipes/email.rb +65 -0
- data/recipes/email_dev.rb +92 -0
- data/recipes/example.rb +63 -0
- data/recipes/extras.rb +283 -0
- data/recipes/frontend.rb +33 -0
- data/recipes/gems.rb +274 -0
- data/recipes/git.rb +27 -0
- data/recipes/init.rb +179 -0
- data/recipes/learn_rails.rb +89 -0
- data/recipes/locale.rb +31 -0
- data/recipes/omniauth.rb +38 -0
- data/recipes/pages.rb +91 -0
- data/recipes/rails_bootstrap.rb +29 -0
- data/recipes/rails_devise.rb +26 -0
- data/recipes/rails_devise_pundit.rb +25 -0
- data/recipes/rails_devise_roles.rb +25 -0
- data/recipes/rails_foundation.rb +29 -0
- data/recipes/rails_mailinglist_activejob.rb +76 -0
- data/recipes/rails_omniauth.rb +27 -0
- data/recipes/rails_signup_download.rb +69 -0
- data/recipes/rails_stripe_checkout.rb +84 -0
- data/recipes/rails_stripe_coupons.rb +125 -0
- data/recipes/rails_stripe_membership_saas.rb +112 -0
- data/recipes/railsapps.rb +77 -0
- data/recipes/readme.rb +161 -0
- data/recipes/roles.rb +40 -0
- data/recipes/setup.rb +162 -0
- data/recipes/tests.rb +59 -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 +138 -0
- data/templates/layout.erb +231 -0
- data/templates/recipe.erb +13 -0
- data/version.rb +3 -0
- metadata +201 -0
data/recipes/readme.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb
|
3
|
+
|
4
|
+
stage_three do
|
5
|
+
say_wizard "recipe stage three"
|
6
|
+
|
7
|
+
# remove default READMEs
|
8
|
+
%w{
|
9
|
+
README
|
10
|
+
README.rdoc
|
11
|
+
doc/README_FOR_APP
|
12
|
+
}.each { |file| remove_file file }
|
13
|
+
|
14
|
+
# add diagnostics to README
|
15
|
+
create_file 'README', "#{app_name.humanize.titleize}\n================\n\n"
|
16
|
+
append_to_file 'README' do <<-TEXT
|
17
|
+
Rails Composer, open source, supported by subscribers.
|
18
|
+
Please join RailsApps to support development of Rails Composer.
|
19
|
+
Need help? Ask on Stack Overflow with the tag 'railsapps.'
|
20
|
+
Problems? Submit an issue: https://github.com/RailsApps/rails_apps_composer/issues
|
21
|
+
Your application contains diagnostics in this README file.
|
22
|
+
Please provide a copy of this README file when reporting any issues.
|
23
|
+
\n
|
24
|
+
TEXT
|
25
|
+
end
|
26
|
+
append_to_file 'README' do <<-TEXT
|
27
|
+
option Build a starter application?
|
28
|
+
choose Enter your selection: [#{prefs[:apps4]}]
|
29
|
+
option Get on the mailing list for Rails Composer news?
|
30
|
+
choose Enter your selection: [#{prefs[:announcements]}]
|
31
|
+
option Web server for development?
|
32
|
+
choose Enter your selection: [#{prefs[:dev_webserver]}]
|
33
|
+
option Web server for production?
|
34
|
+
choose Enter your selection: [#{prefs[:prod_webserver]}]
|
35
|
+
option Database used in development?
|
36
|
+
choose Enter your selection: [#{prefs[:database]}]
|
37
|
+
option Template engine?
|
38
|
+
choose Enter your selection: [#{prefs[:templates]}]
|
39
|
+
option Test framework?
|
40
|
+
choose Enter your selection: [#{prefs[:tests]}]
|
41
|
+
option Continuous testing?
|
42
|
+
choose Enter your selection: [#{prefs[:continuous_testing]}]
|
43
|
+
option Front-end framework?
|
44
|
+
choose Enter your selection: [#{prefs[:frontend]}]
|
45
|
+
option Add support for sending email?
|
46
|
+
choose Enter your selection: [#{prefs[:email]}]
|
47
|
+
option Authentication?
|
48
|
+
choose Enter your selection: [#{prefs[:authentication]}]
|
49
|
+
option Devise modules?
|
50
|
+
choose Enter your selection: [#{prefs[:devise_modules]}]
|
51
|
+
option OmniAuth provider?
|
52
|
+
choose Enter your selection: [#{prefs[:omniauth_provider]}]
|
53
|
+
option Authorization?
|
54
|
+
choose Enter your selection: [#{prefs[:authorization]}]
|
55
|
+
option Use a form builder gem?
|
56
|
+
choose Enter your selection: [#{prefs[:form_builder]}]
|
57
|
+
option Add pages?
|
58
|
+
choose Enter your selection: [#{prefs[:pages]}]
|
59
|
+
option Set a locale?
|
60
|
+
choose Enter your selection: [#{prefs[:locale]}]
|
61
|
+
option Install page-view analytics?
|
62
|
+
choose Enter your selection: [#{prefs[:analytics]}]
|
63
|
+
option Add a deployment mechanism?
|
64
|
+
choose Enter your selection: [#{prefs[:deployment]}]
|
65
|
+
option Set a robots.txt file to ban spiders?
|
66
|
+
choose Enter your selection: [#{prefs[:ban_spiders]}]
|
67
|
+
option Create a GitHub repository? (y/n)
|
68
|
+
choose Enter your selection: [#{prefs[:github]}]
|
69
|
+
option Add gem and file for environment variables?
|
70
|
+
choose Enter your selection: [#{prefs[:local_env_file]}]
|
71
|
+
option Reduce assets logger noise during development?
|
72
|
+
choose Enter your selection: [#{prefs[:quiet_assets]}]
|
73
|
+
option Improve error reporting with 'better_errors' during development?
|
74
|
+
choose Enter your selection: [#{prefs[:better_errors]}]
|
75
|
+
option Use 'pry' as console replacement during development and test?
|
76
|
+
choose Enter your selection: [#{prefs[:pry]}]
|
77
|
+
option Use or create a project-specific rvm gemset?
|
78
|
+
choose Enter your selection: [#{prefs[:rvmrc]}]
|
79
|
+
TEXT
|
80
|
+
end
|
81
|
+
|
82
|
+
create_file 'public/humans.txt' do <<-TEXT
|
83
|
+
/* the humans responsible & colophon */
|
84
|
+
/* humanstxt.org */
|
85
|
+
|
86
|
+
|
87
|
+
/* TEAM */
|
88
|
+
<your title>: <your name>
|
89
|
+
Site:
|
90
|
+
Twitter:
|
91
|
+
Location:
|
92
|
+
|
93
|
+
/* SITE */
|
94
|
+
Standards: HTML5, CSS3
|
95
|
+
Components: jQuery
|
96
|
+
Software: Ruby on Rails
|
97
|
+
TEXT
|
98
|
+
end
|
99
|
+
|
100
|
+
create_file 'README.md', "#{app_name.humanize.titleize}\n================\n\n"
|
101
|
+
|
102
|
+
if prefer :deployment, 'heroku'
|
103
|
+
append_to_file 'README.md' do <<-TEXT
|
104
|
+
[](https://heroku.com/deploy)
|
105
|
+
|
106
|
+
TEXT
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
append_to_file 'README.md' do <<-TEXT
|
111
|
+
This application was generated with the [redmint_composer](https://github.com/adrianescat/redmint_composer) gem
|
112
|
+
based on rails_apps_composer gem provided by [RailsApps Project](http://railsapps.github.io/).
|
113
|
+
|
114
|
+
Rails Composer is open source and supported by subscribers. Please join RailsApps to support development of Rails Composer.
|
115
|
+
|
116
|
+
Ruby on Rails
|
117
|
+
-------------
|
118
|
+
|
119
|
+
This application requires:
|
120
|
+
|
121
|
+
- Ruby #{RUBY_VERSION}
|
122
|
+
- Rails #{Rails::VERSION::STRING}
|
123
|
+
|
124
|
+
|
125
|
+
Getting Started
|
126
|
+
---------------
|
127
|
+
|
128
|
+
Documentation and Support
|
129
|
+
-------------------------
|
130
|
+
|
131
|
+
Issues
|
132
|
+
-------------
|
133
|
+
|
134
|
+
Similar Projects
|
135
|
+
----------------
|
136
|
+
|
137
|
+
Contributing
|
138
|
+
------------
|
139
|
+
|
140
|
+
Credits
|
141
|
+
-------
|
142
|
+
|
143
|
+
License
|
144
|
+
-------
|
145
|
+
TEXT
|
146
|
+
end
|
147
|
+
|
148
|
+
git :add => '-A' if prefer :git, true
|
149
|
+
git :commit => '-qm "rails_apps_composer: add README files"' if prefer :git, true
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
__END__
|
154
|
+
|
155
|
+
name: readme
|
156
|
+
description: "Build a README file for your application."
|
157
|
+
author: RailsApps
|
158
|
+
|
159
|
+
requires: [setup]
|
160
|
+
run_after: [setup]
|
161
|
+
category: configuration
|
data/recipes/roles.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/roles.rb
|
3
|
+
|
4
|
+
stage_two do
|
5
|
+
say_wizard "recipe stage two"
|
6
|
+
if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit')
|
7
|
+
if prefer :authentication, 'none'
|
8
|
+
generate 'model User email:string'
|
9
|
+
run 'bundle exec rake db:migrate'
|
10
|
+
end
|
11
|
+
generate 'migration AddRoleToUsers role:integer'
|
12
|
+
role_boilerplate = " enum role: [:user, :admin]\n after_initialize :set_default_role, :if => :new_record?\n\n"
|
13
|
+
role_boilerplate << " def set_default_role\n self.role ||= :user\n end\n\n" if prefer :authentication, 'devise'
|
14
|
+
if prefer :authentication, 'omniauth'
|
15
|
+
role_boilerplate << <<-RUBY
|
16
|
+
def set_default_role
|
17
|
+
if User.count == 0
|
18
|
+
self.role ||= :admin
|
19
|
+
else
|
20
|
+
self.role ||= :user
|
21
|
+
end
|
22
|
+
end
|
23
|
+
RUBY
|
24
|
+
end
|
25
|
+
inject_into_class 'app/models/user.rb', 'User', role_boilerplate
|
26
|
+
end
|
27
|
+
### GIT ###
|
28
|
+
git :add => '-A' if prefer :git, true
|
29
|
+
git :commit => '-qm "redmint_composer: add roles to a User model"' if prefer :git, true
|
30
|
+
end
|
31
|
+
|
32
|
+
__END__
|
33
|
+
|
34
|
+
name: roles
|
35
|
+
description: "Add roles to a User model"
|
36
|
+
author: RailsApps
|
37
|
+
|
38
|
+
requires: [setup, gems, devise, omniauth]
|
39
|
+
run_after: [setup, gems, devise, omniauth]
|
40
|
+
category: mvc
|
data/recipes/setup.rb
ADDED
@@ -0,0 +1,162 @@
|
|
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"], ["Phusion Passenger (Apache/Nginx)", "passenger"],
|
17
|
+
["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :dev_webserver
|
18
|
+
prefs[:prod_webserver] = multiple_choice "Web server for production?", [["Same as development", "same"],
|
19
|
+
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"], ["Phusion Passenger (Apache/Nginx)", "passenger"],
|
20
|
+
["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :prod_webserver
|
21
|
+
prefs[:prod_webserver] = prefs[:dev_webserver] if prefs[:prod_webserver] == 'same'
|
22
|
+
|
23
|
+
## Database Adapter
|
24
|
+
prefs[:database] = "sqlite" if prefer :database, 'default'
|
25
|
+
prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"],
|
26
|
+
["MySQL", "mysql"]] unless prefs.has_key? :database
|
27
|
+
|
28
|
+
## Template Engine
|
29
|
+
prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates
|
30
|
+
|
31
|
+
## Testing Framework
|
32
|
+
if recipes.include? 'tests'
|
33
|
+
prefs[:tests] = multiple_choice "Test framework?", [["None", "none"],
|
34
|
+
["RSpec with Capybara", "rspec"]] unless prefs.has_key? :tests
|
35
|
+
case prefs[:tests]
|
36
|
+
when 'rspec'
|
37
|
+
say_wizard "Adding DatabaseCleaner, FactoryGirl, Faker, Launchy, Selenium"
|
38
|
+
prefs[:continuous_testing] = multiple_choice "Continuous testing?", [["None", "none"], ["Guard", "guard"]] unless prefs.has_key? :continuous_testing
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
## Front-end Framework
|
43
|
+
if recipes.include? 'frontend'
|
44
|
+
prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"],
|
45
|
+
["Bootstrap 3.3", "bootstrap3"], ["Bootstrap 2.3", "bootstrap2"],
|
46
|
+
["Zurb Foundation 5.5", "foundation5"], ["Zurb Foundation 4.0", "foundation4"],
|
47
|
+
["Simple CSS", "simple"]] unless prefs.has_key? :frontend
|
48
|
+
end
|
49
|
+
|
50
|
+
## Email
|
51
|
+
if recipes.include? 'email'
|
52
|
+
unless prefs.has_key? :email
|
53
|
+
say_wizard "The Devise 'forgot password' feature requires email." if prefer :authentication, 'devise'
|
54
|
+
prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"],
|
55
|
+
["SendGrid","sendgrid"], ["Mandrill","mandrill"]]
|
56
|
+
end
|
57
|
+
else
|
58
|
+
prefs[:email] = 'none'
|
59
|
+
end
|
60
|
+
|
61
|
+
## Authentication and Authorization
|
62
|
+
if (recipes.include? 'devise') || (recipes.include? 'omniauth')
|
63
|
+
prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication
|
64
|
+
case prefs[:authentication]
|
65
|
+
when 'devise'
|
66
|
+
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"],
|
67
|
+
["Devise with Confirmable module","confirmable"],
|
68
|
+
["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules
|
69
|
+
when 'omniauth'
|
70
|
+
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"],
|
71
|
+
["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
|
72
|
+
end
|
73
|
+
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["Simple role-based", "roles"], ["Pundit", "pundit"]] unless prefs.has_key? :authorization
|
74
|
+
if prefer :authentication, 'devise'
|
75
|
+
if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit')
|
76
|
+
prefs[:dashboard] = multiple_choice "Admin interface for database?", [["None", "none"], ["Upmin", "upmin"]] unless prefs.has_key? :dashboard
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
## Form Builder
|
82
|
+
prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder
|
83
|
+
|
84
|
+
## Pages
|
85
|
+
if recipes.include? 'pages'
|
86
|
+
prefs[:pages] = multiple_choice "Add pages?", [["None", "none"],
|
87
|
+
["Home", "home"], ["Home and About", "about"],
|
88
|
+
["Home and Users", "users"],
|
89
|
+
["Home, About, and Users", "about+users"]] unless prefs.has_key? :pages
|
90
|
+
end
|
91
|
+
|
92
|
+
## Bootstrap Page Templates
|
93
|
+
if recipes.include? 'pages'
|
94
|
+
if prefs[:frontend] == 'bootstrap3'
|
95
|
+
prefs[:layouts] = multiple_choice "Add Bootstrap page templates?", [["None", "none"],
|
96
|
+
["1 Col Portfolio", "one_col_portfolio"],
|
97
|
+
["2 Col Portfolio", "two_col_portfolio"],
|
98
|
+
["3 Col Portfolio", "three_col_portfolio"],
|
99
|
+
["4 Col Portfolio", "four_col_portfolio"],
|
100
|
+
["Bare", "bare"],
|
101
|
+
["Blog Home", "blog_home"],
|
102
|
+
["Business Casual", "business_casual"],
|
103
|
+
["Business Frontpage", "business_frontpage"],
|
104
|
+
["Clean Blog", "clean_blog"],
|
105
|
+
["Full Width Pics", "full_width_pics"],
|
106
|
+
["Heroic Features", "heroic_features"],
|
107
|
+
["Landing Page", "landing_page"],
|
108
|
+
["Modern Business", "modern_business"],
|
109
|
+
["One Page Wonder", "one_page_wonder"],
|
110
|
+
["Portfolio Item", "portfolio_item"],
|
111
|
+
["Round About", "round_about"],
|
112
|
+
["Shop Homepage", "shop_homepage"],
|
113
|
+
["Shop Item", "shop_item"],
|
114
|
+
["Simple Sidebar", "simple_sidebar"],
|
115
|
+
["Small Business", "small_business"],
|
116
|
+
["Stylish Portfolio", "stylish_portfolio"],
|
117
|
+
["The Big Picture", "the_big_picture"],
|
118
|
+
["Thumbnail Gallery", "thumbnail_gallery"]] unless prefs.has_key? :layouts
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# save configuration before anything can fail
|
123
|
+
create_file 'config/railscomposer.yml', "# This application was generated with Rails Composer\n\n"
|
124
|
+
append_to_file 'config/railscomposer.yml' do <<-TEXT
|
125
|
+
apps4: [#{prefs[:apps4]}]
|
126
|
+
announcements: [#{prefs[:announcements]}]
|
127
|
+
dev_webserver: [#{prefs[:dev_webserver]}]
|
128
|
+
prod_webserver: [#{prefs[:prod_webserver]}]
|
129
|
+
database: [#{prefs[:database]}]
|
130
|
+
templates: [#{prefs[:templates]}]
|
131
|
+
tests: [#{prefs[:tests]}]
|
132
|
+
continuous_testing: [#{prefs[:continuous_testing]}]
|
133
|
+
frontend: [#{prefs[:frontend]}]
|
134
|
+
email: [#{prefs[:email]}]
|
135
|
+
authentication: [#{prefs[:authentication]}]
|
136
|
+
devise_modules: [#{prefs[:devise_modules]}]
|
137
|
+
omniauth_provider: [#{prefs[:omniauth_provider]}]
|
138
|
+
authorization: [#{prefs[:authorization]}]
|
139
|
+
form_builder: [#{prefs[:form_builder]}]
|
140
|
+
pages: [#{prefs[:pages]}]
|
141
|
+
layouts: [#{prefs[:layouts]}]
|
142
|
+
locale: [#{prefs[:locale]}]
|
143
|
+
analytics: [#{prefs[:analytics]}]
|
144
|
+
deployment: [#{prefs[:deployment]}]
|
145
|
+
ban_spiders: [#{prefs[:ban_spiders]}]
|
146
|
+
github: [#{prefs[:github]}]
|
147
|
+
local_env_file: [#{prefs[:local_env_file]}]
|
148
|
+
quiet_assets: [#{prefs[:quiet_assets]}]
|
149
|
+
better_errors: [#{prefs[:better_errors]}]
|
150
|
+
pry: [#{prefs[:pry]}]
|
151
|
+
rvmrc: [#{prefs[:rvmrc]}]
|
152
|
+
TEXT
|
153
|
+
end
|
154
|
+
|
155
|
+
__END__
|
156
|
+
|
157
|
+
name: setup
|
158
|
+
description: "Make choices for your application."
|
159
|
+
author: RailsApps
|
160
|
+
|
161
|
+
run_after: [git, railsapps]
|
162
|
+
category: configuration
|
data/recipes/tests.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Change the recipe here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/tests.rb
|
3
|
+
|
4
|
+
stage_two do
|
5
|
+
say_wizard "recipe stage two"
|
6
|
+
if prefer :tests, 'rspec'
|
7
|
+
say_wizard "recipe installing RSpec"
|
8
|
+
generate 'testing:configure rspec -f'
|
9
|
+
end
|
10
|
+
if prefer :continuous_testing, 'guard'
|
11
|
+
say_wizard "recipe initializing Guard"
|
12
|
+
run 'bundle exec guard init'
|
13
|
+
end
|
14
|
+
git :add => '-A' if prefer :git, true
|
15
|
+
git :commit => '-qm "redmint_composer: testing framework"' if prefer :git, true
|
16
|
+
end
|
17
|
+
|
18
|
+
stage_three do
|
19
|
+
say_wizard "recipe stage three"
|
20
|
+
if prefer :tests, 'rspec'
|
21
|
+
if prefer :authentication, 'devise'
|
22
|
+
generate 'testing:configure devise -f'
|
23
|
+
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
|
24
|
+
inject_into_file 'spec/factories/users.rb', " confirmed_at Time.now\n", :after => "factory :user do\n"
|
25
|
+
default_url = ' config.action_mailer.default_url_options = { :host => Rails.application.secrets.domain_name }'
|
26
|
+
inject_into_file 'config/environments/test.rb', default_url, :after => "delivery_method = :test\n"
|
27
|
+
gsub_file 'spec/features/users/user_edit_spec.rb', /successfully./, 'successfully,'
|
28
|
+
gsub_file 'spec/features/visitors/sign_up_spec.rb', /Welcome! You have signed up successfully./, 'A message with a confirmation'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
if prefer :authentication, 'omniauth'
|
32
|
+
generate 'testing:configure omniauth -f'
|
33
|
+
end
|
34
|
+
if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit')
|
35
|
+
generate 'testing:configure pundit -f'
|
36
|
+
remove_file 'spec/policies/user_policy_spec.rb' unless %w(users about+users).include?(prefs[:pages])
|
37
|
+
remove_file 'spec/policies/user_policy_spec.rb' if prefer :authorization, 'roles'
|
38
|
+
remove_file 'spec/support/pundit.rb' if prefer :authorization, 'roles'
|
39
|
+
if (prefer :authentication, 'devise') &&\
|
40
|
+
((prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable'))
|
41
|
+
inject_into_file 'spec/factories/users.rb', " confirmed_at Time.now\n", :after => "factory :user do\n"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
unless %w(users about+users).include?(prefs[:pages])
|
45
|
+
remove_file 'spec/features/users/user_index_spec.rb'
|
46
|
+
remove_file 'spec/features/users/user_show_spec.rb'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
__END__
|
52
|
+
|
53
|
+
name: tests
|
54
|
+
description: "Add testing framework."
|
55
|
+
author: RailsApps
|
56
|
+
|
57
|
+
requires: [setup, gems]
|
58
|
+
run_after: [setup, gems]
|
59
|
+
category: testing
|
@@ -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
|