r2m 0.1.0 → 0.2.0

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: f35e24b4f65f55302b6e139de08ce71b6aa49cbb634c25a6ffff46047cf36654
4
- data.tar.gz: e422f1fec1bea0807fd31098c0046d351d4c32bda7aebf4ddb41366974bc2430
3
+ metadata.gz: 8a72dfc7602cc2dd37659e5c4eb4c16e8e10b332efb55a93e50eaad9678710da
4
+ data.tar.gz: '093d2cf507bf7b2eaf6c1eb18eb34f0b03de1692697644953c8213d0491fb13c'
5
5
  SHA512:
6
- metadata.gz: 31294b116c025660f5e4f30c5ecd0ba7f46896cd70c99a06ff52e003f4a456c49a6c87f16860ef27b326820ad1ae467a75f9cc2bd676dbd2639d8deaeba61a8e
7
- data.tar.gz: 3d0fe23c9ed17001fccf2cc62101b36fdfb2e5d7c2f42c0366a7378530394a587098c57db94e6e20034c93d935141b7ce2ed4e5f41b277f59c7121dd5e7487e1
6
+ metadata.gz: 9b8d460ca5d1eaf09fa203f790b314efb6b1ba83b4fc0750afc925be329ccdeb51ed3dc4cf6b2195fc8d6969d20a861acd0f8efdb70b9c18911a3c1240990c84
7
+ data.tar.gz: 5f6e1845d67c8a148d3bf00327fd1e0eae7e134784d3e5ac3029dfee61b8e3b61fdd240241615a285477028644bcd2ab56d1f5b09431fa867dd645e1e2b3a462
data/exe/r2m CHANGED
@@ -2,50 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'rubygems'
5
- require 'thor'
6
5
 
7
- class R2MCommand < Thor
8
- include Thor::Actions
6
+ require 'r2m/command'
9
7
 
10
- default_command :convert
11
- argument :path, default: 'spec'
12
-
13
- def self.exit_on_failure?
14
- true
15
- end
16
-
17
- desc 'convert', 'Convert Rspec to MiniTest'
18
- def convert
19
- files.each { |file| process file }
20
- end
21
-
22
- private
23
-
24
- def process(file)
25
-
26
- # it 'converts it"s to test method with # support' do # => def test_converts_it_s_to_test_method_with_support
27
- convert_it_to_methods(file)
28
- end
29
-
30
- # Finds +it+ cases and converts to test methods declarations
31
- #
32
- # it 'converts it"s to test method with # support' do
33
- # # => def test_converts_it_s_to_test_method_with_support
34
- def convert_it_to_methods(file)
35
- gsub_file(file, /(?<=\bit ').*?(?=' do\b)/) do |match|
36
- match.gsub(/[^\w]+/, '_').downcase
37
- end
38
-
39
- gsub_file(file, /it '(.*)' do/, 'def test_\1')
40
- end
41
-
42
- def files
43
- if Dir.exist?(path)
44
- Dir.glob(File.join(path, '**', '*_test.rb'))
45
- else
46
- Dir.glob(path)
47
- end
48
- end
49
- end
50
-
51
- R2MCommand.start
8
+ R2M::Command.start
@@ -0,0 +1,35 @@
1
+
2
+ require 'thor'
3
+
4
+ module R2M
5
+ class Command < Thor
6
+ include Thor::Actions
7
+
8
+ default_command :convert
9
+ argument :path, default: 'spec'
10
+
11
+ def self.exit_on_failure?
12
+ true
13
+ end
14
+
15
+ desc 'convert', 'Convert Rspec to MiniTest'
16
+
17
+ def convert
18
+ files.each { |file| process file }
19
+ end
20
+
21
+ private
22
+
23
+ def process(file)
24
+ Processor.new(self).process(file)
25
+ end
26
+
27
+ def files
28
+ if Dir.exist?(path)
29
+ Dir.glob(File.join(path, '**', '*_test.rb'))
30
+ else
31
+ Dir.glob(path)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module R2M
6
+ # Process input RSpec and convert it to minitest
7
+ class Processor
8
+ def initialize(command)
9
+ @command = command
10
+ end
11
+
12
+ def process(file)
13
+ # it 'converts it"s to test method with # support' do # => def test_converts_it_s_to_test_method_with_support
14
+ convert_it_to_methods(file)
15
+ end
16
+
17
+ # Finds +it+ cases and converts to test methods declarations
18
+ #
19
+ # it 'converts it"s to test method with # support' do
20
+ # # => def test_converts_it_s_to_test_method_with_support
21
+ def convert_it_to_methods(file)
22
+ @command.gsub_file(file, /(?<=\bit ').*?(?=' do\b)/) do |match|
23
+ match.gsub(/[^\w]+/, '_').downcase
24
+ end
25
+
26
+ @command.gsub_file(file, /it '(.*)' do/, 'def test_\1')
27
+ end
28
+
29
+ # Finds +be_empty+ RSpec matchers and converts to minitest matchers
30
+ #
31
+ # expect(target).to be_empty # => expect(target).must_be_empty
32
+ # expect(target).to_not be_empty # => expect(target).wont_be_empty
33
+ # expect(target).not_to be_empty # => expect(target).wont_be_empty
34
+ def convert_mather_be_empty(file)
35
+ @command.gsub_file(file, /\.to be_empty/, '.must_be_empty')
36
+ @command.gsub_file(file, /\.(to_not|not_to) be_empty/, '.wont_be_empty')
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module R2M
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.bindir = "exe"
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency 'thor'
29
31
  end
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Keen
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2020-05-01 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: A command-line tool for converting RSpec files to minitest.
14
28
  email:
15
29
  - info@jetthoughts.com
@@ -32,6 +46,8 @@ files:
32
46
  - exe/r2m
33
47
  - exe/rspec2minitest
34
48
  - lib/r2m.rb
49
+ - lib/r2m/command.rb
50
+ - lib/r2m/processor.rb
35
51
  - lib/r2m/version.rb
36
52
  - r2m.gemspec
37
53
  homepage: https://github.com/jetthoughts/r2m