r2m 0.2.4 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51ea8c25dfef6661109caeee0ca628389434080b154b1beeb1aad1c1515846f7
4
- data.tar.gz: 4dd1416feddfc8b52e79dfcf4970cdcf3fb8d385885f7f261a8c5e2d0ca23e7c
3
+ metadata.gz: a0dce0f667bf307b01eb6de9ccb4081ab403a1fc6d5f49942537be3535b1061d
4
+ data.tar.gz: 20762c16212c92834ba2f9508f4409ebd8fcc9255034c0ae73998152e87a69e1
5
5
  SHA512:
6
- metadata.gz: b470cdccf3d24ae191eb6b8b5d956a34f112c297a2be1f1e162ec240cdad5f225ec57df18b056905d8149bd4046f145b1570d563c04ad59a95974b829d0be4a1
7
- data.tar.gz: f9dd5ca8be65e5ac323fb16f462ca0daa277a4ac059ca8a06cea3e394f22a25140e638d4036131b38dd5a1492c296969d929687293b8e3a315849bbf56a94f9c
6
+ metadata.gz: 36c76c48458b7435d5cf45154be96174b118859da321951fc04246002ef08f33ea1bf59a57f4c953e052c23d9c1b30996065b2afde0bf8077d8191c92d05443c
7
+ data.tar.gz: 1f3e60cb51c7a650672973e2c9325bcf300c6b8a5809497139d741d6766742e4f6862c32107bbe32461a1d6bed3524b790631090d6488e4ee7fed6d983676638
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'capybara/minitest/spec'
5
+
6
+ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
7
+ TUNING_CHROME_ARGS = %w[
8
+ --disable-background-timer-throttling --disable-backgrounding-occluded-windows
9
+ --disable-breakpad --disable-component-extensions-with-background-pages
10
+ --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees
11
+ --disable-gpu --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking
12
+ --disable-renderer-backgrounding --disable-site-isolation-trials --disable-web-security
13
+ --enable-features=NetworkService,NetworkServiceInProcess --force-color-profile=srgb
14
+ --force-device-scale-factor=1 --hide-scrollbars --metrics-recording-only --mute-audio --no-sandbox
15
+ ].freeze
16
+
17
+ driven_by :selenium, using: :headless_chrome do |options|
18
+ TUNING_CHROME_ARGS.each do |arg|
19
+ options.add_argument arg
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ MiniTest::Spec.class_eval do
4
+ def self.shared_examples
5
+ warn "FIXME: Remove shared_examples: #{caller(2..2).first}"
6
+ @_shared_examples ||= {}
7
+ end
8
+ end
9
+
10
+ module MiniTest::Spec::SharedExamples
11
+ def shared_examples_for(desc, &block)
12
+ MiniTest::Spec.shared_examples[desc] = block
13
+ end
14
+
15
+ def shared_examples(desc, &block)
16
+ MiniTest::Spec.shared_examples[desc] = block
17
+ end
18
+
19
+ def include_examples(desc)
20
+ instance_eval(&MiniTest::Spec.shared_examples[desc])
21
+ end
22
+ end
23
+
24
+ Object.class_eval { include(MiniTest::Spec::SharedExamples) }
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ require_relative '../config/environment'
5
+ require 'rails/test_help'
6
+
7
+ class ActiveSupport::TestCase
8
+ # Run tests in parallel with specified workers
9
+ # parallelize(workers: :number_of_processors)
10
+
11
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
12
+ fixtures :all
13
+ end
data/lib/r2m/command.rb CHANGED
@@ -32,26 +32,36 @@ module R2M
32
32
  type: :boolean
33
33
  )
34
34
  def migrate(*paths)
35
+ setup_rails_to_run_minitest
36
+
35
37
  files(paths.flatten).each do |path|
36
38
  say "Processing #{path}"
37
- run_migrate(path)
38
- run_convert(path)
39
+ migrated_path = run_migrate(path)
40
+ run_convert(migrated_path)
39
41
  end
40
42
  end
41
43
 
42
44
  private
43
45
 
46
+ def setup_rails_to_run_minitest
47
+ path_to_rails_template = File.expand_path('../../template.rb', __dir__)
48
+ system("DISABLE_SPRING=1 rails app:template LOCATION=#{path_to_rails_template}")
49
+ end
50
+
44
51
  def run_migrate(path)
45
52
  SpecMigration.new(Pathname.pwd).migrate(File.realpath(path))
46
53
  end
47
54
 
48
55
  def run_convert(file)
49
56
  say "Processing #{file}"
50
- SpecConvector.new(self).process(file)
57
+ SpecConvector.new(self).process(file.to_s)
51
58
  end
52
59
 
53
60
  def files(paths)
54
- Array(paths).map do |path|
61
+ paths = Array(paths)
62
+ return Dir.glob('spec/**/*_spec.rb') if paths.empty?
63
+
64
+ paths.map do |path|
55
65
  if File.exist?(path) && !File.directory?(path)
56
66
  path
57
67
  elsif Dir.exist?(path)
@@ -28,6 +28,8 @@ class SpecMigration # rubocop:todo Style/Documentation
28
28
 
29
29
  test_basename = spec_basename.sub(/_spec(?=\.rb)/, '_test')
30
30
  test_file = test_dirname + test_basename
31
- FileUtils.cp spec_file, test_file
31
+ FileUtils.cp spec_file, test_file unless test_file.exist?
32
+
33
+ test_file
32
34
  end
33
35
  end
data/lib/r2m/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module R2M
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.2.5'.freeze
3
3
  end
data/template.rb ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ say 'Updating rails to run minitests/spec'
4
+
5
+ source_paths.unshift(__dir__)
6
+
7
+ gem 'minitest-spec-rails', require: false, group: :test
8
+ gem 'rspec-expectations', require: false, group: :test
9
+ gem 'capybara', require: false, group: :test
10
+
11
+ `bundle install`
12
+
13
+ directory 'lib/install/test', 'test'
14
+
15
+ insert_into_file('test/test_helper.rb', <<~TEST_HELPER_SNIPPET, before: 'class ActiveSupport::TestCase')
16
+
17
+ require 'minitest-spec-rails'
18
+ require 'rspec/expectations/minitest_integration'
19
+
20
+ require_relative 'support/shared_examples'
21
+
22
+ TEST_HELPER_SNIPPET
23
+
24
+
25
+ say <<~MSG
26
+ **************************
27
+ DO NOT FORGET TO INSTALL CODE QUALITY TOOLS:
28
+ `rails app:template LOCATION=https://raw.githubusercontent.com/jetthoughts/jt_tools/master/template.rb`
29
+ **************************
30
+ MSG
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r2m
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Keen
@@ -48,6 +48,9 @@ files:
48
48
  - docs/_config.yml
49
49
  - exe/r2m
50
50
  - exe/rspec2minitest
51
+ - lib/install/test/application_system_test_case.rb
52
+ - lib/install/test/support/shared_examples.rb
53
+ - lib/install/test/test_helper.rb
51
54
  - lib/r2m.rb
52
55
  - lib/r2m/command.rb
53
56
  - lib/r2m/spec_convector.rb
@@ -56,6 +59,7 @@ files:
56
59
  - r2m.gemspec
57
60
  - sample_app/test/example_spec/example_test.rb
58
61
  - sample_app/test/example_test.rb
62
+ - template.rb
59
63
  homepage: https://github.com/jetthoughts/r2m
60
64
  licenses:
61
65
  - MIT