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
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ feature "user generates rails app with karma/jasmine" 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
+ before(:all) do
13
+ make_it_so!("rails #{app_name} --js-test-lib karma")
14
+ end
15
+
16
+ let(:package_json_path) { File.join(app_path, 'package.json') }
17
+
18
+ it 'creates a karma.config' do
19
+ karma_config = File.join(app_path, 'karma.conf.js')
20
+ expect(FileTest.exists?(karma_config)).to eq(true)
21
+ end
22
+
23
+ it 'creates a testHelper.js' do
24
+ test_helper = File.join(app_path, 'spec/javascript/testHelper.js')
25
+ expect(FileTest.exists?(test_helper)).to eq(true)
26
+ end
27
+
28
+ it 'includes karma in package.json' do
29
+ in_package_json?(File.join(app_path, 'package.json')) do |json|
30
+ expect(json["devDependencies"]["karma"]).to_not be_nil
31
+ end
32
+ end
33
+
34
+ it 'includes jasmine in package.json' do
35
+ in_package_json?(File.join(app_path, 'package.json')) do |json|
36
+ expect(json["devDependencies"]["jasmine-core"]).to_not be_nil
37
+ end
38
+ end
39
+
40
+ it 'adds coverage/* to gitignore' do
41
+ expect(read_file('.gitignore')).to include("coverage/*\n")
42
+ end
43
+
44
+ it 'does not configure enzyme adapter in testHelper' do
45
+ testHelper = read_file('spec/javascript/testHelper.js')
46
+ expect(testHelper).to_not include("Enzyme.configure({ adapter: new EnzymeAdapter() })")
47
+ end
48
+
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")
61
+ end
62
+
63
+ it 'does not add jest as the test script in package.json' do
64
+ in_package_json?(package_json_path) do |json|
65
+ expect(json["scripts"]["test"]).to_not include("jest")
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ feature "user generates rails app without js test framework" 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
+ before(:all) do
13
+ make_it_so!("rails #{app_name} --js-test-lib false")
14
+ end
15
+
16
+ let(:package_json_path) { File.join(app_path, 'package.json') }
17
+
18
+ it 'does not create a karma.config' do
19
+ karma_config = File.join(app_path, 'karma.conf.js')
20
+ expect(FileTest.exists?(karma_config)).to eq(false)
21
+ end
22
+
23
+ it 'does not create a testHelper.js' do
24
+ test_helper = File.join(app_path, 'spec/javascript/testHelper.js')
25
+ expect(FileTest.exists?(test_helper)).to eq(false)
26
+ end
27
+
28
+ it 'does not create an enzyme config file' do
29
+ test_helper = File.join(app_path, 'spec/javascript/support/enzyme.js')
30
+ expect(FileTest.exists?(test_helper)).to eq(false)
31
+ end
32
+
33
+ it 'does not include karma or jest in package.json' do
34
+ in_package_json?(File.join(app_path, 'package.json')) do |json|
35
+ expect(json["devDependencies"]["karma"]).to be_nil
36
+ expect(json["devDependencies"]["jest"]).to be_nil
37
+ end
38
+ end
39
+
40
+ it 'does not include jasmine in package.json' do
41
+ in_package_json?(File.join(app_path, 'package.json')) do |json|
42
+ expect(json["devDependencies"]["jasmine-core"]).to be_nil
43
+ end
44
+ end
45
+
46
+ it 'does not add a test script in package.json' do
47
+ in_package_json?(package_json_path) do |json|
48
+ expect(json["scripts"]["test"]).to be_nil
49
+ end
50
+ end
51
+ end
@@ -50,6 +50,29 @@ module MakeItSoSpecHelpers
50
50
  json = JSON.parse(contents)
51
51
  yield(json)
52
52
  end
53
+
54
+ def read_file(file_path)
55
+ File.read(File.join(app_path, file_path))
56
+ end
57
+
58
+ def major_version(version_string)
59
+ version_array(version_string)[0]
60
+ end
61
+
62
+ def minor_version(version_string)
63
+ version_array(version_string)[1]
64
+ end
65
+
66
+ def patch_version(version_string)
67
+ version_array(version_string)[2]
68
+ end
69
+
70
+ def version_array(version_string)
71
+ version_string.delete!("^")
72
+ version_string.delete!("~")
73
+ version_array = version_string.split(".")
74
+ version_array.map{ |string| string.to_i }
75
+ end
53
76
  end
54
77
 
55
78
  RSpec.configure do |config|
@@ -0,0 +1,18 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require foundation
16
+ //= require_tree .
17
+
18
+ $(function(){ $(document).foundation(); });
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
16
+
@@ -2,7 +2,7 @@
2
2
  import React from 'react'
3
3
  import { render } from 'react-dom'
4
4
 
5
- import App from '../react/components/app'
5
+ import App from '../react/components/App'
6
6
  import RedBox from 'redbox-react'
7
7
 
8
8
  document.addEventListener('DOMContentLoaded', () => {
@@ -4,4 +4,4 @@ export const App = (props) => {
4
4
  return (<h1>Make It So React</h1>)
5
5
  }
6
6
 
7
- export default App
7
+ export default App
@@ -0,0 +1,5 @@
1
+ describe('example test', () => {
2
+ it('should pass', () => {
3
+ expect(true).toBe(true);
4
+ });
5
+ });
@@ -4,20 +4,13 @@
4
4
  <title><%= camelized %></title>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <%%= stylesheet_link_tag 'application', media: 'all' %>
7
- <% if options.foundation? %>
8
- <%%= javascript_include_tag "vendor/modernizr" %>
9
- <% end %>
10
7
  <%%= csrf_meta_tags %>
11
8
  </head>
12
9
  <body>
13
10
  <%- if options.devise? -%>
14
11
  <% if options.foundation? %>
15
12
  <nav class="top-bar">
16
- <ul class="title-area">
17
- <li class="name">
18
- <h1><a href="/"><%= camelized %></a></h1>
19
- </li>
20
- </ul>
13
+ <h1><a href="/"><%= camelized %></a></h1>
21
14
 
22
15
  <section class="top-bar-section">
23
16
  <ul class="right">
@@ -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 PhantomJS browser
7
- browsers: ['PhantomJS'],
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
  ],
@@ -36,7 +34,6 @@ module.exports = function(config) {
36
34
  // use babel-loader to transpile the test and src folders
37
35
  {
38
36
  test: /\.jsx?$/,
39
- exclude: /node_modules/,
40
37
  loader: 'babel-loader'
41
38
  },
42
39
  {
@@ -0,0 +1,5 @@
1
+ describe('example test', () => {
2
+ it('should pass', () => {
3
+ expect(true).toBe(true);
4
+ });
5
+ });
@@ -1,6 +1,4 @@
1
1
  const Enzyme = require('enzyme');
2
-
3
- const EnzymeAdapter = require('enzyme-adapter-react-15.4');
2
+ const EnzymeAdapter = require("ADAPTER NAME GOES HERE");
4
3
 
5
4
  Enzyme.configure({ adapter: new EnzymeAdapter() });
6
-
@@ -1,13 +1,18 @@
1
1
  import { shallow, mount } from 'enzyme';
2
2
  import jasmineEnzyme from 'jasmine-enzyme';
3
3
  import React from 'react';
4
- import 'jasmine-ajax';
4
+ import fetchPonyfill from 'fetch-ponyfill';
5
+ const {fetch, Request, Response, Headers} = fetchPonyfill({});
5
6
 
6
7
  Object.assign(global, {
7
8
  jasmineEnzyme,
8
9
  mount,
9
10
  React,
10
11
  shallow,
12
+ fetch,
13
+ Request,
14
+ Response,
15
+ Headers
11
16
  });
12
17
 
13
18
  beforeEach(() => {
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.4.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pickett
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-01 00:00:00.000000000 Z
11
+ date: 2021-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -72,42 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.7'
75
+ version: '2.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.7'
83
- - !ruby/object:Gem::Dependency
84
- name: appraisal
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '12.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '12.0'
82
+ version: '2.1'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: rspec
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -146,18 +118,12 @@ extra_rdoc_files: []
146
118
  files:
147
119
  - ".gitignore"
148
120
  - ".rspec"
149
- - Appraisals
121
+ - CHANGELOG.md
150
122
  - Gemfile
151
123
  - LICENSE.txt
152
124
  - README.md
153
125
  - Rakefile
154
126
  - bin/make_it_so
155
- - gemfiles/rails_4_0.gemfile
156
- - gemfiles/rails_4_0.gemfile.lock
157
- - gemfiles/rails_4_1.gemfile
158
- - gemfiles/rails_4_1.gemfile.lock
159
- - gemfiles/rails_4_2.gemfile
160
- - gemfiles/rails_4_2.gemfile.lock
161
127
  - lib/generators/gosu_app_generator.rb
162
128
  - lib/generators/rails_app_generator.rb
163
129
  - lib/generators/sinatra_app_generator.rb
@@ -165,15 +131,19 @@ files:
165
131
  - lib/make_it_so/command_line_interface.rb
166
132
  - lib/make_it_so/rails.rb
167
133
  - lib/make_it_so/rails/app_builder.rb
134
+ - lib/make_it_so/rails/prerequisite_check.rb
168
135
  - lib/make_it_so/version.rb
169
136
  - make_it_so.gemspec
170
137
  - snippets/rails/application_generator.rb
138
+ - snippets/rails/js_enzyme_testing_deps.json
171
139
  - snippets/rails/js_jest_testing_deps.json
172
- - snippets/rails/js_testing_deps.json
140
+ - snippets/rails/js_karma_jasmine_testing_deps.json
173
141
  - snippets/rails/react_dependencies.json
174
142
  - snippets/rails/user_factory.rb
143
+ - spec/features/rails/user_generates_rails_spec.rb
144
+ - spec/features/rails/user_generates_rails_with_karma_spec.rb
145
+ - spec/features/rails/user_generates_rails_without_js_test_lib_spec.rb
175
146
  - spec/features/user_generates_gosu_spec.rb
176
- - spec/features/user_generates_rails_spec.rb
177
147
  - spec/features/user_generates_sinatra_spec.rb
178
148
  - spec/spec_helper.rb
179
149
  - spec/support/make_it_so_spec_helpers.rb
@@ -188,17 +158,22 @@ files:
188
158
  - templates/rails/.env
189
159
  - templates/rails/.env.example
190
160
  - templates/rails/.gitkeep
161
+ - templates/rails/app/assets/javascripts/application.foundation.js
162
+ - templates/rails/app/assets/javascripts/application.js
191
163
  - templates/rails/app/controllers/application_controller.rb
192
164
  - templates/rails/app/controllers/homes_controller.rb
193
165
  - templates/rails/app/javascript/packs/new_application.js
194
- - templates/rails/app/javascript/react/components/app.js
166
+ - templates/rails/app/javascript/react/components/App.js
167
+ - templates/rails/app/javascript/react/components/example.test.js
195
168
  - templates/rails/app/models/application_record.rb
196
169
  - templates/rails/app/views/homes/index.html.erb
197
170
  - templates/rails/app/views/layouts/application.html.erb.tt
171
+ - templates/rails/babel.config.js
198
172
  - templates/rails/karma.conf.js
199
173
  - templates/rails/spec/features/user_signs_in_spec.rb
200
174
  - templates/rails/spec/features/user_signs_out_spec.rb
201
175
  - templates/rails/spec/features/user_signs_up_spec.rb
176
+ - templates/rails/spec/javascript/example.test.js
202
177
  - templates/rails/spec/javascript/exampleTest.js
203
178
  - templates/rails/spec/javascript/support/enzyme.js
204
179
  - templates/rails/spec/javascript/support/jest-fetch-mock.js
@@ -221,7 +196,7 @@ homepage: ''
221
196
  licenses:
222
197
  - MIT
223
198
  metadata: {}
224
- post_install_message:
199
+ post_install_message:
225
200
  rdoc_options: []
226
201
  require_paths:
227
202
  - lib
@@ -236,14 +211,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
211
  - !ruby/object:Gem::Version
237
212
  version: '0'
238
213
  requirements: []
239
- rubyforge_project:
240
- rubygems_version: 2.6.13
241
- signing_key:
214
+ rubygems_version: 3.1.6
215
+ signing_key:
242
216
  specification_version: 4
243
217
  summary: An application generator for all things ruby
244
218
  test_files:
219
+ - spec/features/rails/user_generates_rails_spec.rb
220
+ - spec/features/rails/user_generates_rails_with_karma_spec.rb
221
+ - spec/features/rails/user_generates_rails_without_js_test_lib_spec.rb
245
222
  - spec/features/user_generates_gosu_spec.rb
246
- - spec/features/user_generates_rails_spec.rb
247
223
  - spec/features/user_generates_sinatra_spec.rb
248
224
  - spec/spec_helper.rb
249
225
  - spec/support/make_it_so_spec_helpers.rb