r2m 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/install/test/application_system_test_case.rb +22 -0
- data/lib/install/test/support/shared_examples.rb +24 -0
- data/lib/install/test/test_helper.rb +13 -0
- data/lib/r2m/command.rb +14 -4
- data/lib/r2m/spec_migration.rb +3 -1
- data/lib/r2m/version.rb +1 -1
- data/template.rb +30 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0dce0f667bf307b01eb6de9ccb4081ab403a1fc6d5f49942537be3535b1061d
|
4
|
+
data.tar.gz: 20762c16212c92834ba2f9508f4409ebd8fcc9255034c0ae73998152e87a69e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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)
|
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)
|
data/lib/r2m/spec_migration.rb
CHANGED
@@ -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
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
|
+
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
|