make_it_so 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/Gemfile +16 -0
- data/lib/generators/rails_app_generator.rb +6 -0
- data/lib/make_it_so.rb +3 -0
- data/lib/make_it_so/command_line_interface.rb +3 -1
- data/lib/make_it_so/rails.rb +1 -2
- data/lib/make_it_so/rails/app_builder.rb +76 -65
- data/lib/make_it_so/rails/prerequisite_check.rb +29 -0
- data/lib/make_it_so/version.rb +1 -1
- data/snippets/rails/js_enzyme_testing_deps.json +6 -0
- data/snippets/rails/js_jest_testing_deps.json +22 -4
- data/snippets/rails/js_karma_jasmine_testing_deps.json +5 -4
- data/snippets/rails/react_dependencies.json +10 -7
- data/spec/features/rails/user_generates_rails_spec.rb +26 -20
- data/spec/features/rails/user_generates_rails_with_karma_spec.rb +14 -4
- data/templates/rails/babel.config.js +77 -0
- data/templates/rails/karma.conf.js +2 -4
- data/templates/rails/spec/javascript/example.test.js +5 -0
- data/templates/rails/spec/javascript/support/enzyme.js +1 -1
- data/templates/rails/spec/javascript/testHelper.js +0 -4
- metadata +7 -3
- data/templates/rails/.babelrc +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2c34aca2be98715b41417216c183fc283c06ef203a42945927e6fa71c35e027
|
4
|
+
data.tar.gz: b0e6c29001e305ae6978fd52d6b753e599d85c77e41610e483f83e0485e694c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e395f33577107fe638da218ed7a3fe068fce927c73098233d79ba64551b13a346ba0706cd9ca1de122b30d3e885ead9148e7c60e537c0e11b1295bab926d37b1
|
7
|
+
data.tar.gz: 43ee817cc5d04d3ad32c937c14137c9752c98f4c9aa24d376328a393007fd8771bbda8473f947962ed20a43fac4e7bcc2affdd3b6cfc937b17405e886a361350
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.5.1] - 2019-10-08
|
10
|
+
|
11
|
+
- skip bootsnap by default
|
12
|
+
- added prerequisite rails version check
|
13
|
+
- adjust webpacker routines to run `after_bundle`
|
14
|
+
- only stop spring if it is being installed
|
15
|
+
|
16
|
+
## [0.5.0] - 2019-09-02
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- `react-router` is now installed by default
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- `--karma` and `--jest` options have been removed in favor of a `--js-test-lib` param.
|
25
|
+
- The default behavior of `make_it_so` now generates `jest` as the default test lib instead of `karma`
|
26
|
+
- `foundation-rails` was updated to v6.5
|
27
|
+
- `modernizr` was removed
|
28
|
+
- Development runtime was upgraded to ruby v2.6.3
|
29
|
+
|
30
|
+
[Unreleased]:https://github.com/LaunchAcademy/make_it_so/compare/v0.5.0...HEAD
|
31
|
+
[0.5.1]:https://github.com/LaunchAcademy/make_it_so/compare/v0.5.0...v0.5.1
|
32
|
+
[0.5.0]:https://github.com/LaunchAcademy/make_it_so/compare/v0.4.5...v0.5.0
|
data/Gemfile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
require_relative 'lib/make_it_so/rails'
|
4
|
+
|
3
5
|
ruby '2.6.3'
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in make_it_so.gemspec
|
@@ -8,4 +10,18 @@ gemspec
|
|
8
10
|
group :development do
|
9
11
|
gem 'pry'
|
10
12
|
gem 'solargraph'
|
13
|
+
|
14
|
+
[
|
15
|
+
'rails',
|
16
|
+
'activejob',
|
17
|
+
'actionmailer'
|
18
|
+
].each do |gem_name|
|
19
|
+
gem gem_name, MakeItSo::Rails::VERSION
|
20
|
+
end
|
21
|
+
|
22
|
+
gem 'sprockets-rails', '3.0.4'
|
23
|
+
gem 'listen'
|
24
|
+
gem 'rspec-rails'
|
25
|
+
gem 'devise'
|
26
|
+
gem 'webpacker'
|
11
27
|
end
|
@@ -57,6 +57,12 @@ module MakeItSo
|
|
57
57
|
default: "jest",
|
58
58
|
desc:
|
59
59
|
"Generate Jest testing framework (default), Karma/Jasmine ('karma'), or no framework ('false')"
|
60
|
+
|
61
|
+
class_option :skip_bootsnap,
|
62
|
+
type: :boolean,
|
63
|
+
default: true,
|
64
|
+
desc:
|
65
|
+
"Skip bootsnap"
|
60
66
|
|
61
67
|
def initialize(*args)
|
62
68
|
super
|
data/lib/make_it_so.rb
CHANGED
@@ -6,7 +6,9 @@ module MakeItSo
|
|
6
6
|
option :devise, type: :boolean
|
7
7
|
option :js_test_lib, default: "jest"
|
8
8
|
def rails(app_name)
|
9
|
-
MakeItSo::
|
9
|
+
if MakeItSo::Rails::PrerequisiteCheck.new.check
|
10
|
+
MakeItSo::RailsAppGenerator.start(ARGV[1..-1])
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
desc "sinatra <app_name>",
|
data/lib/make_it_so/rails.rb
CHANGED
@@ -50,43 +50,41 @@ module MakeItSo
|
|
50
50
|
def react
|
51
51
|
@generator.gem 'webpacker', '~> 3.3'
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
unparsed_json = snippet('react_dependencies.json')
|
59
|
-
parsed_json = JSON.parse(unparsed_json)
|
60
|
-
|
61
|
-
modify_json(package_json_file) do |json|
|
62
|
-
["dependencies", "devDependencies"].each do |key|
|
63
|
-
json[key] ||= {}
|
64
|
-
json[key].merge!(parsed_json[key])
|
65
|
-
end
|
53
|
+
after_bundle do
|
54
|
+
rake 'webpacker:install'
|
55
|
+
rake 'webpacker:install:react'
|
56
|
+
remove_file 'app/javascript/packs/application.js'
|
57
|
+
remove_file 'app/javascript/packs/hello_react.jsx'
|
66
58
|
|
67
|
-
|
68
|
-
|
59
|
+
unparsed_json = snippet('react_dependencies.json')
|
60
|
+
parsed_json = JSON.parse(unparsed_json)
|
69
61
|
|
70
|
-
|
71
|
-
|
62
|
+
modify_json(package_json_file) do |json|
|
63
|
+
["dependencies", "devDependencies"].each do |key|
|
64
|
+
json[key] ||= {}
|
65
|
+
json[key].merge!(parsed_json[key])
|
66
|
+
end
|
72
67
|
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
json["scripts"] ||= {}
|
69
|
+
json["scripts"]["start"] = "./bin/webpack-dev-server"
|
70
|
+
|
71
|
+
json["dependencies"].delete("babel-preset-react")
|
72
|
+
end
|
73
|
+
|
74
|
+
inside 'app/javascript/packs' do
|
75
|
+
copy_file 'new_application.js', 'application.js'
|
76
|
+
remove_file 'new_application.js'
|
77
|
+
end
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
79
81
|
def karma
|
80
82
|
after_bundle do
|
81
|
-
|
82
|
-
|
83
|
+
add_test_dependency_snippets(
|
84
|
+
["js_karma_jasmine_testing_deps.json", "js_enzyme_testing_deps.json"]
|
85
|
+
)
|
83
86
|
|
84
|
-
|
85
|
-
json["devDependencies"] ||= {}
|
86
|
-
json["devDependencies"].merge!(parsed_json["devDependencies"])
|
87
|
-
json["scripts"] ||= {}
|
88
|
-
json["scripts"]["test"] = "node_modules/.bin/karma start karma.conf.js"
|
89
|
-
end
|
87
|
+
create_enzyme_config
|
90
88
|
|
91
89
|
template 'karma.conf.js'
|
92
90
|
inside 'spec/javascript' do
|
@@ -99,45 +97,22 @@ module MakeItSo
|
|
99
97
|
end
|
100
98
|
|
101
99
|
remove_file '.babelrc'
|
102
|
-
|
100
|
+
remove_file 'babel.config.js'
|
101
|
+
template 'babel.config.js'
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
106
105
|
def jest
|
107
106
|
after_bundle do
|
108
|
-
|
109
|
-
|
107
|
+
add_test_dependency_snippets(
|
108
|
+
["js_jest_testing_deps.json", "js_enzyme_testing_deps.json"]
|
109
|
+
)
|
110
110
|
|
111
|
-
|
112
|
-
inside 'spec/javascript/support' do
|
113
|
-
template 'enzyme.js'
|
114
|
-
end
|
115
|
-
|
116
|
-
modify_json(package_json_file) do |json|
|
117
|
-
json["devDependencies"] ||= {}
|
118
|
-
json["devDependencies"].merge!(parsed_json["devDependencies"])
|
119
|
-
json["scripts"] ||= {}
|
120
|
-
json["scripts"]["test"] = "node_modules/.bin/jest"
|
121
|
-
json["scripts"]["test:dev"] = "node_modules/.bin/jest --notify --watch"
|
122
|
-
json["jest"] ||= {}
|
123
|
-
json["jest"].merge!({
|
124
|
-
"automock": false,
|
125
|
-
"roots": [
|
126
|
-
"spec/javascript"
|
127
|
-
],
|
128
|
-
"moduleDirectories": [
|
129
|
-
"node_modules",
|
130
|
-
"app/javascript"
|
131
|
-
],
|
132
|
-
"setupFiles": [
|
133
|
-
"./spec/javascript/support/enzyme.js"
|
134
|
-
],
|
135
|
-
"testURL": "http://localhost/"
|
136
|
-
})
|
137
|
-
end
|
111
|
+
create_enzyme_config
|
138
112
|
|
139
113
|
remove_file '.babelrc'
|
140
|
-
|
114
|
+
remove_file 'babel.config.js'
|
115
|
+
template 'babel.config.js'
|
141
116
|
end
|
142
117
|
end
|
143
118
|
|
@@ -156,14 +131,16 @@ module MakeItSo
|
|
156
131
|
end
|
157
132
|
|
158
133
|
def rspec_dependency
|
159
|
-
@generator.gem 'rspec-rails', group: [:development, :test]
|
134
|
+
@generator.gem 'rspec-rails', '3.8.2', group: [:development, :test]
|
160
135
|
@generator.gem 'capybara', group: [:development, :test]
|
161
136
|
@generator.gem 'launchy', group: [:development, :test]
|
162
137
|
|
163
138
|
after_bundle do
|
164
|
-
|
165
|
-
|
166
|
-
|
139
|
+
if !options[:skip_spring]
|
140
|
+
#stop spring in case it is running - it will hang
|
141
|
+
#https://github.com/rails/rails/issues/13381
|
142
|
+
run 'spring stop'
|
143
|
+
end
|
167
144
|
generate 'rspec:install'
|
168
145
|
inside 'spec' do
|
169
146
|
empty_directory 'support'
|
@@ -229,8 +206,16 @@ module MakeItSo
|
|
229
206
|
group: [:development, :test],
|
230
207
|
require: false
|
231
208
|
after_bundle do
|
232
|
-
inside 'spec
|
233
|
-
|
209
|
+
inside 'spec' do
|
210
|
+
insert_into_file 'rails_helper.rb',
|
211
|
+
after: rails_helper_insertion_hook do
|
212
|
+
|
213
|
+
"require File.join(File.dirname(__FILE__), 'support/shoulda')\n"
|
214
|
+
end
|
215
|
+
|
216
|
+
inside 'support' do
|
217
|
+
template 'shoulda.rb'
|
218
|
+
end
|
234
219
|
end
|
235
220
|
end
|
236
221
|
end
|
@@ -294,6 +279,32 @@ module MakeItSo
|
|
294
279
|
PACKAGE_PATH = "package.json"
|
295
280
|
WEBCONFIG_PATH = "webpack.config.js"
|
296
281
|
|
282
|
+
def add_test_dependency_snippets(snippet_paths)
|
283
|
+
snippet_paths.each do |snippet_path|
|
284
|
+
snippet = snippet(snippet_path)
|
285
|
+
parsed_snippet = JSON.parse(snippet)
|
286
|
+
keys = parsed_snippet.keys
|
287
|
+
|
288
|
+
modify_json(package_json_file) do |json|
|
289
|
+
keys.each do |key|
|
290
|
+
json[key] ||= {}
|
291
|
+
json[key].merge!(parsed_snippet[key])
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def create_enzyme_config
|
298
|
+
run 'mkdir -p spec/javascript/support'
|
299
|
+
devDependencies = parsed_package_json["devDependencies"].keys
|
300
|
+
enzymeAdapter = devDependencies.select{ |d| d =~ /^enzyme-adapter-react-[0-9]*/ }[0]
|
301
|
+
|
302
|
+
inside 'spec/javascript/support' do
|
303
|
+
template 'enzyme.js'
|
304
|
+
gsub_file 'enzyme.js', 'ADAPTER NAME GOES HERE', enzymeAdapter
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
297
308
|
def parsed_package_json
|
298
309
|
@package_json ||= parse_json_file(package_json_file)
|
299
310
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
module MakeItSo
|
4
|
+
module Rails
|
5
|
+
class PrerequisiteCheck
|
6
|
+
include Thor::Base
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
def check
|
10
|
+
say "Checking Rails version...", :yellow
|
11
|
+
begin
|
12
|
+
require "rails"
|
13
|
+
puts ::Rails.version
|
14
|
+
if ::Rails.version != MakeItSo::Rails::VERSION
|
15
|
+
say "Rails versions check FAILED - execute the following", :red
|
16
|
+
say "gem uninstall rails railties activejob actionmailer -a && gem install rails -v #{MakeItSo::Rails::VERSION}"
|
17
|
+
return false
|
18
|
+
else
|
19
|
+
say "Rails version MATCH", :green
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
rescue LoadError => e
|
23
|
+
say "Rails not installed", :red
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/make_it_so/version.rb
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
|
-
"babel-jest": "
|
4
|
-
"enzyme": "~3.10.0",
|
5
|
-
"enzyme-adapter-react-16": "~1.14.0",
|
3
|
+
"babel-jest": "^24.9.0",
|
6
4
|
"fetch-mock": "~5.13.1",
|
7
|
-
"jest": "
|
5
|
+
"jest": "^24.9.0"
|
6
|
+
},
|
7
|
+
"scripts": {
|
8
|
+
"start": "./bin/webpack-dev-server",
|
9
|
+
"test": "node_modules/.bin/jest",
|
10
|
+
"test:dev": "node_modules/.bin/jest --notify --watch"
|
11
|
+
},
|
12
|
+
"jest": {
|
13
|
+
"automock": false,
|
14
|
+
"roots": [
|
15
|
+
"spec/javascript",
|
16
|
+
"app/javascript"
|
17
|
+
],
|
18
|
+
"moduleDirectories": [
|
19
|
+
"node_modules",
|
20
|
+
"app/javascript"
|
21
|
+
],
|
22
|
+
"setupFiles": [
|
23
|
+
"./spec/javascript/support/enzyme.js"
|
24
|
+
],
|
25
|
+
"testURL": "http://localhost/"
|
8
26
|
}
|
9
27
|
}
|
@@ -1,18 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
|
-
"enzyme": "~3.10.0",
|
4
|
-
"enzyme-adapter-react-16": "^1.14.0",
|
5
3
|
"fetch-mock": "5",
|
6
4
|
"fetch-ponyfill": "^6.0.2",
|
7
5
|
"jasmine-core": "~2.4.1",
|
8
6
|
"jasmine-enzyme": "~7.0.0",
|
9
7
|
"karma": "~0.13.22",
|
8
|
+
"karma-chrome-launcher": "^3.1.0",
|
10
9
|
"karma-coverage": "0.5.5",
|
11
10
|
"karma-jasmine": "~0.3.8",
|
12
11
|
"karma-phantomjs-launcher": "~1.0.4",
|
13
12
|
"karma-sourcemap-loader": "0.3.7",
|
14
13
|
"karma-spec-reporter": "0.0.26",
|
15
|
-
"karma-webpack": "2.0.1"
|
16
|
-
|
14
|
+
"karma-webpack": "2.0.1"
|
15
|
+
},
|
16
|
+
"scripts": {
|
17
|
+
"test": "node_modules/.bin/karma start karma.conf.js"
|
17
18
|
}
|
18
19
|
}
|
@@ -1,20 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"dependencies": {
|
3
|
-
"prop-types": "~15.6.0",
|
4
|
-
"react": "~16.8.0",
|
5
|
-
"react-dom": "~16.8.0",
|
6
|
-
"react-router-dom": "5.0.0",
|
7
|
-
"redbox-react": "1.6.0"
|
8
|
-
},
|
9
|
-
"devDependencies": {
|
10
3
|
"@babel/core": "^7.5.5",
|
11
4
|
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
12
5
|
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
13
6
|
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
7
|
+
"@babel/plugin-transform-destructuring": "^7.6.0",
|
8
|
+
"@babel/plugin-transform-regenerator": "^7.4.5",
|
14
9
|
"@babel/plugin-transform-runtime": "^7.5.5",
|
15
10
|
"@babel/preset-env": "^7.5.5",
|
16
11
|
"@babel/preset-react": "^7.0.0",
|
12
|
+
"@babel/runtime": "^7.6.2",
|
17
13
|
"babel-loader": "^8.0.6",
|
14
|
+
"prop-types": "~15.6.0",
|
15
|
+
"react": "~16.8.0",
|
16
|
+
"react-dom": "~16.8.0",
|
17
|
+
"react-router-dom": "5.0.0",
|
18
|
+
"redbox-react": "1.6.0"
|
19
|
+
},
|
20
|
+
"devDependencies": {
|
18
21
|
"webpack-cli": "^2.0.10",
|
19
22
|
"webpack-dev-server": "^2.11.1"
|
20
23
|
}
|
@@ -49,16 +49,6 @@ feature 'user generates rails app with default settings' do
|
|
49
49
|
expect(FileTest.exists?(join_paths(app_path, 'config/storage.yml'))).to eq(false)
|
50
50
|
end
|
51
51
|
|
52
|
-
scenario 'creates a valid gemfile' do
|
53
|
-
words = ['source', '#', 'gem', 'group', 'end', 'ruby']
|
54
|
-
|
55
|
-
File.readlines('Gemfile').each do |line|
|
56
|
-
unless line.strip.empty?
|
57
|
-
expect(line.strip.start_with?(*words)).to eq(true)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
52
|
context 'pry-rails' do
|
63
53
|
it 'is added as a dependency' do
|
64
54
|
expect(File.read(gemfile_path)).to match(/gem(.*)pry-rails/)
|
@@ -135,6 +125,11 @@ feature 'user generates rails app with default settings' do
|
|
135
125
|
it 'includes a shoulda file in the support directory' do
|
136
126
|
expect(FileTest.exists?(join_paths(app_path, 'spec/support/shoulda.rb')))
|
137
127
|
end
|
128
|
+
|
129
|
+
it 'requires the shoulda support file' do
|
130
|
+
expect(File.read(rails_spec_helper)).
|
131
|
+
to include("\nrequire File.join(File.dirname(__FILE__), 'support/shoulda')\n")
|
132
|
+
end
|
138
133
|
end
|
139
134
|
|
140
135
|
context 'database_cleaner' do
|
@@ -255,17 +250,22 @@ feature 'user generates rails app with default settings' do
|
|
255
250
|
context 'babel' do
|
256
251
|
it 'includes necessary babel packages in package.json as dev dependencies' do
|
257
252
|
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
258
|
-
expect(json["
|
259
|
-
expect(json["
|
260
|
-
expect(json["
|
261
|
-
expect(json["
|
253
|
+
expect(json["dependencies"]["@babel/core"]).to_not be_nil
|
254
|
+
expect(json["dependencies"]["@babel/preset-env"]).to_not be_nil
|
255
|
+
expect(json["dependencies"]["@babel/preset-react"]).to_not be_nil
|
256
|
+
expect(json["dependencies"]["babel-loader"]).to_not be_nil
|
262
257
|
end
|
263
258
|
end
|
264
259
|
|
265
|
-
it '
|
266
|
-
babelrc =
|
267
|
-
expect(babelrc).to
|
268
|
-
|
260
|
+
it 'does not create .babelrc' do
|
261
|
+
babelrc = File.join(app_path, '.babelrc')
|
262
|
+
expect(FileTest.exists?(babelrc)).to eq(false)
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'sets necessary presets in babel.config.js' do
|
266
|
+
babel_config = read_file('babel.config.js')
|
267
|
+
expect(babel_config).to include("@babel/env")
|
268
|
+
expect(babel_config).to include("@babel/react")
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
@@ -286,9 +286,15 @@ feature 'user generates rails app with default settings' do
|
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
289
|
-
it '
|
290
|
-
|
289
|
+
it 'includes enzyme.js with correct Enzyme config' do
|
290
|
+
file_subpath = "spec/javascript/support/enzyme.js"
|
291
|
+
support_file = File.join(app_path, file_subpath)
|
291
292
|
expect(FileTest.exists?(support_file)).to eq(true)
|
293
|
+
|
294
|
+
enzyme = read_file(file_subpath)
|
295
|
+
expect(enzyme).to include('require("enzyme-adapter-react-16")')
|
296
|
+
expect(enzyme).to include("Enzyme.configure")
|
297
|
+
expect(enzyme).to include("enzyme-adapter-react-16")
|
292
298
|
end
|
293
299
|
|
294
300
|
it 'adds spec/javascript/support/enzyme.js to setup' do
|
@@ -41,13 +41,23 @@ feature "user generates rails app with karma/jasmine" do
|
|
41
41
|
expect(read_file('.gitignore')).to include("coverage/*\n")
|
42
42
|
end
|
43
43
|
|
44
|
-
it '
|
44
|
+
it 'does not configure enzyme adapter in testHelper' do
|
45
45
|
testHelper = read_file('spec/javascript/testHelper.js')
|
46
|
-
expect(testHelper).
|
46
|
+
expect(testHelper).to_not include("Enzyme.configure({ adapter: new EnzymeAdapter() })")
|
47
47
|
end
|
48
48
|
|
49
|
-
it '
|
50
|
-
|
49
|
+
it 'includes enzyme.js with correct Enzyme config' do
|
50
|
+
file_subpath = "spec/javascript/support/enzyme.js"
|
51
|
+
support_file = File.join(app_path, file_subpath)
|
52
|
+
expect(FileTest.exists?(support_file)).to eq(true)
|
53
|
+
|
54
|
+
enzyme = read_file(file_subpath)
|
55
|
+
expect(enzyme).to include("Enzyme.configure")
|
56
|
+
expect(enzyme).to include("enzyme-adapter-react-16")
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'karma.conf.js does not use @babel/polyfill' do
|
60
|
+
expect(read_file('karma.conf.js')).to_not include("node_modules/@babel/polyfill/dist/polyfill.js")
|
51
61
|
end
|
52
62
|
|
53
63
|
it 'does not add jest as the test script in package.json' do
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module.exports = function(api) {
|
2
|
+
var validEnv = ['development', 'test', 'production']
|
3
|
+
var currentEnv = api.env()
|
4
|
+
var isDevelopmentEnv = api.env('development')
|
5
|
+
var isProductionEnv = api.env('production')
|
6
|
+
var isTestEnv = api.env('test')
|
7
|
+
|
8
|
+
if (!validEnv.includes(currentEnv)) {
|
9
|
+
throw new Error(
|
10
|
+
'Please specify a valid `NODE_ENV` or ' +
|
11
|
+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
|
12
|
+
'"test", and "production". Instead, received: ' +
|
13
|
+
JSON.stringify(currentEnv) +
|
14
|
+
'.'
|
15
|
+
)
|
16
|
+
}
|
17
|
+
|
18
|
+
return {
|
19
|
+
presets: [
|
20
|
+
isTestEnv && [
|
21
|
+
require('@babel/preset-env').default,
|
22
|
+
{
|
23
|
+
targets: {
|
24
|
+
node: 'current'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
],
|
28
|
+
(isProductionEnv || isDevelopmentEnv) && [
|
29
|
+
require('@babel/preset-env').default,
|
30
|
+
{
|
31
|
+
forceAllTransforms: true,
|
32
|
+
useBuiltIns: 'entry',
|
33
|
+
corejs: 3,
|
34
|
+
modules: false,
|
35
|
+
exclude: ['transform-typeof-symbol']
|
36
|
+
}
|
37
|
+
],
|
38
|
+
[
|
39
|
+
require('@babel/preset-react').default,
|
40
|
+
{
|
41
|
+
development: isDevelopmentEnv || isTestEnv,
|
42
|
+
useBuiltIns: true
|
43
|
+
}
|
44
|
+
]
|
45
|
+
].filter(Boolean),
|
46
|
+
plugins: [
|
47
|
+
require('@babel/plugin-syntax-dynamic-import').default,
|
48
|
+
require('@babel/plugin-transform-destructuring').default,
|
49
|
+
[
|
50
|
+
require('@babel/plugin-proposal-class-properties').default,
|
51
|
+
{
|
52
|
+
loose: true
|
53
|
+
}
|
54
|
+
],
|
55
|
+
[
|
56
|
+
require('@babel/plugin-proposal-object-rest-spread').default,
|
57
|
+
{
|
58
|
+
useBuiltIns: true
|
59
|
+
}
|
60
|
+
],
|
61
|
+
[
|
62
|
+
require('@babel/plugin-transform-runtime').default,
|
63
|
+
{
|
64
|
+
helpers: false,
|
65
|
+
regenerator: true,
|
66
|
+
corejs: false
|
67
|
+
}
|
68
|
+
],
|
69
|
+
[
|
70
|
+
require('@babel/plugin-transform-regenerator').default,
|
71
|
+
{
|
72
|
+
async: false
|
73
|
+
}
|
74
|
+
]
|
75
|
+
].filter(Boolean)
|
76
|
+
}
|
77
|
+
}
|
@@ -3,16 +3,14 @@ var path = require('path');
|
|
3
3
|
module.exports = function(config) {
|
4
4
|
config.set({
|
5
5
|
basePath: "",
|
6
|
-
// use the
|
7
|
-
browsers: ['
|
6
|
+
// use the Chrome Headless browser
|
7
|
+
browsers: ['ChromeHeadless'],
|
8
8
|
|
9
9
|
// use the Jasmine testing framework
|
10
10
|
frameworks: ['jasmine'],
|
11
11
|
|
12
12
|
// files that Karma will server to the browser
|
13
13
|
files: [
|
14
|
-
// use Babel polyfill to emulate a full ES6 environment in PhantomJS
|
15
|
-
'node_modules/@babel/polyfill/dist/polyfill.js',
|
16
14
|
// entry file for Webpack
|
17
15
|
'spec/javascript/testHelper.js'
|
18
16
|
],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: make_it_so
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Pickett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09
|
11
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -118,6 +118,7 @@ extra_rdoc_files: []
|
|
118
118
|
files:
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rspec"
|
121
|
+
- CHANGELOG.md
|
121
122
|
- Gemfile
|
122
123
|
- LICENSE.txt
|
123
124
|
- README.md
|
@@ -130,9 +131,11 @@ files:
|
|
130
131
|
- lib/make_it_so/command_line_interface.rb
|
131
132
|
- lib/make_it_so/rails.rb
|
132
133
|
- lib/make_it_so/rails/app_builder.rb
|
134
|
+
- lib/make_it_so/rails/prerequisite_check.rb
|
133
135
|
- lib/make_it_so/version.rb
|
134
136
|
- make_it_so.gemspec
|
135
137
|
- snippets/rails/application_generator.rb
|
138
|
+
- snippets/rails/js_enzyme_testing_deps.json
|
136
139
|
- snippets/rails/js_jest_testing_deps.json
|
137
140
|
- snippets/rails/js_karma_jasmine_testing_deps.json
|
138
141
|
- snippets/rails/react_dependencies.json
|
@@ -152,7 +155,6 @@ files:
|
|
152
155
|
- templates/gosu/lib/bounding_box.rb
|
153
156
|
- templates/gosu/lib/keys.rb
|
154
157
|
- templates/gosu/spec/spec_helper.rb
|
155
|
-
- templates/rails/.babelrc
|
156
158
|
- templates/rails/.env
|
157
159
|
- templates/rails/.env.example
|
158
160
|
- templates/rails/.gitkeep
|
@@ -163,10 +165,12 @@ files:
|
|
163
165
|
- templates/rails/app/models/application_record.rb
|
164
166
|
- templates/rails/app/views/homes/index.html.erb
|
165
167
|
- templates/rails/app/views/layouts/application.html.erb.tt
|
168
|
+
- templates/rails/babel.config.js
|
166
169
|
- templates/rails/karma.conf.js
|
167
170
|
- templates/rails/spec/features/user_signs_in_spec.rb
|
168
171
|
- templates/rails/spec/features/user_signs_out_spec.rb
|
169
172
|
- templates/rails/spec/features/user_signs_up_spec.rb
|
173
|
+
- templates/rails/spec/javascript/example.test.js
|
170
174
|
- templates/rails/spec/javascript/exampleTest.js
|
171
175
|
- templates/rails/spec/javascript/support/enzyme.js
|
172
176
|
- templates/rails/spec/javascript/support/jest-fetch-mock.js
|
data/templates/rails/.babelrc
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"presets": [
|
3
|
-
[
|
4
|
-
"@babel/env",
|
5
|
-
{
|
6
|
-
"modules": false,
|
7
|
-
"targets": {
|
8
|
-
"browsers": "> 1%"
|
9
|
-
},
|
10
|
-
"forceAllTransforms": true
|
11
|
-
}
|
12
|
-
],
|
13
|
-
"@babel/react"
|
14
|
-
],
|
15
|
-
"plugins": [
|
16
|
-
"@babel/syntax-dynamic-import",
|
17
|
-
"@babel/proposal-object-rest-spread",
|
18
|
-
[
|
19
|
-
"@babel/proposal-class-properties",
|
20
|
-
{
|
21
|
-
"spec": true
|
22
|
-
}
|
23
|
-
]
|
24
|
-
],
|
25
|
-
"env": {
|
26
|
-
"test": {
|
27
|
-
"presets": [
|
28
|
-
"@babel/env",
|
29
|
-
"@babel/react"
|
30
|
-
]
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|