minitest_to_rspec 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +51 -0
- data/.rubocop_todo.yml +0 -235
- data/CHANGELOG.md +15 -0
- data/lib/minitest_to_rspec.rb +1 -0
- data/lib/minitest_to_rspec/cli.rb +16 -15
- data/lib/minitest_to_rspec/converter.rb +1 -0
- data/lib/minitest_to_rspec/errors.rb +4 -3
- data/lib/minitest_to_rspec/model/base.rb +0 -1
- data/lib/minitest_to_rspec/model/call.rb +4 -5
- data/lib/minitest_to_rspec/model/calls/returns.rb +4 -5
- data/lib/minitest_to_rspec/model/hash_exp.rb +0 -1
- data/lib/minitest_to_rspec/model/iter.rb +0 -1
- data/lib/minitest_to_rspec/model/klass.rb +0 -1
- data/lib/minitest_to_rspec/processor.rb +3 -0
- data/lib/minitest_to_rspec/sexp_assertions.rb +0 -1
- data/lib/minitest_to_rspec/subprocessors/base.rb +6 -0
- data/lib/minitest_to_rspec/subprocessors/call.rb +3 -3
- data/lib/minitest_to_rspec/subprocessors/defn.rb +2 -2
- data/lib/minitest_to_rspec/subprocessors/iter.rb +1 -0
- data/lib/minitest_to_rspec/subprocessors/klass.rb +3 -2
- data/lib/minitest_to_rspec/version.rb +1 -1
- data/minitest_to_rspec.gemspec +4 -10
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a89068f950887ebcdd8be9c8ca536dfa940f2143
|
4
|
+
data.tar.gz: 04a7059143e642b7716569d071fa47f1e9430977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae2983733dfc525b9866deea9b088a959d5472a16f9d85b82f2d313622e8d64c52e3613e55fea2ba5956474ef3fec43f8cfbac38c5bd055aab8693ed6247fa59
|
7
|
+
data.tar.gz: d0a13ebcd6acaed6df633c931147a81c88766d85129942632c0e7acbfa4575b55c023fe289fbbe77202bf303133d14595d42a85a0f8f8d96715028ab9b571b81
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -4,3 +4,54 @@ AllCops:
|
|
4
4
|
Exclude:
|
5
5
|
- spec/fixtures/**/*
|
6
6
|
TargetRubyVersion: 2.3
|
7
|
+
|
8
|
+
Layout/AlignParameters:
|
9
|
+
EnforcedStyle: with_fixed_indentation
|
10
|
+
|
11
|
+
Layout/FirstParameterIndentation:
|
12
|
+
EnforcedStyle: consistent
|
13
|
+
|
14
|
+
Layout/IndentHeredoc:
|
15
|
+
EnforcedStyle: squiggly
|
16
|
+
|
17
|
+
Layout/MultilineMethodCallBraceLayout:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Layout/MultilineMethodCallIndentation:
|
21
|
+
EnforcedStyle: indented
|
22
|
+
|
23
|
+
# We use the symbols `:true` and `:false` in S-expressions.
|
24
|
+
Lint/BooleanSymbol:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
# Not useful compared to e.g. AbcSize
|
28
|
+
Metrics/BlockLength:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
# Not useful compared to e.g. AbcSize
|
32
|
+
Metrics/ClassLength:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
# Not useful compared to e.g. AbcSize
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Not useful compared to e.g. AbcSize
|
40
|
+
Metrics/ModuleLength:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# EOS is a well-known delimiter and thus satisfactory.
|
44
|
+
Naming/HeredocDelimiterNaming:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# Prefer semantic delimiters, but avoid `end.x`. Too subtle to lint.
|
48
|
+
Style/BlockDelimiters:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/Documentation:
|
52
|
+
Exclude:
|
53
|
+
- 'spec/**/*'
|
54
|
+
|
55
|
+
# Guard clauses are great, but this is too subtle to lint.
|
56
|
+
Style/GuardClause:
|
57
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -6,241 +6,6 @@
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count: 1
|
10
|
-
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
-
# Include: **/*.gemspec
|
13
|
-
Gemspec/OrderedDependencies:
|
14
|
-
Exclude:
|
15
|
-
- 'minitest_to_rspec.gemspec'
|
16
|
-
|
17
|
-
# Offense count: 11
|
18
|
-
# Cop supports --auto-correct.
|
19
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
20
|
-
# SupportedStyles: with_first_parameter, with_fixed_indentation
|
21
|
-
Layout/AlignParameters:
|
22
|
-
Exclude:
|
23
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
24
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
25
|
-
|
26
|
-
# Offense count: 16
|
27
|
-
# Cop supports --auto-correct.
|
28
|
-
Layout/ClosingParenthesisIndentation:
|
29
|
-
Exclude:
|
30
|
-
- 'lib/minitest_to_rspec/subprocessors/base.rb'
|
31
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
32
|
-
- 'lib/minitest_to_rspec/subprocessors/iter.rb'
|
33
|
-
- 'spec/lib/subprocessors/base_spec.rb'
|
34
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
35
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
36
|
-
|
37
|
-
# Offense count: 7
|
38
|
-
# Cop supports --auto-correct.
|
39
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
40
|
-
# SupportedStyles: leading, trailing
|
41
|
-
Layout/DotPosition:
|
42
|
-
Exclude:
|
43
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
44
|
-
- 'lib/minitest_to_rspec/model/call.rb'
|
45
|
-
- 'lib/minitest_to_rspec/model/calls/returns.rb'
|
46
|
-
|
47
|
-
# Offense count: 1
|
48
|
-
# Cop supports --auto-correct.
|
49
|
-
Layout/EmptyLineAfterMagicComment:
|
50
|
-
Exclude:
|
51
|
-
- 'minitest_to_rspec.gemspec'
|
52
|
-
|
53
|
-
# Offense count: 5
|
54
|
-
# Cop supports --auto-correct.
|
55
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
56
|
-
# SupportedStyles: empty_lines, no_empty_lines
|
57
|
-
Layout/EmptyLinesAroundBlockBody:
|
58
|
-
Exclude:
|
59
|
-
- 'spec/lib/converter_spec.rb'
|
60
|
-
- 'spec/lib/model/calls/returns_spec.rb'
|
61
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
62
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
63
|
-
|
64
|
-
# Offense count: 2
|
65
|
-
# Cop supports --auto-correct.
|
66
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
67
|
-
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
68
|
-
Layout/EmptyLinesAroundClassBody:
|
69
|
-
Exclude:
|
70
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
71
|
-
- 'lib/minitest_to_rspec/subprocessors/klass.rb'
|
72
|
-
|
73
|
-
# Offense count: 8
|
74
|
-
# Cop supports --auto-correct.
|
75
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
76
|
-
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
77
|
-
Layout/EmptyLinesAroundModuleBody:
|
78
|
-
Exclude:
|
79
|
-
- 'lib/minitest_to_rspec/model/base.rb'
|
80
|
-
- 'lib/minitest_to_rspec/model/call.rb'
|
81
|
-
- 'lib/minitest_to_rspec/model/calls/returns.rb'
|
82
|
-
- 'lib/minitest_to_rspec/model/hash_exp.rb'
|
83
|
-
- 'lib/minitest_to_rspec/model/iter.rb'
|
84
|
-
- 'lib/minitest_to_rspec/model/klass.rb'
|
85
|
-
- 'lib/minitest_to_rspec/sexp_assertions.rb'
|
86
|
-
- 'spec/lib/sexp_assertions_spec.rb'
|
87
|
-
|
88
|
-
# Offense count: 10
|
89
|
-
# Cop supports --auto-correct.
|
90
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
91
|
-
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
92
|
-
Layout/FirstParameterIndentation:
|
93
|
-
Exclude:
|
94
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
95
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
96
|
-
|
97
|
-
# Offense count: 4
|
98
|
-
# Cop supports --auto-correct.
|
99
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
100
|
-
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
101
|
-
Layout/IndentHeredoc:
|
102
|
-
Exclude:
|
103
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
104
|
-
- 'lib/minitest_to_rspec/errors.rb'
|
105
|
-
- 'minitest_to_rspec.gemspec'
|
106
|
-
|
107
|
-
# Offense count: 15
|
108
|
-
# Cop supports --auto-correct.
|
109
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
110
|
-
# SupportedStyles: symmetrical, new_line, same_line
|
111
|
-
Layout/MultilineMethodCallBraceLayout:
|
112
|
-
Exclude:
|
113
|
-
- 'lib/minitest_to_rspec/subprocessors/base.rb'
|
114
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
115
|
-
- 'lib/minitest_to_rspec/subprocessors/iter.rb'
|
116
|
-
- 'spec/lib/subprocessors/base_spec.rb'
|
117
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
118
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
119
|
-
|
120
|
-
# Offense count: 1
|
121
|
-
# Cop supports --auto-correct.
|
122
|
-
Layout/SpaceInsideParens:
|
123
|
-
Exclude:
|
124
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
125
|
-
|
126
|
-
# Offense count: 3
|
127
|
-
Lint/BooleanSymbol:
|
128
|
-
Exclude:
|
129
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
130
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
131
|
-
|
132
|
-
# Offense count: 15
|
133
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
134
|
-
Metrics/BlockLength:
|
135
|
-
Max: 280
|
136
|
-
|
137
|
-
# Offense count: 2
|
138
|
-
# Configuration parameters: CountComments.
|
139
|
-
Metrics/ClassLength:
|
140
|
-
Max: 241
|
141
|
-
|
142
|
-
# Offense count: 7
|
143
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
144
|
-
# URISchemes: http, https
|
145
|
-
Metrics/LineLength:
|
146
|
-
Max: 92
|
147
|
-
|
148
|
-
# Offense count: 3
|
149
|
-
# Configuration parameters: CountComments.
|
150
|
-
Metrics/MethodLength:
|
151
|
-
Max: 18
|
152
|
-
|
153
|
-
# Offense count: 3
|
154
|
-
# Configuration parameters: CountComments.
|
155
|
-
Metrics/ModuleLength:
|
156
|
-
Max: 282
|
157
|
-
|
158
|
-
# Offense count: 30
|
159
|
-
# Configuration parameters: Blacklist.
|
160
|
-
# Blacklist: END, (?-mix:EO[A-Z]{1})
|
161
|
-
Naming/HeredocDelimiterNaming:
|
162
|
-
Exclude:
|
163
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
164
|
-
- 'lib/minitest_to_rspec/errors.rb'
|
165
|
-
- 'minitest_to_rspec.gemspec'
|
166
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
167
|
-
- 'spec/lib/subprocessors/iter_spec.rb'
|
168
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
169
|
-
|
170
|
-
# Offense count: 1
|
171
|
-
# Cop supports --auto-correct.
|
172
|
-
Performance/StringReplacement:
|
173
|
-
Exclude:
|
174
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
175
|
-
|
176
|
-
# Offense count: 16
|
177
|
-
# Cop supports --auto-correct.
|
178
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
179
|
-
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
180
|
-
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
181
|
-
# FunctionalMethods: let, let!, subject, watch
|
182
|
-
# IgnoredMethods: lambda, proc, it
|
183
|
-
Style/BlockDelimiters:
|
184
|
-
Exclude:
|
185
|
-
- 'lib/minitest_to_rspec/model/iter.rb'
|
186
|
-
- 'lib/minitest_to_rspec/model/klass.rb'
|
187
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
188
|
-
- 'lib/minitest_to_rspec/subprocessors/iter.rb'
|
189
|
-
- 'spec/lib/cli_spec.rb'
|
190
|
-
- 'spec/lib/model/call_spec.rb'
|
191
|
-
- 'spec/lib/sexp_assertions_spec.rb'
|
192
|
-
- 'spec/lib/subprocessors/iter_spec.rb'
|
193
|
-
- 'spec/lib/subprocessors/klass_spec.rb'
|
194
|
-
|
195
|
-
# Offense count: 9
|
196
|
-
Style/Documentation:
|
197
|
-
Exclude:
|
198
|
-
- 'spec/**/*'
|
199
|
-
- 'test/**/*'
|
200
|
-
- 'lib/minitest_to_rspec.rb'
|
201
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
202
|
-
- 'lib/minitest_to_rspec/converter.rb'
|
203
|
-
- 'lib/minitest_to_rspec/errors.rb'
|
204
|
-
- 'lib/minitest_to_rspec/processor.rb'
|
205
|
-
- 'lib/minitest_to_rspec/subprocessors/base.rb'
|
206
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
207
|
-
- 'lib/minitest_to_rspec/subprocessors/iter.rb'
|
208
|
-
- 'lib/minitest_to_rspec/subprocessors/klass.rb'
|
209
|
-
|
210
|
-
# Offense count: 1
|
211
|
-
# Cop supports --auto-correct.
|
212
|
-
Style/Encoding:
|
213
|
-
Exclude:
|
214
|
-
- 'minitest_to_rspec.gemspec'
|
215
|
-
|
216
|
-
# Offense count: 6
|
217
|
-
# Configuration parameters: MinBodyLength.
|
218
|
-
Style/GuardClause:
|
219
|
-
Exclude:
|
220
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
221
|
-
- 'lib/minitest_to_rspec/model/call.rb'
|
222
|
-
- 'lib/minitest_to_rspec/model/calls/returns.rb'
|
223
|
-
- 'lib/minitest_to_rspec/sexp_assertions.rb'
|
224
|
-
|
225
|
-
# Offense count: 2
|
226
|
-
# Cop supports --auto-correct.
|
227
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
228
|
-
# SupportedStyles: line_count_dependent, lambda, literal
|
229
|
-
Style/Lambda:
|
230
|
-
Exclude:
|
231
|
-
- 'spec/lib/subprocessors/call_spec.rb'
|
232
|
-
- 'spec/lib/subprocessors/iter_spec.rb'
|
233
|
-
|
234
|
-
# Offense count: 5
|
235
|
-
# Cop supports --auto-correct.
|
236
|
-
Style/MutableConstant:
|
237
|
-
Exclude:
|
238
|
-
- 'lib/minitest_to_rspec/cli.rb'
|
239
|
-
- 'lib/minitest_to_rspec/errors.rb'
|
240
|
-
- 'lib/minitest_to_rspec/model/calls/returns.rb'
|
241
|
-
- 'lib/minitest_to_rspec/subprocessors/call.rb'
|
242
|
-
- 'spec/lib/converter_spec.rb'
|
243
|
-
|
244
9
|
# Offense count: 5
|
245
10
|
# Cop supports --auto-correct.
|
246
11
|
Style/RedundantFreeze:
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,21 @@ of [keepachangelog.com][2].
|
|
17
17
|
|
18
18
|
- None
|
19
19
|
|
20
|
+
## 0.10.1 (2017-11-04)
|
21
|
+
|
22
|
+
### Breaking Changes
|
23
|
+
|
24
|
+
- None
|
25
|
+
|
26
|
+
### Added
|
27
|
+
|
28
|
+
- None
|
29
|
+
|
30
|
+
### Fixed
|
31
|
+
|
32
|
+
- [#10](https://github.com/jaredbeck/minitest_to_rspec/pull/10) - Lift
|
33
|
+
version constraint on sexp_processor
|
34
|
+
|
20
35
|
## 0.10.0 (2017-11-01)
|
21
36
|
|
22
37
|
### Breaking Changes
|
data/lib/minitest_to_rspec.rb
CHANGED
@@ -5,6 +5,7 @@ require "minitest_to_rspec"
|
|
5
5
|
require "trollop"
|
6
6
|
|
7
7
|
module MinitestToRspec
|
8
|
+
# Command-Line Interface (CLI) instantiated by `bin/mt2rspec`
|
8
9
|
class CLI
|
9
10
|
E_USAGE = 1.freeze
|
10
11
|
E_FILE_NOT_FOUND = 2.freeze
|
@@ -12,21 +13,21 @@ module MinitestToRspec
|
|
12
13
|
E_CONVERT_FAIL = 4.freeze
|
13
14
|
E_CANNOT_CREATE_TARGET_DIR = 5.freeze
|
14
15
|
|
15
|
-
BANNER =
|
16
|
-
Usage: mt2rspec [--rails] [--mocha] source_file [target_file]
|
16
|
+
BANNER = <<~EOS.freeze
|
17
|
+
Usage: mt2rspec [--rails] [--mocha] source_file [target_file]
|
17
18
|
|
18
|
-
Reads source_file, writes target_file. If target_file is omitted,
|
19
|
-
its location will be inferred. For example, test/fruit/banana_test.rb
|
20
|
-
implies spec/fruit/banana_spec.rb. If the target directory doesn't
|
21
|
-
exist, it will be created.
|
19
|
+
Reads source_file, writes target_file. If target_file is omitted,
|
20
|
+
its location will be inferred. For example, test/fruit/banana_test.rb
|
21
|
+
implies spec/fruit/banana_spec.rb. If the target directory doesn't
|
22
|
+
exist, it will be created.
|
22
23
|
|
23
|
-
Options:
|
24
|
-
EOS
|
24
|
+
Options:
|
25
|
+
EOS
|
25
26
|
OPT_MOCHA = "Convert mocha to rspec-mocks. (Experimental)"
|
26
|
-
OPT_RAILS =
|
27
|
-
Requires rails_helper instead of spec_helper.
|
28
|
-
Passes :type metadatum to RSpec.describe.
|
29
|
-
EOS
|
27
|
+
OPT_RAILS = <<~EOS.tr("\n", " ").freeze
|
28
|
+
Requires rails_helper instead of spec_helper.
|
29
|
+
Passes :type metadatum to RSpec.describe.
|
30
|
+
EOS
|
30
31
|
|
31
32
|
attr_reader :source, :target
|
32
33
|
|
@@ -95,9 +96,9 @@ EOS
|
|
95
96
|
end
|
96
97
|
|
97
98
|
def infer_target_from(source)
|
98
|
-
source
|
99
|
-
gsub(/\Atest/, "spec")
|
100
|
-
gsub(/_test.rb\Z/, "_spec.rb")
|
99
|
+
source
|
100
|
+
.gsub(/\Atest/, "spec")
|
101
|
+
.gsub(/_test.rb\Z/, "_spec.rb")
|
101
102
|
end
|
102
103
|
|
103
104
|
def read_source
|
@@ -14,10 +14,11 @@ module MinitestToRspec
|
|
14
14
|
# does not (yet) implement a conversion.
|
15
15
|
class NotImplemented < Error; end
|
16
16
|
|
17
|
+
# See DEFAULT_MESSAGE
|
17
18
|
class ModuleShorthandError < NotImplemented
|
18
|
-
DEFAULT_MESSAGE =
|
19
|
-
Unsupported class definition: Module shorthand (A::B::C) is not supported.
|
20
|
-
Please convert your class definition to use nested modules and try again.
|
19
|
+
DEFAULT_MESSAGE = <<~EOS
|
20
|
+
Unsupported class definition: Module shorthand (A::B::C) is not supported.
|
21
|
+
Please convert your class definition to use nested modules and try again.
|
21
22
|
EOS
|
22
23
|
|
23
24
|
def initialize(msg = nil)
|
@@ -4,7 +4,6 @@ require_relative "base"
|
|
4
4
|
|
5
5
|
module MinitestToRspec
|
6
6
|
module Model
|
7
|
-
|
8
7
|
# Data object. Represents a `:call` s-expression.
|
9
8
|
class Call < Base
|
10
9
|
attr_reader :original
|
@@ -73,10 +72,10 @@ module MinitestToRspec
|
|
73
72
|
end
|
74
73
|
|
75
74
|
def calls_in_receiver_chain
|
76
|
-
receiver_chain
|
77
|
-
compact
|
78
|
-
select { |r| sexp_type?(:call, r) }
|
79
|
-
map { |r| Call.new(r) }
|
75
|
+
receiver_chain
|
76
|
+
.compact
|
77
|
+
.select { |r| sexp_type?(:call, r) }
|
78
|
+
.map { |r| Call.new(r) }
|
80
79
|
end
|
81
80
|
|
82
81
|
def method_name
|
@@ -6,11 +6,10 @@ require_relative "../../errors"
|
|
6
6
|
module MinitestToRspec
|
7
7
|
module Model
|
8
8
|
module Calls
|
9
|
-
|
10
9
|
# Represents a call to `returns`, the stubbing method
|
11
10
|
# from `mocha`.
|
12
11
|
class Returns < Call
|
13
|
-
KNOWN_RECEIVERS = %i[stubs expects with]
|
12
|
+
KNOWN_RECEIVERS = %i[stubs expects with].freeze
|
14
13
|
|
15
14
|
def initialize(exp)
|
16
15
|
@exp = exp
|
@@ -39,9 +38,9 @@ module MinitestToRspec
|
|
39
38
|
end
|
40
39
|
|
41
40
|
def message
|
42
|
-
calls_in_receiver_chain
|
43
|
-
find { |c| [:stubs, :expects].include? c.method_name }
|
44
|
-
arguments[0]
|
41
|
+
calls_in_receiver_chain
|
42
|
+
.find { |c| [:stubs, :expects].include? c.method_name }
|
43
|
+
.arguments[0]
|
45
44
|
end
|
46
45
|
|
47
46
|
# To avoid a `ProcessingError` please check `known_variant?`
|
@@ -8,6 +8,9 @@ require_relative "subprocessors/klass"
|
|
8
8
|
require_relative "subprocessors/iter"
|
9
9
|
|
10
10
|
module MinitestToRspec
|
11
|
+
# Consumes a `String` of minitest code and returns an S-expression
|
12
|
+
# representing equivalent RSpec code. The main method is `#process`. See
|
13
|
+
# `SexpProcessor` docs for details.
|
11
14
|
class Processor < SexpProcessor
|
12
15
|
def initialize(rails, mocha)
|
13
16
|
super()
|
@@ -4,6 +4,12 @@ require_relative "../sexp_assertions"
|
|
4
4
|
|
5
5
|
module MinitestToRspec
|
6
6
|
module Subprocessors
|
7
|
+
# Parent class of "sub-processors". There is one sub-processor for each
|
8
|
+
# `sexp_type` that `Processor` knows how to process.
|
9
|
+
#
|
10
|
+
# For example, `Subprocessors::Call` will process an `s(:call, ..)`
|
11
|
+
# expression representing minitest code, and return an S-expression
|
12
|
+
# representing equivalent RSpec code.
|
7
13
|
class Base
|
8
14
|
include SexpAssertions
|
9
15
|
|
@@ -7,8 +7,8 @@ require_relative "base"
|
|
7
7
|
|
8
8
|
module MinitestToRspec
|
9
9
|
module Subprocessors
|
10
|
+
# Processes `s(:call, ..)` expressions.
|
10
11
|
class Call < Base
|
11
|
-
|
12
12
|
# Mocha methods will only be processed if `--mocha` flag was given,
|
13
13
|
# i.e. `mocha` argument in constructor is true.
|
14
14
|
MOCHA_METHODS = %i[
|
@@ -19,7 +19,7 @@ module MinitestToRspec
|
|
19
19
|
stubs
|
20
20
|
stub_everything
|
21
21
|
twice
|
22
|
-
]
|
22
|
+
].freeze
|
23
23
|
|
24
24
|
def initialize(sexp, rails, mocha)
|
25
25
|
super(rails, mocha)
|
@@ -200,7 +200,7 @@ module MinitestToRspec
|
|
200
200
|
def method_stub_everything
|
201
201
|
if @exp.receiver.nil?
|
202
202
|
d = s(:call, nil, :double, *@exp.arguments)
|
203
|
-
s(:call, d, :as_null_object,
|
203
|
+
s(:call, d, :as_null_object,)
|
204
204
|
else
|
205
205
|
@exp.original
|
206
206
|
end
|
@@ -5,8 +5,8 @@ require_relative "base"
|
|
5
5
|
|
6
6
|
module MinitestToRspec
|
7
7
|
module Subprocessors
|
8
|
-
# Minitest tests can be defined as methods using names beginning with
|
9
|
-
# Process those tests into RSpec `it` example blocks.
|
8
|
+
# Minitest tests can be defined as methods using names beginning with
|
9
|
+
# 'test_'. Process those tests into RSpec `it` example blocks.
|
10
10
|
class Defn < Base
|
11
11
|
def initialize(sexp, rails, mocha)
|
12
12
|
super(rails, mocha)
|
@@ -6,8 +6,8 @@ require_relative "base"
|
|
6
6
|
|
7
7
|
module MinitestToRspec
|
8
8
|
module Subprocessors
|
9
|
+
# Processes `s(:class, ..)` expressions.
|
9
10
|
class Klass < Base
|
10
|
-
|
11
11
|
# Takes `sexp`, a `:class` s-expression, and `rails`, a
|
12
12
|
# boolean indicating that `rspec-rails` conventions (like
|
13
13
|
# `:type` metadata) should be used.
|
@@ -32,7 +32,8 @@ module MinitestToRspec
|
|
32
32
|
|
33
33
|
# Returns a :block S-expression, the contents of the class.
|
34
34
|
def block
|
35
|
-
|
35
|
+
processed = @exp.block.map { |line| full_process(line) }
|
36
|
+
s(:block, *processed)
|
36
37
|
end
|
37
38
|
|
38
39
|
# Given a `test_class_name` like `BananaTest`, returns the
|
data/minitest_to_rspec.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
2
|
+
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'minitest_to_rspec/version'
|
@@ -12,8 +12,8 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.email = ["jared@jaredbeck.com"]
|
13
13
|
|
14
14
|
spec.summary = "Converts minitest files to rspec"
|
15
|
-
spec.description =
|
16
|
-
A command-line tool for converting minitest files to rspec.
|
15
|
+
spec.description = <<~EOS
|
16
|
+
A command-line tool for converting minitest files to rspec.
|
17
17
|
EOS
|
18
18
|
spec.homepage = "https://github.com/jaredbeck/minitest_to_rspec"
|
19
19
|
spec.license = "MIT"
|
@@ -24,16 +24,10 @@ A command-line tool for converting minitest files to rspec.
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
spec.required_ruby_version = ">= 2.3.0"
|
26
26
|
|
27
|
-
spec.add_runtime_dependency "ruby_parser", "~> 3.8"
|
28
27
|
spec.add_runtime_dependency "ruby2ruby", "~> 2.3"
|
28
|
+
spec.add_runtime_dependency "ruby_parser", "~> 3.8"
|
29
29
|
spec.add_runtime_dependency "trollop", "~> 2.1"
|
30
30
|
|
31
|
-
# Temporary runtime dependency. It seems there were breaking changes in
|
32
|
-
# sexp_processor between 4.7 and 4.10. When we have adapted to these breaking
|
33
|
-
# changes, we can lift this constraint.
|
34
|
-
# https://github.com/jaredbeck/minitest_to_rspec/issues/4
|
35
|
-
spec.add_runtime_dependency "sexp_processor", "< 4.8"
|
36
|
-
|
37
31
|
spec.add_development_dependency "bundler", "~> 1.7"
|
38
32
|
spec.add_development_dependency "byebug", "~> 9.1"
|
39
33
|
spec.add_development_dependency "rake", "~> 12.1"
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest_to_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Beck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: ruby2ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ruby_parser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: trollop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: sexp_processor
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "<"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '4.8'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "<"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '4.8'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: bundler
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|