make_it_so 0.4.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +34 -0
  3. data/Gemfile +18 -1
  4. data/README.md +5 -4
  5. data/lib/generators/rails_app_generator.rb +17 -10
  6. data/lib/make_it_so.rb +3 -0
  7. data/lib/make_it_so/command_line_interface.rb +4 -2
  8. data/lib/make_it_so/rails.rb +1 -2
  9. data/lib/make_it_so/rails/app_builder.rb +102 -86
  10. data/lib/make_it_so/rails/prerequisite_check.rb +29 -0
  11. data/lib/make_it_so/version.rb +1 -1
  12. data/make_it_so.gemspec +1 -3
  13. data/snippets/rails/js_enzyme_testing_deps.json +6 -0
  14. data/snippets/rails/js_jest_testing_deps.json +15 -5
  15. data/snippets/rails/{js_testing_deps.json → js_karma_jasmine_testing_deps.json} +8 -7
  16. data/snippets/rails/react_dependencies.json +14 -3
  17. data/snippets/rails/user_factory.rb +2 -2
  18. data/spec/features/rails/user_generates_rails_spec.rb +410 -0
  19. data/spec/features/rails/user_generates_rails_with_karma_spec.rb +68 -0
  20. data/spec/features/rails/user_generates_rails_without_js_test_lib_spec.rb +51 -0
  21. data/spec/support/make_it_so_spec_helpers.rb +23 -0
  22. data/templates/rails/app/assets/javascripts/application.foundation.js +18 -0
  23. data/templates/rails/app/assets/javascripts/application.js +16 -0
  24. data/templates/rails/app/javascript/packs/new_application.js +1 -1
  25. data/templates/rails/app/javascript/react/components/{app.js → App.js} +1 -1
  26. data/templates/rails/app/javascript/react/components/example.test.js +5 -0
  27. data/templates/rails/app/views/layouts/application.html.erb.tt +1 -8
  28. data/templates/rails/babel.config.js +77 -0
  29. data/templates/rails/karma.conf.js +2 -5
  30. data/templates/rails/spec/javascript/example.test.js +5 -0
  31. data/templates/rails/spec/javascript/support/enzyme.js +1 -3
  32. data/templates/rails/spec/javascript/testHelper.js +6 -1
  33. metadata +24 -48
  34. data/Appraisals +0 -4
  35. data/gemfiles/rails_4_0.gemfile +0 -11
  36. data/gemfiles/rails_4_0.gemfile.lock +0 -88
  37. data/gemfiles/rails_4_1.gemfile +0 -11
  38. data/gemfiles/rails_4_1.gemfile.lock +0 -92
  39. data/gemfiles/rails_4_2.gemfile +0 -11
  40. data/gemfiles/rails_4_2.gemfile.lock +0 -106
  41. data/spec/features/user_generates_rails_spec.rb +0 -352
data/Appraisals DELETED
@@ -1,4 +0,0 @@
1
- appraise "rails-4-2" do
2
- gem "railties", "~> 4.2.0"
3
- end
4
-
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "railties", "~> 4.0.12"
6
-
7
- group :development do
8
- gem "pry"
9
- end
10
-
11
- gemspec :path => "../"
@@ -1,88 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- make_it_so (0.0.2)
5
- railties
6
- thor
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionpack (4.0.12)
12
- activesupport (= 4.0.12)
13
- builder (~> 3.1.0)
14
- erubis (~> 2.7.0)
15
- rack (~> 1.5.2)
16
- rack-test (~> 0.6.2)
17
- activesupport (4.0.12)
18
- i18n (~> 0.6, >= 0.6.9)
19
- minitest (~> 4.2)
20
- multi_json (~> 1.3)
21
- thread_safe (~> 0.1)
22
- tzinfo (~> 0.3.37)
23
- appraisal (1.0.2)
24
- bundler
25
- rake
26
- thor (>= 0.14.0)
27
- builder (3.1.4)
28
- capybara (2.4.4)
29
- mime-types (>= 1.16)
30
- nokogiri (>= 1.3.3)
31
- rack (>= 1.0.0)
32
- rack-test (>= 0.5.4)
33
- xpath (~> 2.0)
34
- coderay (1.1.0)
35
- diff-lcs (1.2.5)
36
- erubis (2.7.0)
37
- i18n (0.7.0)
38
- method_source (0.8.2)
39
- mime-types (2.4.3)
40
- mini_portile (0.6.1)
41
- minitest (4.7.5)
42
- multi_json (1.10.1)
43
- nokogiri (1.6.5)
44
- mini_portile (~> 0.6.0)
45
- pry (0.10.1)
46
- coderay (~> 1.1.0)
47
- method_source (~> 0.8.1)
48
- slop (~> 3.4)
49
- rack (1.5.2)
50
- rack-test (0.6.2)
51
- rack (>= 1.0)
52
- railties (4.0.12)
53
- actionpack (= 4.0.12)
54
- activesupport (= 4.0.12)
55
- rake (>= 0.8.7)
56
- thor (>= 0.18.1, < 2.0)
57
- rake (10.4.2)
58
- rspec (3.1.0)
59
- rspec-core (~> 3.1.0)
60
- rspec-expectations (~> 3.1.0)
61
- rspec-mocks (~> 3.1.0)
62
- rspec-core (3.1.7)
63
- rspec-support (~> 3.1.0)
64
- rspec-expectations (3.1.2)
65
- diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.1.0)
67
- rspec-mocks (3.1.3)
68
- rspec-support (~> 3.1.0)
69
- rspec-support (3.1.2)
70
- slop (3.6.0)
71
- thor (0.19.1)
72
- thread_safe (0.3.4)
73
- tzinfo (0.3.42)
74
- xpath (2.0.0)
75
- nokogiri (~> 1.3)
76
-
77
- PLATFORMS
78
- ruby
79
-
80
- DEPENDENCIES
81
- appraisal
82
- bundler (~> 1.7)
83
- capybara
84
- make_it_so!
85
- pry
86
- railties (~> 4.0.12)
87
- rake (~> 10.0)
88
- rspec
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "railties", "~> 4.1.8"
6
-
7
- group :development do
8
- gem "pry"
9
- end
10
-
11
- gemspec :path => "../"
@@ -1,92 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- make_it_so (0.0.2)
5
- railties
6
- thor
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionpack (4.1.8)
12
- actionview (= 4.1.8)
13
- activesupport (= 4.1.8)
14
- rack (~> 1.5.2)
15
- rack-test (~> 0.6.2)
16
- actionview (4.1.8)
17
- activesupport (= 4.1.8)
18
- builder (~> 3.1)
19
- erubis (~> 2.7.0)
20
- activesupport (4.1.8)
21
- i18n (~> 0.6, >= 0.6.9)
22
- json (~> 1.7, >= 1.7.7)
23
- minitest (~> 5.1)
24
- thread_safe (~> 0.1)
25
- tzinfo (~> 1.1)
26
- appraisal (1.0.2)
27
- bundler
28
- rake
29
- thor (>= 0.14.0)
30
- builder (3.2.2)
31
- capybara (2.4.4)
32
- mime-types (>= 1.16)
33
- nokogiri (>= 1.3.3)
34
- rack (>= 1.0.0)
35
- rack-test (>= 0.5.4)
36
- xpath (~> 2.0)
37
- coderay (1.1.0)
38
- diff-lcs (1.2.5)
39
- erubis (2.7.0)
40
- i18n (0.7.0)
41
- json (1.8.1)
42
- method_source (0.8.2)
43
- mime-types (2.4.3)
44
- mini_portile (0.6.1)
45
- minitest (5.5.0)
46
- nokogiri (1.6.5)
47
- mini_portile (~> 0.6.0)
48
- pry (0.10.1)
49
- coderay (~> 1.1.0)
50
- method_source (~> 0.8.1)
51
- slop (~> 3.4)
52
- rack (1.5.2)
53
- rack-test (0.6.2)
54
- rack (>= 1.0)
55
- railties (4.1.8)
56
- actionpack (= 4.1.8)
57
- activesupport (= 4.1.8)
58
- rake (>= 0.8.7)
59
- thor (>= 0.18.1, < 2.0)
60
- rake (10.4.2)
61
- rspec (3.1.0)
62
- rspec-core (~> 3.1.0)
63
- rspec-expectations (~> 3.1.0)
64
- rspec-mocks (~> 3.1.0)
65
- rspec-core (3.1.7)
66
- rspec-support (~> 3.1.0)
67
- rspec-expectations (3.1.2)
68
- diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.1.0)
70
- rspec-mocks (3.1.3)
71
- rspec-support (~> 3.1.0)
72
- rspec-support (3.1.2)
73
- slop (3.6.0)
74
- thor (0.19.1)
75
- thread_safe (0.3.4)
76
- tzinfo (1.2.2)
77
- thread_safe (~> 0.1)
78
- xpath (2.0.0)
79
- nokogiri (~> 1.3)
80
-
81
- PLATFORMS
82
- ruby
83
-
84
- DEPENDENCIES
85
- appraisal
86
- bundler (~> 1.7)
87
- capybara
88
- make_it_so!
89
- pry
90
- railties (~> 4.1.8)
91
- rake (~> 10.0)
92
- rspec
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "railties", "~> 4.2.0"
6
-
7
- group :development do
8
- gem "pry"
9
- end
10
-
11
- gemspec :path => "../"
@@ -1,106 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- make_it_so (0.0.2)
5
- railties
6
- thor
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionpack (4.2.0)
12
- actionview (= 4.2.0)
13
- activesupport (= 4.2.0)
14
- rack (~> 1.6.0)
15
- rack-test (~> 0.6.2)
16
- rails-dom-testing (~> 1.0, >= 1.0.5)
17
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
18
- actionview (4.2.0)
19
- activesupport (= 4.2.0)
20
- builder (~> 3.1)
21
- erubis (~> 2.7.0)
22
- rails-dom-testing (~> 1.0, >= 1.0.5)
23
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
24
- activesupport (4.2.0)
25
- i18n (~> 0.7)
26
- json (~> 1.7, >= 1.7.7)
27
- minitest (~> 5.1)
28
- thread_safe (~> 0.3, >= 0.3.4)
29
- tzinfo (~> 1.1)
30
- appraisal (1.0.2)
31
- bundler
32
- rake
33
- thor (>= 0.14.0)
34
- builder (3.2.2)
35
- capybara (2.4.4)
36
- mime-types (>= 1.16)
37
- nokogiri (>= 1.3.3)
38
- rack (>= 1.0.0)
39
- rack-test (>= 0.5.4)
40
- xpath (~> 2.0)
41
- coderay (1.1.0)
42
- diff-lcs (1.2.5)
43
- erubis (2.7.0)
44
- i18n (0.7.0)
45
- json (1.8.1)
46
- loofah (2.0.1)
47
- nokogiri (>= 1.5.9)
48
- method_source (0.8.2)
49
- mime-types (2.4.3)
50
- mini_portile (0.6.1)
51
- minitest (5.5.0)
52
- nokogiri (1.6.5)
53
- mini_portile (~> 0.6.0)
54
- pry (0.10.1)
55
- coderay (~> 1.1.0)
56
- method_source (~> 0.8.1)
57
- slop (~> 3.4)
58
- rack (1.6.0)
59
- rack-test (0.6.2)
60
- rack (>= 1.0)
61
- rails-deprecated_sanitizer (1.0.3)
62
- activesupport (>= 4.2.0.alpha)
63
- rails-dom-testing (1.0.5)
64
- activesupport (>= 4.2.0.beta, < 5.0)
65
- nokogiri (~> 1.6.0)
66
- rails-deprecated_sanitizer (>= 1.0.1)
67
- rails-html-sanitizer (1.0.1)
68
- loofah (~> 2.0)
69
- railties (4.2.0)
70
- actionpack (= 4.2.0)
71
- activesupport (= 4.2.0)
72
- rake (>= 0.8.7)
73
- thor (>= 0.18.1, < 2.0)
74
- rake (10.4.2)
75
- rspec (3.1.0)
76
- rspec-core (~> 3.1.0)
77
- rspec-expectations (~> 3.1.0)
78
- rspec-mocks (~> 3.1.0)
79
- rspec-core (3.1.7)
80
- rspec-support (~> 3.1.0)
81
- rspec-expectations (3.1.2)
82
- diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.1.0)
84
- rspec-mocks (3.1.3)
85
- rspec-support (~> 3.1.0)
86
- rspec-support (3.1.2)
87
- slop (3.6.0)
88
- thor (0.19.1)
89
- thread_safe (0.3.4)
90
- tzinfo (1.2.2)
91
- thread_safe (~> 0.1)
92
- xpath (2.0.0)
93
- nokogiri (~> 1.3)
94
-
95
- PLATFORMS
96
- ruby
97
-
98
- DEPENDENCIES
99
- appraisal
100
- bundler (~> 1.7)
101
- capybara
102
- make_it_so!
103
- pry
104
- railties (~> 4.2.0)
105
- rake (~> 10.0)
106
- rspec
@@ -1,352 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'user generates rails app' 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) { join_paths(app_path, 'app/assets/stylesheets/application.css') }
13
-
14
- let(:gemfile_path) { join_paths(app_path, 'Gemfile')}
15
- let(:package_json_path) { join_paths(app_path, 'package.json')}
16
- let(:rails_spec_helper) { join_paths(app_path, 'spec/rails_helper.rb')}
17
-
18
- before(:all) do
19
- make_it_so!("rails #{app_name}")
20
- end
21
-
22
- scenario 'generates a rails app' do
23
- expect(FileTest.exists?(join_paths(app_path, 'app/models'))).to eq(true)
24
- end
25
-
26
- scenario 'creates an application.js manifest' do
27
- js_file = join_paths(app_path, 'app/assets/javascripts/application.js')
28
- expect(FileTest.exists?(js_file)).to eq(true)
29
- end
30
-
31
- scenario 'creates an application.css manifest' do
32
- expect(FileTest.exists?(css_manifest_path)).to eq(true)
33
- end
34
-
35
- scenario 'includes the flash in the layout' do
36
- app_layout = File.join(app_path, 'app/views/layouts/application.html.erb')
37
- expect(File.read(app_layout)).to include('flash')
38
- end
39
-
40
- scenario 'includes viewport meta tag in layout for mobile' do
41
- app_layout = File.join(app_path, 'app/views/layouts/application.html.erb')
42
- expect(File.read(app_layout)).to include('initial-scale=1.0')
43
- expect(File.read(app_layout)).to include('viewport')
44
- end
45
-
46
- scenario 'creates a valid gemfile' do
47
- words = ['source', '#', 'gem', 'group', 'end', 'ruby']
48
-
49
- File.readlines('Gemfile').each do |line|
50
- unless line.strip.empty?
51
- expect(line.strip.start_with?(*words)).to eq(true)
52
- end
53
- end
54
- end
55
-
56
- context 'pry-rails' do
57
- it 'is added as a dependency' do
58
- expect(File.read(gemfile_path)).to match(/gem(.*)pry-rails/)
59
- end
60
- end
61
-
62
- context 'rspec' do
63
- it 'eliminates test/unit' do
64
- expect(FileTest.exists?(join_paths(app_path, 'test'))).to_not eq(true)
65
- end
66
-
67
- it 'inserts a spec_helper' do
68
- spec_helper = join_paths(app_path, 'spec/spec_helper.rb')
69
- expect(FileTest.exists?(spec_helper)).to eq(true)
70
- end
71
-
72
- context 'byebug' do
73
- it 'removes the byebug dependency' do
74
- expect(File.read(gemfile_path)).to_not match(/gem(.*)byebug/)
75
- end
76
- end
77
-
78
- context 'capybara' do
79
- it 'includes capybara as a Gemfile dependency' do
80
- expect(File.read(gemfile_path)).to include('capybara')
81
- end
82
-
83
- it 'includes launch as a Gemfile dependency' do
84
- expect(File.read(gemfile_path)).to include('launchy')
85
- end
86
-
87
- it 'includes capybara in the rails_helper' do
88
- expect(File.read(rails_spec_helper)).to match(/require \'capybara\/rspec\'/)
89
- end
90
- end
91
-
92
- context 'factory_bot' do
93
- it 'includes a factory_bot support file' do
94
- fb_support_path = join_paths(app_path, 'spec/support/factory_bot.rb')
95
- expect(FileTest.exists?(fb_support_path)).to eq(true)
96
- end
97
-
98
- it 'includes the factory_bot gem' do
99
- expect(File.read(gemfile_path)).to include('factory_bot')
100
- end
101
-
102
- it 'requires all support files, including factory bot' do
103
- expect(File.read(rails_spec_helper)).
104
- to include("\nDir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }\n\n")
105
- end
106
- end
107
-
108
- context 'valid_attribute' do
109
- it 'includes the valid_attribute gem' do
110
- expect(File.read(gemfile_path)).to include('valid_attribute')
111
- end
112
-
113
- it 'creates the valid_attribute support file' do
114
- support_path = join_paths(app_path, 'spec/support/valid_attribute.rb')
115
- expect(FileTest.exists?(support_path)).to eq(true)
116
- end
117
-
118
- it 'requires the valid_attribute support file' do
119
- expect(File.read(rails_spec_helper)).
120
- to match(/require(.*)support\/valid_attribute/)
121
- end
122
- end
123
-
124
- context 'shoulda' do
125
- it 'includes shoulda-matchers in the gemfile' do
126
- expect(File.read(gemfile_path)).to include('shoulda-matchers')
127
- end
128
-
129
- it 'includes a shoulda file in the support directory' do
130
- expect(FileTest.exists?(join_paths(app_path, 'spec/support/shoulda.rb')))
131
- end
132
- end
133
-
134
- context 'database_cleaner' do
135
- it 'includes database_cleaner in the gemfile' do
136
- expect(File.read(gemfile_path)).to include('database_cleaner')
137
- end
138
-
139
- it 'creates the database_cleaner support file' do
140
- support_path = join_paths(app_path, 'spec/support/database_cleaner.rb')
141
- expect(FileTest.exists?(support_path)).to eq(true)
142
- end
143
- end
144
- end
145
-
146
- context 'devise' do
147
- it 'adds devise as a dependency' do
148
- expect(File.read(gemfile_path)).to include('devise')
149
- end
150
-
151
- it 'generates devise' do
152
- devise_initializer = File.join(app_path, 'config/initializers/devise.rb')
153
- expect(FileTest.exists?(devise_initializer)).to eq(true)
154
- end
155
-
156
- it 'generates devise views' do
157
- devise_views = File.join(app_path, 'app/views/devise')
158
- expect(FileTest.exists?(devise_views)).to eq(true)
159
- end
160
-
161
- it 'creates a user model' do
162
- user_model = File.join(app_path, 'app/models/user.rb')
163
- expect(FileTest.exists?(user_model)).to eq(true)
164
- end
165
-
166
- it 'creates a user_signs_up feature spec' do
167
- feature_spec = File.join(app_path, 'spec/features/user_signs_up_spec.rb')
168
- expect(FileTest.exists?(feature_spec)).to eq(true)
169
- end
170
-
171
- it 'creates a user_signs_in feature spec' do
172
- feature_spec = File.join(app_path, 'spec/features/user_signs_in_spec.rb')
173
- expect(FileTest.exists?(feature_spec)).to eq(true)
174
- end
175
-
176
- it 'creates a user_signs_out feature spec' do
177
- feature_spec = File.join(app_path, 'spec/features/user_signs_out_spec.rb')
178
- expect(FileTest.exists?(feature_spec)).to eq(true)
179
- end
180
- end
181
-
182
- context 'foundation' do
183
- it 'generates foundation' do
184
- expect(File.read(css_manifest_path)).to include('foundation_and_overrides')
185
- end
186
-
187
- it 'includes modernizr in the layout' do
188
- expect(File.read(File.join(app_path, 'app/views/layouts/application.html.erb'))).to include('modernizr')
189
- end
190
- end
191
-
192
- context 'react' do
193
- it 'generates a packs file' do
194
- expect(FileTest.exists?(join_paths(app_path, 'app/javascript/packs/application.js'))).to eq(true)
195
- end
196
-
197
- it 'includes react in package.json' do
198
- in_package_json?(File.join(app_path, 'package.json')) do |json|
199
- expect(json["dependencies"]["react"]).to_not be_nil
200
- end
201
- end
202
-
203
- it 'includes redbox-react in package.json' do
204
- in_package_json?(File.join(app_path, 'package.json')) do |json|
205
- expect(json["dependencies"]["redbox-react"]).to_not be_nil
206
- end
207
- end
208
-
209
- it 'includes react-dom in package.json' do
210
- in_package_json?(File.join(app_path, 'package.json')) do |json|
211
- expect(json["dependencies"]["react-dom"]).to_not be_nil
212
- end
213
- end
214
- end
215
-
216
- context 'karma' do
217
- it 'creates a karma.config' do
218
- karma_config = File.join(app_path, 'karma.conf.js')
219
- expect(FileTest.exists?(karma_config)).to eq(true)
220
- end
221
-
222
- it 'creates a testHelper.js' do
223
- test_helper = File.join(app_path, 'spec/javascript/testHelper.js')
224
- expect(FileTest.exists?(test_helper)).to eq(true)
225
- end
226
-
227
- it 'includes karma in package.json' do
228
- in_package_json?(File.join(app_path, 'package.json')) do |json|
229
- expect(json["devDependencies"]["karma"]).to_not be_nil
230
- end
231
- end
232
-
233
- it 'includes jasmine in package.json' do
234
- in_package_json?(File.join(app_path, 'package.json')) do |json|
235
- expect(json["devDependencies"]["jasmine-core"]).to_not be_nil
236
- end
237
- end
238
-
239
- it 'includes react-addons-test-utils' do
240
- in_package_json?(File.join(app_path, 'package.json')) do |json|
241
- expect(json["devDependencies"]["react-addons-test-utils"]).to_not be_nil
242
- end
243
- end
244
-
245
- it 'adds coverage/* to gitignore' do
246
- expect(File.read(File.join(app_path, '.gitignore'))).to include("coverage/*\n")
247
- end
248
-
249
- end
250
-
251
- context 'dotenv' do
252
- it 'adds dotenv-rails to Gemfile' do
253
- expect(File.read(gemfile_path)).to match(/gem(.*)dotenv-rails/)
254
- end
255
-
256
- it 'adds .env to gitignore' do
257
- expect(File.read(File.join(app_path, '.gitignore'))).to include(".env\n")
258
- end
259
-
260
- it 'creates a .env file' do
261
- expect(FileTest.exists?(File.join(app_path, '.env'))).to eq(true)
262
- end
263
-
264
- it 'creates a .env.example file' do
265
- expect(FileTest.exists?(File.join(app_path, '.env.example'))).to eq(true)
266
- end
267
- end
268
- end
269
-
270
- feature 'jest' do
271
- def app_name
272
- 'dummy_rails'
273
- end
274
-
275
- def app_path
276
- join_paths(tmp_path, app_name)
277
- end
278
-
279
- before(:all) do
280
- make_it_so!("rails #{app_name} --jest")
281
- end
282
-
283
- let(:package_json_path) { File.join(app_path, 'package.json') }
284
-
285
-
286
- scenario 'adds jest as a dependency' do
287
- in_package_json?(package_json_path) do |json|
288
- expect(json["devDependencies"]["jest"]).to_not be_nil
289
- end
290
- end
291
-
292
- scenario 'adds enzyme as a dependency' do
293
- in_package_json?(package_json_path) do |json|
294
- expect(json["devDependencies"]["enzyme"]).to_not be_nil
295
- end
296
- end
297
-
298
- scenario 'adds fetch-mock as a dependency' do
299
- in_package_json?(package_json_path) do |json|
300
- expect(json["devDependencies"]["fetch-mock"]).to_not be_nil
301
- end
302
- end
303
-
304
- scenario 'adds jest as the test script in package.json' do
305
- in_package_json?(package_json_path) do |json|
306
- expect(json["scripts"]["test"]).to include("jest")
307
- end
308
- end
309
-
310
- scenario 'adds spec/javascripts to roots' do
311
- in_package_json?(package_json_path) do |json|
312
- expect(json["jest"]).to_not be_nil
313
- expect(json["jest"]["roots"]).to include("spec/javascript")
314
- end
315
- end
316
-
317
- scenario 'adds node_modules to modules directory' do
318
- in_package_json?(package_json_path) do |json|
319
- expect(json["jest"]).to_not be_nil
320
- expect(json["jest"]["moduleDirectories"]).to_not be_nil
321
- expect(json["jest"]["moduleDirectories"]).to include("node_modules")
322
- end
323
- end
324
-
325
- scenario 'adds app/javascript to modules directory' do
326
- in_package_json?(package_json_path) do |json|
327
- expect(json["jest"]).to_not be_nil
328
- expect(json["jest"]["moduleDirectories"]).to_not be_nil
329
- expect(json["jest"]["moduleDirectories"]).to include("app/javascript")
330
- end
331
- end
332
-
333
- scenario 'adds testURL to jest configuration' do
334
- in_package_json?(package_json_path) do |json|
335
- expect(json["jest"]).to_not be_nil
336
- expect(json["jest"]["testURL"]).to_not be_nil
337
- expect(json["jest"]["testURL"]).to eq("http://localhost/")
338
- end
339
- end
340
-
341
- scenario 'adds a spec/javascript/support/enzyme.js file' do
342
- support_file = File.join(app_path, 'spec/javascript/support/enzyme.js')
343
- expect(FileTest.exists?(support_file)).to eq(true)
344
- end
345
-
346
- scenario 'adds spec/javascript/support/enzyme.js to setup' do
347
- in_package_json?(package_json_path) do |json|
348
- expect(json["jest"]).to_not be_nil
349
- expect(json["jest"]["setupFiles"]).to include('./spec/javascript/support/enzyme.js')
350
- end
351
- end
352
- end