make_it_so 0.2.4 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99acc252bdfae2b84de984c360870ec229a270ca
4
- data.tar.gz: 17299578ba1456f439ec182748d0ad552b5deef4
3
+ metadata.gz: 1a9e64a14a478c5b0f110324e40ceac5e4065d02
4
+ data.tar.gz: 8326835760bb6e855fa1ff0ae7dd8ebbc626dcbf
5
5
  SHA512:
6
- metadata.gz: d436a0ef81a5cdc5d3c1a93ffb8838f37ac9a05693a96cbce5aec7d7458bfda2f9da773c6611400eba41b9a846e32f85a055a23f4f403ec2326534e67f9cd328
7
- data.tar.gz: 2c7e02d7488584e5b8f6cd00ceddc112d18d7062278f5df26742a61700c3dca8e7e681f7836914c398605655961cc03ecde641aaad8829aeffc013e790f94d5c
6
+ metadata.gz: 25ef05cacc042ff38f396edefbbe32bb993472eb10142f8968a611b07e59a94f066a2ef65194f26ecd634ee79c5dca64df158ec36a30ebc463f50146a01517e2
7
+ data.tar.gz: e073599e2d29b1f368a28ebacd961855aeb12754f0dafe0a01f58363563f564c28c636f9bfcc920a8ba56bd5da7ffbd18541983d1d1fbfef6e5254d6cba1d18c
@@ -52,6 +52,11 @@ module MakeItSo
52
52
  default: true,
53
53
  desc: 'Generate karma testing setup'
54
54
 
55
+ class_option :jest,
56
+ type: :boolean,
57
+ default: false,
58
+ desc: 'Generate jest testing setup'
59
+
55
60
  def initialize(*args)
56
61
  super
57
62
  if @options[:rspec]
@@ -93,7 +98,9 @@ module MakeItSo
93
98
  build 'react'
94
99
  end
95
100
 
96
- if options[:karma]
101
+ if options[:jest]
102
+ build 'jest'
103
+ elsif options[:karma]
97
104
  build 'karma'
98
105
  end
99
106
  end
@@ -3,10 +3,10 @@ module MakeItSo
3
3
  class CommandLineInterface < Thor
4
4
  desc "rails <app_name>",
5
5
  "generates a rails application based on your specifications"
6
- option :devise
6
+ option :devise, type: :boolean
7
+ option :jest, type: :boolean
7
8
  def rails(app_name)
8
- puts "#{app_name}"
9
- MakeItSo::RailsAppGenerator.start([app_name])
9
+ MakeItSo::RailsAppGenerator.start(ARGV[1..-1])
10
10
  end
11
11
 
12
12
  desc "sinatra <app_name>",
@@ -93,6 +93,30 @@ module MakeItSo
93
93
  end
94
94
  end
95
95
 
96
+ def jest
97
+ after_bundle do
98
+ run 'yarn add jest babel-jest --dev'
99
+ run 'mkdir -p spec/javascript'
100
+ modify_json(package_json_file) do |json|
101
+ json["scripts"] ||= {}
102
+ json["scripts"]["test"] = "node_modules/.bin/jest"
103
+ json["scripts"]["test:dev"] = "node_modules/.bin/jest --notify --watch"
104
+ json["jest"] ||= {}
105
+ json["jest"].merge!({
106
+ "roots": [
107
+ "spec/javascript"
108
+ ],
109
+ "moduleDirectories": [
110
+ "node_modules",
111
+ "app/javascript"
112
+ ]
113
+ })
114
+ end
115
+
116
+ rake 'yarn:install'
117
+ end
118
+ end
119
+
96
120
  def rspec_dependency
97
121
  self.gem 'rspec-rails', group: [:development, :test]
98
122
  self.gem 'capybara', group: [:development, :test]
@@ -1,3 +1,3 @@
1
1
  module MakeItSo
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -224,7 +224,59 @@ feature 'user generates rails app' do
224
224
  in_package_json?(File.join(app_path, 'package.json')) do |json|
225
225
  expect(json["devDependencies"]["react-addons-test-utils"]).to_not be_nil
226
226
  end
227
+ end
228
+ end
229
+
230
+ end
231
+
232
+ feature 'jest' do
233
+ def app_name
234
+ 'dummy_rails'
235
+ end
236
+
237
+ def app_path
238
+ join_paths(tmp_path, app_name)
239
+ end
240
+
241
+ before(:all) do
242
+ make_it_so!("rails #{app_name} --jest")
243
+ end
244
+
245
+ let(:package_json_path) { File.join(app_path, 'package.json') }
246
+
247
+
248
+ scenario 'adds jest as a dependency' do
249
+ in_package_json?(package_json_path) do |json|
250
+ expect(json["devDependencies"]["jest"]).to_not be_nil
251
+ end
252
+ end
253
+
254
+ scenario 'adds jest as the test script in package.json' do
255
+ in_package_json?(package_json_path) do |json|
256
+ expect(json["scripts"]["test"]).to include("jest")
257
+ end
258
+ end
259
+
260
+ scenario 'adds spec/javascripts to roots' do
261
+ in_package_json?(package_json_path) do |json|
262
+ expect(json["jest"]).to_not be_nil
263
+ expect(json["jest"]["roots"]).to include("spec/javascript")
264
+ end
265
+ end
266
+
267
+ scenario 'adds node_modules to modules directory' do
268
+ in_package_json?(package_json_path) do |json|
269
+ expect(json["jest"]).to_not be_nil
270
+ expect(json["jest"]["moduleDirectories"]).to_not be_nil
271
+ expect(json["jest"]["moduleDirectories"]).to include("node_modules")
272
+ end
273
+ end
227
274
 
275
+ scenario 'adds app/javascript to modules directory' do
276
+ in_package_json?(package_json_path) do |json|
277
+ expect(json["jest"]).to_not be_nil
278
+ expect(json["jest"]["moduleDirectories"]).to_not be_nil
279
+ expect(json["jest"]["moduleDirectories"]).to include("app/javascript")
228
280
  end
229
281
  end
230
282
  end
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.2.4
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pickett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-27 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.6.13
232
+ rubygems_version: 2.4.5.1
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: An application generator for all things ruby