make_it_so 0.4.2 → 0.6.0
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 +5 -5
- data/CHANGELOG.md +34 -0
- data/Gemfile +18 -1
- data/README.md +5 -4
- data/lib/generators/rails_app_generator.rb +17 -10
- data/lib/make_it_so.rb +3 -0
- data/lib/make_it_so/command_line_interface.rb +4 -2
- data/lib/make_it_so/rails.rb +1 -2
- data/lib/make_it_so/rails/app_builder.rb +102 -86
- data/lib/make_it_so/rails/prerequisite_check.rb +29 -0
- data/lib/make_it_so/version.rb +1 -1
- data/make_it_so.gemspec +1 -3
- data/snippets/rails/js_enzyme_testing_deps.json +6 -0
- data/snippets/rails/js_jest_testing_deps.json +15 -5
- data/snippets/rails/{js_testing_deps.json → js_karma_jasmine_testing_deps.json} +8 -7
- data/snippets/rails/react_dependencies.json +14 -3
- data/snippets/rails/user_factory.rb +2 -2
- data/spec/features/rails/user_generates_rails_spec.rb +410 -0
- data/spec/features/rails/user_generates_rails_with_karma_spec.rb +68 -0
- data/spec/features/rails/user_generates_rails_without_js_test_lib_spec.rb +51 -0
- data/spec/support/make_it_so_spec_helpers.rb +23 -0
- data/templates/rails/app/assets/javascripts/application.foundation.js +18 -0
- data/templates/rails/app/assets/javascripts/application.js +16 -0
- data/templates/rails/app/javascript/packs/new_application.js +1 -1
- data/templates/rails/app/javascript/react/components/{app.js → App.js} +1 -1
- data/templates/rails/app/javascript/react/components/example.test.js +5 -0
- data/templates/rails/app/views/layouts/application.html.erb.tt +1 -8
- data/templates/rails/babel.config.js +77 -0
- data/templates/rails/karma.conf.js +2 -5
- data/templates/rails/spec/javascript/example.test.js +5 -0
- data/templates/rails/spec/javascript/support/enzyme.js +1 -3
- data/templates/rails/spec/javascript/testHelper.js +6 -1
- metadata +24 -48
- data/Appraisals +0 -4
- data/gemfiles/rails_4_0.gemfile +0 -11
- data/gemfiles/rails_4_0.gemfile.lock +0 -88
- data/gemfiles/rails_4_1.gemfile +0 -11
- data/gemfiles/rails_4_1.gemfile.lock +0 -92
- data/gemfiles/rails_4_2.gemfile +0 -11
- data/gemfiles/rails_4_2.gemfile.lock +0 -106
- data/spec/features/user_generates_rails_spec.rb +0 -352
@@ -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
data/make_it_so.gemspec
CHANGED
@@ -23,9 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "activerecord", "~> 5.2"
|
24
24
|
spec.add_dependency "json"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "~> 1
|
27
|
-
spec.add_development_dependency "appraisal"
|
28
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
29
27
|
spec.add_development_dependency "rspec"
|
30
28
|
spec.add_development_dependency "capybara"
|
31
29
|
end
|
@@ -1,10 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
|
-
"babel-jest": "
|
4
|
-
"enzyme": "~3.3.0",
|
5
|
-
"enzyme-adapter-react-15.4": "~1.0.6",
|
3
|
+
"babel-jest": "^24.9.0",
|
6
4
|
"fetch-mock": "~5.13.1",
|
7
|
-
"jest": "
|
8
|
-
"
|
5
|
+
"jest": "^24.9.0",
|
6
|
+
"@types/jest": "^24.9.0"
|
7
|
+
},
|
8
|
+
"scripts": {
|
9
|
+
"start": "./bin/webpack-dev-server",
|
10
|
+
"test": "node_modules/.bin/jest",
|
11
|
+
"test:dev": "node_modules/.bin/jest --notify --watch"
|
12
|
+
},
|
13
|
+
"jest": {
|
14
|
+
"automock": false,
|
15
|
+
"roots": ["spec/javascript", "app/javascript"],
|
16
|
+
"moduleDirectories": ["node_modules", "app/javascript"],
|
17
|
+
"setupFiles": ["./spec/javascript/support/enzyme.js"],
|
18
|
+
"testURL": "http://localhost/"
|
9
19
|
}
|
10
20
|
}
|
@@ -1,18 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
|
-
"
|
4
|
-
"
|
3
|
+
"fetch-mock": "5",
|
4
|
+
"fetch-ponyfill": "^6.0.2",
|
5
5
|
"jasmine-core": "~2.4.1",
|
6
|
-
"jasmine-enzyme": "~
|
6
|
+
"jasmine-enzyme": "~7.0.0",
|
7
7
|
"karma": "~0.13.22",
|
8
|
+
"karma-chrome-launcher": "^3.1.0",
|
8
9
|
"karma-coverage": "0.5.5",
|
9
10
|
"karma-jasmine": "~0.3.8",
|
10
11
|
"karma-phantomjs-launcher": "~1.0.4",
|
11
12
|
"karma-sourcemap-loader": "0.3.7",
|
12
13
|
"karma-spec-reporter": "0.0.26",
|
13
|
-
"karma-webpack": "2.0.1"
|
14
|
-
|
15
|
-
|
14
|
+
"karma-webpack": "2.0.1"
|
15
|
+
},
|
16
|
+
"scripts": {
|
17
|
+
"test": "node_modules/.bin/karma start karma.conf.js"
|
16
18
|
}
|
17
19
|
}
|
18
|
-
|
@@ -1,9 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"dependencies": {
|
3
|
-
"babel
|
3
|
+
"@babel/core": "^7.5.5",
|
4
|
+
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
5
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
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",
|
9
|
+
"@babel/plugin-transform-runtime": "^7.13.10",
|
10
|
+
"@babel/preset-env": "^7.5.5",
|
11
|
+
"@babel/preset-react": "^7.0.0",
|
12
|
+
"@babel/runtime": "^7.13.10",
|
13
|
+
"babel-loader": "^8.0.6",
|
4
14
|
"prop-types": "~15.6.0",
|
5
|
-
"react": "~
|
6
|
-
"react-dom": "~
|
15
|
+
"react": "~16.8.0",
|
16
|
+
"react-dom": "~16.8.0",
|
17
|
+
"react-router-dom": "5.0.0",
|
7
18
|
"redbox-react": "1.6.0"
|
8
19
|
},
|
9
20
|
"devDependencies": {
|
@@ -0,0 +1,410 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'user generates rails app with default settings' do
|
4
|
+
def app_name
|
5
|
+
'dummy_rails'
|
6
|
+
end
|
7
|
+
|
8
|
+
def app_path
|
9
|
+
join_paths(tmp_path, app_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:css_manifest_path) {
|
13
|
+
join_paths(app_path, 'app/assets/stylesheets/application.css')
|
14
|
+
}
|
15
|
+
|
16
|
+
let(:gemfile_path) { join_paths(app_path, 'Gemfile')}
|
17
|
+
let(:package_json_path) { join_paths(app_path, 'package.json')}
|
18
|
+
let(:rails_spec_helper) { join_paths(app_path, 'spec/rails_helper.rb')}
|
19
|
+
|
20
|
+
before(:all) do
|
21
|
+
make_it_so!("rails #{app_name}")
|
22
|
+
end
|
23
|
+
|
24
|
+
scenario 'generates a rails app' do
|
25
|
+
expect(FileTest.exists?(join_paths(app_path, 'app/models'))).to eq(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
scenario 'creates an application.js manifest' do
|
29
|
+
js_file = join_paths(app_path, 'app/assets/javascripts/application.js')
|
30
|
+
expect(FileTest.exists?(js_file)).to eq(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario 'creates an application.css manifest' do
|
34
|
+
expect(FileTest.exists?(css_manifest_path)).to eq(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
scenario 'includes the flash in the layout' do
|
38
|
+
app_layout = File.join(app_path, 'app/views/layouts/application.html.erb')
|
39
|
+
expect(File.read(app_layout)).to include('flash')
|
40
|
+
end
|
41
|
+
|
42
|
+
scenario 'includes viewport meta tag in layout for mobile' do
|
43
|
+
app_layout = File.join(app_path, 'app/views/layouts/application.html.erb')
|
44
|
+
expect(File.read(app_layout)).to include('initial-scale=1.0')
|
45
|
+
expect(File.read(app_layout)).to include('viewport')
|
46
|
+
end
|
47
|
+
|
48
|
+
scenario 'skips active_storage' do
|
49
|
+
expect(FileTest.exists?(join_paths(app_path, 'config/storage.yml'))).to eq(false)
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'pry-rails' do
|
53
|
+
it 'is added as a dependency' do
|
54
|
+
expect(File.read(gemfile_path)).to match(/gem(.*)pry-rails/)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'rspec' do
|
59
|
+
it 'eliminates test/unit' do
|
60
|
+
expect(FileTest.exists?(join_paths(app_path, 'test'))).to_not eq(true)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'inserts a spec_helper' do
|
64
|
+
spec_helper = join_paths(app_path, 'spec/spec_helper.rb')
|
65
|
+
expect(FileTest.exists?(spec_helper)).to eq(true)
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'byebug' do
|
69
|
+
it 'removes the byebug dependency' do
|
70
|
+
expect(File.read(gemfile_path)).to_not match(/gem(.*)byebug/)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'capybara' do
|
75
|
+
it 'includes capybara as a Gemfile dependency' do
|
76
|
+
expect(File.read(gemfile_path)).to include('capybara')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'includes launchy as a Gemfile dependency' do
|
80
|
+
expect(File.read(gemfile_path)).to include('launchy')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'includes capybara in the rails_helper' do
|
84
|
+
expect(File.read(rails_spec_helper)).to match(/require \'capybara\/rspec\'/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'factory_bot' do
|
89
|
+
it 'includes a factory_bot support file' do
|
90
|
+
fb_support_path = join_paths(app_path, 'spec/support/factory_bot.rb')
|
91
|
+
expect(FileTest.exists?(fb_support_path)).to eq(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'includes the factory_bot gem' do
|
95
|
+
expect(File.read(gemfile_path)).to include('factory_bot')
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'requires the factory_bot support file' do
|
99
|
+
expect(File.read(rails_spec_helper)).
|
100
|
+
to include("\nrequire File.join(File.dirname(__FILE__), 'support/factory_bot')\n")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'valid_attribute' do
|
105
|
+
it 'includes the valid_attribute gem' do
|
106
|
+
expect(File.read(gemfile_path)).to include('valid_attribute')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'creates the valid_attribute support file' do
|
110
|
+
support_path = join_paths(app_path, 'spec/support/valid_attribute.rb')
|
111
|
+
expect(FileTest.exists?(support_path)).to eq(true)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'requires the valid_attribute support file' do
|
115
|
+
expect(File.read(rails_spec_helper)).
|
116
|
+
to match(/require(.*)support\/valid_attribute/)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'shoulda' do
|
121
|
+
it 'includes shoulda-matchers in the gemfile' do
|
122
|
+
expect(File.read(gemfile_path)).to include('shoulda-matchers')
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'includes a shoulda file in the support directory' do
|
126
|
+
expect(FileTest.exists?(join_paths(app_path, 'spec/support/shoulda.rb')))
|
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
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'database_cleaner' do
|
136
|
+
it 'includes database_cleaner in the gemfile' do
|
137
|
+
expect(File.read(gemfile_path)).to include('database_cleaner')
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'creates the database_cleaner support file' do
|
141
|
+
support_path = join_paths(app_path, 'spec/support/database_cleaner.rb')
|
142
|
+
expect(FileTest.exists?(support_path)).to eq(true)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'devise' do
|
148
|
+
it 'adds devise as a dependency' do
|
149
|
+
expect(File.read(gemfile_path)).to include('devise')
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'generates devise' do
|
153
|
+
devise_initializer = File.join(app_path, 'config/initializers/devise.rb')
|
154
|
+
expect(FileTest.exists?(devise_initializer)).to eq(true)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'generates devise views' do
|
158
|
+
devise_views = File.join(app_path, 'app/views/devise')
|
159
|
+
expect(FileTest.exists?(devise_views)).to eq(true)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'creates a user model' do
|
163
|
+
user_model = File.join(app_path, 'app/models/user.rb')
|
164
|
+
expect(FileTest.exists?(user_model)).to eq(true)
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'creates a user_signs_up feature spec' do
|
168
|
+
feature_spec = File.join(app_path, 'spec/features/user_signs_up_spec.rb')
|
169
|
+
expect(FileTest.exists?(feature_spec)).to eq(true)
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'creates a user_signs_in feature spec' do
|
173
|
+
feature_spec = File.join(app_path, 'spec/features/user_signs_in_spec.rb')
|
174
|
+
expect(FileTest.exists?(feature_spec)).to eq(true)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'creates a user_signs_out feature spec' do
|
178
|
+
feature_spec = File.join(app_path, 'spec/features/user_signs_out_spec.rb')
|
179
|
+
expect(FileTest.exists?(feature_spec)).to eq(true)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'foundation' do
|
184
|
+
it 'generates foundation' do
|
185
|
+
expect(File.read(css_manifest_path)).to include('foundation_and_overrides')
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'does not include foundation.html.erb' do
|
189
|
+
foundation_html = File.join(app_path, 'app/views/layouts/foundation.html.erb')
|
190
|
+
expect(FileTest.exists?(foundation_html)).to eq(false)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'does not include modernizr in the layout' do
|
194
|
+
expect(read_file('app/views/layouts/application.html.erb')).to_not include('modernizr')
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'adds the custom application.js manifest to the assets folder' do
|
198
|
+
file_subpath = "app/assets/javascripts/application.js"
|
199
|
+
generated_js_manifest = File.join(app_path, file_subpath)
|
200
|
+
expect(FileTest.exists?(generated_js_manifest)).to eq(true)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'react' do
|
205
|
+
it 'generates a packs file' do
|
206
|
+
expect(FileTest.exists?(join_paths(app_path, 'app/javascript/packs/application.js'))).to eq(true)
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'includes react in package.json' do
|
210
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
211
|
+
react = json["dependencies"]["react"]
|
212
|
+
expect(major_version(react)).to be 16
|
213
|
+
expect(minor_version(react)).to be 8
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'includes redbox-react in package.json' do
|
218
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
219
|
+
expect(json["dependencies"]["redbox-react"]).to_not be_nil
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'includes react-dom in package.json' do
|
224
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
225
|
+
react_dom = json["dependencies"]["react-dom"]
|
226
|
+
expect(major_version(react_dom)).to be 16
|
227
|
+
expect(minor_version(react_dom)).to be 8
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'includes react-router-dom in package.json' do
|
232
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
233
|
+
expect(json["dependencies"]["react-router-dom"]).to_not be_nil
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context 'dotenv' do
|
239
|
+
it 'adds dotenv-rails to Gemfile' do
|
240
|
+
expect(File.read(gemfile_path)).to match(/gem(.*)dotenv-rails/)
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'adds .env to gitignore' do
|
244
|
+
expect(read_file('.gitignore')).to include(".env\n")
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'creates a .env file' do
|
248
|
+
expect(FileTest.exists?(File.join(app_path, '.env'))).to eq(true)
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'creates a .env.example file' do
|
252
|
+
expect(FileTest.exists?(File.join(app_path, '.env.example'))).to eq(true)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context 'babel' do
|
257
|
+
it 'includes necessary babel packages in package.json as dev dependencies' do
|
258
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
259
|
+
expect(json["dependencies"]["@babel/core"]).to_not be_nil
|
260
|
+
expect(json["dependencies"]["@babel/preset-env"]).to_not be_nil
|
261
|
+
expect(json["dependencies"]["@babel/preset-react"]).to_not be_nil
|
262
|
+
expect(json["dependencies"]["babel-loader"]).to_not be_nil
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'does not create .babelrc' do
|
267
|
+
babelrc = File.join(app_path, '.babelrc')
|
268
|
+
expect(FileTest.exists?(babelrc)).to eq(false)
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'sets necessary presets in babel.config.js' do
|
272
|
+
babel_config = read_file('babel.config.js')
|
273
|
+
expect(babel_config).to include("@babel/preset-env")
|
274
|
+
expect(babel_config).to include("@babel/preset-react")
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
context 'enzyme' do
|
279
|
+
it 'includes enzyme in package.json' do
|
280
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
281
|
+
enzyme = json["devDependencies"]["enzyme"]
|
282
|
+
expect(major_version(enzyme)).to be 3
|
283
|
+
expect(minor_version(enzyme)).to be 10
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'includes enzyme-adapter-react-16 in package.json' do
|
288
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
289
|
+
adapter = json["devDependencies"]["enzyme-adapter-react-16"]
|
290
|
+
expect(major_version(adapter)).to be 1
|
291
|
+
expect(minor_version(adapter)).to be 14
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'includes enzyme.js with correct Enzyme config' do
|
296
|
+
file_subpath = "spec/javascript/support/enzyme.js"
|
297
|
+
support_file = File.join(app_path, file_subpath)
|
298
|
+
expect(FileTest.exists?(support_file)).to eq(true)
|
299
|
+
|
300
|
+
enzyme = read_file(file_subpath)
|
301
|
+
expect(enzyme).to include('require("enzyme-adapter-react-16")')
|
302
|
+
expect(enzyme).to include("Enzyme.configure")
|
303
|
+
expect(enzyme).to include("enzyme-adapter-react-16")
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'adds spec/javascript/support/enzyme.js to setup' do
|
307
|
+
in_package_json?(package_json_path) do |json|
|
308
|
+
expect(json["jest"]).to_not be_nil
|
309
|
+
expect(json["jest"]["setupFiles"]).to include('./spec/javascript/support/enzyme.js')
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'adds example.test.js to react components folder' do
|
314
|
+
file_subpath = "app/javascript/react/components/example.test.js"
|
315
|
+
example_test_file = File.join(app_path, file_subpath)
|
316
|
+
expect(FileTest.exists?(example_test_file)).to eq(true)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
context 'jest' do
|
321
|
+
it 'includes fetch-mock' do
|
322
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
323
|
+
expect(json["devDependencies"]["fetch-mock"]).to_not be_nil
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
scenario 'adds jest as a dependency' do
|
328
|
+
in_package_json?(package_json_path) do |json|
|
329
|
+
expect(json["devDependencies"]["jest"]).to_not be_nil
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
scenario 'adds @types/jest as a dependency' do
|
334
|
+
in_package_json?(package_json_path) do |json|
|
335
|
+
expect(json["devDependencies"]["@types/jest"]).to_not be_nil
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
scenario 'adds enzyme as a dependency' do
|
340
|
+
in_package_json?(package_json_path) do |json|
|
341
|
+
expect(json["devDependencies"]["enzyme"]).to_not be_nil
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
scenario 'adds fetch-mock as a dependency' do
|
346
|
+
in_package_json?(package_json_path) do |json|
|
347
|
+
expect(json["devDependencies"]["fetch-mock"]).to_not be_nil
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
scenario 'adds jest as the test script in package.json' do
|
352
|
+
in_package_json?(package_json_path) do |json|
|
353
|
+
expect(json["scripts"]["test"]).to include("jest")
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
scenario 'adds spec/javascripts to roots' do
|
358
|
+
in_package_json?(package_json_path) do |json|
|
359
|
+
expect(json["jest"]).to_not be_nil
|
360
|
+
expect(json["jest"]["roots"]).to include("spec/javascript")
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
scenario 'adds node_modules to modules directory' do
|
365
|
+
in_package_json?(package_json_path) do |json|
|
366
|
+
expect(json["jest"]).to_not be_nil
|
367
|
+
expect(json["jest"]["moduleDirectories"]).to_not be_nil
|
368
|
+
expect(json["jest"]["moduleDirectories"]).to include("node_modules")
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
scenario 'adds app/javascript to modules directory' do
|
373
|
+
in_package_json?(package_json_path) do |json|
|
374
|
+
expect(json["jest"]).to_not be_nil
|
375
|
+
expect(json["jest"]["moduleDirectories"]).to_not be_nil
|
376
|
+
expect(json["jest"]["moduleDirectories"]).to include("app/javascript")
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
scenario 'adds testURL to jest configuration' do
|
381
|
+
in_package_json?(package_json_path) do |json|
|
382
|
+
expect(json["jest"]).to_not be_nil
|
383
|
+
expect(json["jest"]["testURL"]).to_not be_nil
|
384
|
+
expect(json["jest"]["testURL"]).to eq("http://localhost/")
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
it 'does not create a karma.config' do
|
390
|
+
karma_config = File.join(app_path, 'karma.conf.js')
|
391
|
+
expect(FileTest.exists?(karma_config)).to eq(false)
|
392
|
+
end
|
393
|
+
|
394
|
+
it 'does not create a testHelper.js' do
|
395
|
+
test_helper = File.join(app_path, 'spec/javascript/testHelper.js')
|
396
|
+
expect(FileTest.exists?(test_helper)).to eq(false)
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'does not include karma in package.json' do
|
400
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
401
|
+
expect(json["devDependencies"]["karma"]).to be_nil
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'does not include jasmine in package.json' do
|
406
|
+
in_package_json?(File.join(app_path, 'package.json')) do |json|
|
407
|
+
expect(json["devDependencies"]["jasmine-core"]).to be_nil
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|