transpec 1.13.1 → 2.0.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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +63 -22
- data/README.md.erb +55 -16
- data/lib/transpec/cli.rb +9 -9
- data/lib/transpec/commit_message.rb +2 -0
- data/lib/transpec/{configuration.rb → config.rb} +7 -6
- data/lib/transpec/converter.rb +57 -46
- data/lib/transpec/option_parser.rb +23 -25
- data/lib/transpec/rspec_version.rb +6 -0
- data/lib/transpec/spec_suite.rb +2 -6
- data/lib/transpec/syntax/example.rb +2 -15
- data/lib/transpec/syntax/example_group.rb +111 -9
- data/lib/transpec/syntax/have/dynamic_analysis.rb +1 -1
- data/lib/transpec/syntax/mixin/metadata.rb +29 -0
- data/lib/transpec/syntax/mixin/rspec_rails.rb +27 -0
- data/lib/transpec/syntax/rspec_configure.rb +14 -3
- data/lib/transpec/syntax/rspec_configure/{configuration_modification.rb → config_modification.rb} +18 -15
- data/lib/transpec/syntax/rspec_configure/framework.rb +7 -7
- data/lib/transpec/syntax/rspec_configure/mocks.rb +1 -1
- data/lib/transpec/version.rb +3 -3
- data/spec/transpec/commit_message_spec.rb +9 -1
- data/spec/transpec/{configuration_spec.rb → config_spec.rb} +19 -18
- data/spec/transpec/converter_spec.rb +245 -210
- data/spec/transpec/option_parser_spec.rb +27 -59
- data/spec/transpec/rspec_version_spec.rb +26 -0
- data/spec/transpec/syntax/example_group_spec.rb +277 -0
- data/spec/transpec/syntax/have_spec.rb +1 -1
- data/spec/transpec/syntax/rspec_configure_spec.rb +117 -0
- data/tasks/fixtures/guard/2.99.0/COMMIT_EDITMSG +3 -1
- data/tasks/fixtures/guard/3.0.0/COMMIT_EDITMSG +3 -1
- data/tasks/fixtures/mail/2.99.0/COMMIT_EDITMSG +3 -1
- data/tasks/fixtures/mail/3.0.0/COMMIT_EDITMSG +3 -1
- data/tasks/fixtures/twitter/2.99.0/COMMIT_EDITMSG +3 -1
- data/tasks/fixtures/twitter/3.0.0/COMMIT_EDITMSG +3 -1
- data/tasks/readme.rake +3 -2
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c55138d0f6562f6e88f54a665a1606ff3b69f97d
|
4
|
+
data.tar.gz: ad436da74d347b87d8e5e96adebf45f2e8c9bc29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d194a5757be5ebad5680322636fb28e4acb2179421d89b018a3e40965a5712c8395aa8a2130e6bb13e6e74a32d9da4785f458f5cc4c7a4b041a3b169c793040a
|
7
|
+
data.tar.gz: 82630e3bab603645603d56cf8d272e8a5ced283989ee1e59bfb3fba43cb78738d6563d11ac645d6d49dda62391da6f88b44b06afc8673335be7518cdadd145d8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Development
|
4
4
|
|
5
|
+
## v2.0.0
|
6
|
+
|
7
|
+
* Support conversion of implicit spec types in rspec-rails. ([#57](https://github.com/yujinakayama/transpec/issues/57))
|
8
|
+
* Enable conversion of `have(n).items` even if rspec-rails is loaded in the spec according to the removal of rspec-collection_matchers in rspec-rails 3.
|
9
|
+
* Remove support for deprecated options `-m/--generate-commit-message` and `-t/--convert-stub-with-hash`.
|
10
|
+
|
5
11
|
## v1.13.1
|
6
12
|
|
7
13
|
* Fix a bug where multiline expression `expect(obj).to receive(:message)\n.and_return { value }` was converted to `expect(obj).to.receive(:message)\n { value }` and the block was interpreted as a hash literal. ([#60](https://github.com/yujinakayama/transpec/issues/60))
|
data/README.md
CHANGED
@@ -133,7 +133,7 @@ Running dynamic analysis with command "bundle exec rspec"...
|
|
133
133
|
Finished in 13.07 seconds
|
134
134
|
100 examples, 0 failures
|
135
135
|
|
136
|
-
|
136
|
+
Gathering the spec suite data...
|
137
137
|
|
138
138
|
Converting spec/spec_helper.rb
|
139
139
|
Converting spec/support/cache_helper.rb
|
@@ -202,6 +202,9 @@ read this article by [Myron Marston](https://github.com/myronmarston), who is th
|
|
202
202
|
|
203
203
|
## Options
|
204
204
|
|
205
|
+
Though Transpec ships with sensible defaults that essentially conform to the RSpec 3 defaults,
|
206
|
+
you can customize the conversion behavior.
|
207
|
+
|
205
208
|
### `-f/--force`
|
206
209
|
|
207
210
|
Force processing even if the current Git repository is not clean.
|
@@ -210,7 +213,7 @@ Force processing even if the current Git repository is not clean.
|
|
210
213
|
$ git status --short
|
211
214
|
M spec/spec_helper.rb
|
212
215
|
$ transpec
|
213
|
-
The current Git repository is not clean. Aborting.
|
216
|
+
The current Git repository is not clean. Aborting. If you want to proceed forcibly, use -f/--force option.
|
214
217
|
$ transpec --force
|
215
218
|
Copying project for dynamic analysis...
|
216
219
|
Running dynamic analysis with command "bundle exec rspec"...
|
@@ -479,6 +482,7 @@ The one-liner (implicit receiver) `should`:
|
|
479
482
|
* [Pending examples](#pending-examples)
|
480
483
|
* [Current example object](#current-example-object)
|
481
484
|
* [Custom matcher DSL](#custom-matcher-dsl)
|
485
|
+
* [Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails)
|
482
486
|
* [Example groups](#example-groups)
|
483
487
|
* [Hook scope aliases](#hook-scope-aliases)
|
484
488
|
|
@@ -594,8 +598,6 @@ expect(obj).to be false
|
|
594
598
|
|
595
599
|
So, converting `be_true`/`be_false` to `be_truthy`/`be_falsey` never breaks your specs and this is Transpec's default. If you are willing to test boolean values strictly, you can convert them to `be true`/`be false` with `--boolean-matcher true,false` option. Note that this may break your specs if your application code don't return exact boolean values.
|
596
600
|
|
597
|
-
---
|
598
|
-
|
599
601
|
* This conversion can be disabled by: `--keep deprecated`
|
600
602
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
601
603
|
* See also: [Consider renaming `be_true` and `be_false` to `be_truthy` and `be_falsey` · rspec/rspec-expectations](https://github.com/rspec/rspec-expectations/issues/283)
|
@@ -620,7 +622,7 @@ expect(1.0 / 3.0).to be_within(0.001).of(0.333)
|
|
620
622
|
|
621
623
|
### `have(n).items` matcher
|
622
624
|
|
623
|
-
**This conversion will be disabled automatically if `rspec-collection_matchers`
|
625
|
+
**This conversion will be disabled automatically if `rspec-collection_matchers` is loaded in your spec.**
|
624
626
|
|
625
627
|
Targets:
|
626
628
|
|
@@ -660,9 +662,7 @@ There's an option to continue using `have(n).items` matcher with [rspec-collecti
|
|
660
662
|
If you choose to do so, disable this conversion by either:
|
661
663
|
|
662
664
|
* Specify `--keep have_items` option manually.
|
663
|
-
* Require `rspec-collection_matchers`
|
664
|
-
|
665
|
-
Note: `rspec-rails` 3.0 [still uses `have(n).items` matcher with `rspec-collection_matchers`](https://github.com/rspec/rspec-rails/blob/v3.0.0.beta1/rspec-rails.gemspec#L41).
|
665
|
+
* Require `rspec-collection_matchers` in your spec so that Transpec automatically disables this conversion.
|
666
666
|
|
667
667
|
---
|
668
668
|
|
@@ -672,7 +672,7 @@ Note: `rspec-rails` 3.0 [still uses `have(n).items` matcher with `rspec-collecti
|
|
672
672
|
|
673
673
|
### One-liner expectations with `have(n).items` matcher
|
674
674
|
|
675
|
-
**This conversion will be disabled automatically if `rspec-collection_matchers`
|
675
|
+
**This conversion will be disabled automatically if `rspec-collection_matchers` is loaded in your spec.**
|
676
676
|
|
677
677
|
Targets:
|
678
678
|
|
@@ -909,7 +909,7 @@ So, if you're going to use Transpec in [the upgrade path to RSpec 3](http://myro
|
|
909
909
|
3. Upgrade to RSpec 3.0
|
910
910
|
4. Run `transpec` again to convert `obj.stub(:message => value)`
|
911
911
|
|
912
|
-
Or if you're going to stay RSpec 2.14 for now but want to convert all `stub` to `allow` statements, run `transpec` with `--convert
|
912
|
+
Or if you're going to stay RSpec 2.14 for now but want to convert all `stub` to `allow` statements, run `transpec` with `--convert stub_with_hash` option. Note that once the conversion is done, multiple statements cannot be merged into a `receive_messages`.
|
913
913
|
|
914
914
|
* This conversion can be disabled by: `--keep stub`
|
915
915
|
* Deprecation: deprecated since RSpec 3.0
|
@@ -994,8 +994,6 @@ end
|
|
994
994
|
|
995
995
|
describe 'example' do
|
996
996
|
it 'is any_instance implementation block' do
|
997
|
-
Klass.any_instance.should_receive(:message) { |arg| puts arg }
|
998
|
-
Klass.any_instance.stub(:message) { |arg| puts arg }
|
999
997
|
expect_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1000
998
|
allow_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1001
999
|
end
|
@@ -1015,8 +1013,6 @@ describe 'example' do
|
|
1015
1013
|
it 'is any_instance implementation block' do
|
1016
1014
|
expect_any_instance_of(Klass).to receive(:message) { |instance, arg| puts arg }
|
1017
1015
|
allow_any_instance_of(Klass).to receive(:message) { |instance, arg| puts arg }
|
1018
|
-
expect_any_instance_of(Klass).to receive(:message) { |instance, arg| puts arg }
|
1019
|
-
allow_any_instance_of(Klass).to receive(:message) { |instance, arg| puts arg }
|
1020
1016
|
end
|
1021
1017
|
end
|
1022
1018
|
|
@@ -1031,8 +1027,6 @@ describe 'example' do
|
|
1031
1027
|
it 'is any_instance implementation block' do
|
1032
1028
|
expect_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1033
1029
|
allow_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1034
|
-
expect_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1035
|
-
allow_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1036
1030
|
end
|
1037
1031
|
end
|
1038
1032
|
```
|
@@ -1202,8 +1196,6 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/7d
|
|
1202
1196
|
> end
|
1203
1197
|
> ```
|
1204
1198
|
|
1205
|
-
---
|
1206
|
-
|
1207
1199
|
* This conversion can be disabled by: `--keep deprecated`
|
1208
1200
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1209
1201
|
* See also: [Core: DSL methods will yield the example - The Plan for RSpec 3](http://myronmars.to/n/dev-blog/2013/07/the-plan-for-rspec-3#core_dsl_methods_will_yield_the_example)
|
@@ -1238,6 +1230,55 @@ end
|
|
1238
1230
|
* Deprecation: deprecated since RSpec 3.0
|
1239
1231
|
* See also: [Expectations: Matcher protocol and custom matcher API changes - The Plan for RSpec 3](http://myronmars.to/n/dev-blog/2013/07/the-plan-for-rspec-3#expectations_matcher_protocol_and_custom_matcher_api_changes)
|
1240
1232
|
|
1233
|
+
### Implicit spec types in rspec-rails
|
1234
|
+
|
1235
|
+
**This conversion is available only if `rspec-rails` is loaded in your spec and your project's RSpec is `2.99.0.rc1` or later.**
|
1236
|
+
|
1237
|
+
Targets:
|
1238
|
+
|
1239
|
+
```ruby
|
1240
|
+
# In spec/models/some_model_spec.rb
|
1241
|
+
RSpec.configure do |rspec|
|
1242
|
+
end
|
1243
|
+
|
1244
|
+
describe SomeModel do
|
1245
|
+
end
|
1246
|
+
```
|
1247
|
+
|
1248
|
+
Will be converted to:
|
1249
|
+
|
1250
|
+
```ruby
|
1251
|
+
RSpec.configure do |rspec|
|
1252
|
+
end
|
1253
|
+
|
1254
|
+
describe SomeModel, :type => :model do
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
# With `--no-explicit-spec-type`
|
1258
|
+
RSpec.configure do |rspec|
|
1259
|
+
rspec.infer_spec_type_from_file_location!
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
describe SomeModel do
|
1263
|
+
end
|
1264
|
+
```
|
1265
|
+
|
1266
|
+
Here's an excerpt from [the warning](https://github.com/rspec/rspec-rails/blob/ab6313b/lib/rspec/rails/infer_type_configuration.rb#L13-L22) in RSpec 2.99:
|
1267
|
+
|
1268
|
+
> rspec-rails 3 will no longer automatically infer an example group's spec type from the file location. You can explicitly opt-in to this feature using this snippet:
|
1269
|
+
>
|
1270
|
+
> ```ruby
|
1271
|
+
> RSpec.configure do |config|
|
1272
|
+
> config.infer_spec_type_from_file_location!
|
1273
|
+
> end
|
1274
|
+
> ```
|
1275
|
+
>
|
1276
|
+
> If you wish to manually label spec types via metadata you can safely ignore this warning and continue upgrading to RSpec 3 without addressing it.
|
1277
|
+
|
1278
|
+
* This conversion can be disabled by: `--keep deprecated`
|
1279
|
+
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1280
|
+
* See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
|
1281
|
+
|
1241
1282
|
### Example groups
|
1242
1283
|
|
1243
1284
|
**This conversion is disabled by default and available only if your project's RSpec is `3.0.0.beta2` or later.**
|
@@ -1290,8 +1331,8 @@ describe 'example' do
|
|
1290
1331
|
before(:all) { do_something }
|
1291
1332
|
end
|
1292
1333
|
|
1293
|
-
RSpec.configure do |
|
1294
|
-
before(:suite) { do_something }
|
1334
|
+
RSpec.configure do |rspec|
|
1335
|
+
rspec.before(:suite) { do_something }
|
1295
1336
|
end
|
1296
1337
|
```
|
1297
1338
|
|
@@ -1304,8 +1345,8 @@ describe 'example' do
|
|
1304
1345
|
before(:context) { do_something }
|
1305
1346
|
end
|
1306
1347
|
|
1307
|
-
RSpec.configure do |
|
1308
|
-
before(:suite) { do_something }
|
1348
|
+
RSpec.configure do |rspec|
|
1349
|
+
rspec.before(:suite) { do_something }
|
1309
1350
|
end
|
1310
1351
|
```
|
1311
1352
|
|
data/README.md.erb
CHANGED
@@ -107,7 +107,7 @@ Running dynamic analysis with command "bundle exec rspec"...
|
|
107
107
|
Finished in 13.07 seconds
|
108
108
|
100 examples, 0 failures
|
109
109
|
|
110
|
-
|
110
|
+
Gathering the spec suite data...
|
111
111
|
|
112
112
|
Converting spec/spec_helper.rb
|
113
113
|
Converting spec/support/cache_helper.rb
|
@@ -176,6 +176,9 @@ read this article by [Myron Marston](https://github.com/myronmarston), who is th
|
|
176
176
|
|
177
177
|
## Options
|
178
178
|
|
179
|
+
Though Transpec ships with sensible defaults that essentially conform to the RSpec 3 defaults,
|
180
|
+
you can customize the conversion behavior.
|
181
|
+
|
179
182
|
### `-f/--force`
|
180
183
|
|
181
184
|
Force processing even if the current Git repository is not clean.
|
@@ -184,7 +187,7 @@ Force processing even if the current Git repository is not clean.
|
|
184
187
|
$ git status --short
|
185
188
|
M spec/spec_helper.rb
|
186
189
|
$ transpec
|
187
|
-
The current Git repository is not clean. Aborting.
|
190
|
+
The current Git repository is not clean. Aborting. If you want to proceed forcibly, use -f/--force option.
|
188
191
|
$ transpec --force
|
189
192
|
Copying project for dynamic analysis...
|
190
193
|
Running dynamic analysis with command "bundle exec rspec"...
|
@@ -576,8 +579,6 @@ Will be converted to:
|
|
576
579
|
|
577
580
|
So, converting `be_true`/`be_false` to `be_truthy`/`be_falsey` never breaks your specs and this is Transpec's default. If you are willing to test boolean values strictly, you can convert them to `be true`/`be false` with `--boolean-matcher true,false` option. Note that this may break your specs if your application code don't return exact boolean values.
|
578
581
|
|
579
|
-
---
|
580
|
-
|
581
582
|
* This conversion can be disabled by: `--keep deprecated`
|
582
583
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
583
584
|
* See also: [Consider renaming `be_true` and `be_false` to `be_truthy` and `be_falsey` · rspec/rspec-expectations](https://github.com/rspec/rspec-expectations/issues/283)
|
@@ -606,7 +607,7 @@ Will be converted to:
|
|
606
607
|
|
607
608
|
### `have(n).items` matcher
|
608
609
|
|
609
|
-
**This conversion will be disabled automatically if `rspec-collection_matchers`
|
610
|
+
**This conversion will be disabled automatically if `rspec-collection_matchers` is loaded in your spec.**
|
610
611
|
|
611
612
|
Targets:
|
612
613
|
|
@@ -685,9 +686,7 @@ There's an option to continue using `have(n).items` matcher with [rspec-collecti
|
|
685
686
|
If you choose to do so, disable this conversion by either:
|
686
687
|
|
687
688
|
* Specify `--keep have_items` option manually.
|
688
|
-
* Require `rspec-collection_matchers`
|
689
|
-
|
690
|
-
Note: `rspec-rails` 3.0 [still uses `have(n).items` matcher with `rspec-collection_matchers`](https://github.com/rspec/rspec-rails/blob/v3.0.0.beta1/rspec-rails.gemspec#L41).
|
689
|
+
* Require `rspec-collection_matchers` in your spec so that Transpec automatically disables this conversion.
|
691
690
|
|
692
691
|
---
|
693
692
|
|
@@ -697,7 +696,7 @@ Note: `rspec-rails` 3.0 [still uses `have(n).items` matcher with `rspec-collecti
|
|
697
696
|
|
698
697
|
### One-liner expectations with `have(n).items` matcher
|
699
698
|
|
700
|
-
**This conversion will be disabled automatically if `rspec-collection_matchers`
|
699
|
+
**This conversion will be disabled automatically if `rspec-collection_matchers` is loaded in your spec.**
|
701
700
|
|
702
701
|
Targets:
|
703
702
|
|
@@ -974,7 +973,7 @@ So, if you're going to use Transpec in [the upgrade path to RSpec 3](http://myro
|
|
974
973
|
3. Upgrade to RSpec 3.0
|
975
974
|
4. Run `transpec` again to convert `obj.stub(:message => value)`
|
976
975
|
|
977
|
-
Or if you're going to stay RSpec 2.14 for now but want to convert all `stub` to `allow` statements, run `transpec` with `--convert
|
976
|
+
Or if you're going to stay RSpec 2.14 for now but want to convert all `stub` to `allow` statements, run `transpec` with `--convert stub_with_hash` option. Note that once the conversion is done, multiple statements cannot be merged into a `receive_messages`.
|
978
977
|
|
979
978
|
* This conversion can be disabled by: `--keep stub`
|
980
979
|
* Deprecation: deprecated since RSpec 3.0
|
@@ -1068,8 +1067,6 @@ end
|
|
1068
1067
|
|
1069
1068
|
describe 'example' do
|
1070
1069
|
it 'is any_instance implementation block' do
|
1071
|
-
Klass.any_instance.should_receive(:message) { |arg| puts arg }
|
1072
|
-
Klass.any_instance.stub(:message) { |arg| puts arg }
|
1073
1070
|
expect_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1074
1071
|
allow_any_instance_of(Klass).to receive(:message) { |arg| puts arg }
|
1075
1072
|
end
|
@@ -1238,8 +1235,6 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/7d
|
|
1238
1235
|
> end
|
1239
1236
|
> ```
|
1240
1237
|
|
1241
|
-
---
|
1242
|
-
|
1243
1238
|
* This conversion can be disabled by: `--keep deprecated`
|
1244
1239
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1245
1240
|
* See also: [Core: DSL methods will yield the example - The Plan for RSpec 3](http://myronmars.to/n/dev-blog/2013/07/the-plan-for-rspec-3#core_dsl_methods_will_yield_the_example)
|
@@ -1273,6 +1268,50 @@ Will be converted to:
|
|
1273
1268
|
* Deprecation: deprecated since RSpec 3.0
|
1274
1269
|
* See also: [Expectations: Matcher protocol and custom matcher API changes - The Plan for RSpec 3](http://myronmars.to/n/dev-blog/2013/07/the-plan-for-rspec-3#expectations_matcher_protocol_and_custom_matcher_api_changes)
|
1275
1270
|
|
1271
|
+
### Implicit spec types in rspec-rails
|
1272
|
+
|
1273
|
+
**This conversion is available only if `rspec-rails` is loaded in your spec and your project's RSpec is `<%= rspec_version = Transpec::RSpecVersion.implicit_spec_type_disablement_available_version %>` or later.**
|
1274
|
+
|
1275
|
+
Targets:
|
1276
|
+
|
1277
|
+
```ruby
|
1278
|
+
# In spec/models/some_model_spec.rb
|
1279
|
+
<%=
|
1280
|
+
example = <<END
|
1281
|
+
RSpec.configure do |rspec|
|
1282
|
+
end
|
1283
|
+
|
1284
|
+
describe SomeModel do
|
1285
|
+
end
|
1286
|
+
END
|
1287
|
+
-%>
|
1288
|
+
```
|
1289
|
+
|
1290
|
+
Will be converted to:
|
1291
|
+
|
1292
|
+
```ruby
|
1293
|
+
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb') -%>
|
1294
|
+
|
1295
|
+
# With `--no-explicit-spec-type`
|
1296
|
+
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb', cli: ['--no-explicit-spec-type']) -%>
|
1297
|
+
```
|
1298
|
+
|
1299
|
+
Here's an excerpt from [the warning](https://github.com/rspec/rspec-rails/blob/ab6313b/lib/rspec/rails/infer_type_configuration.rb#L13-L22) in RSpec 2.99:
|
1300
|
+
|
1301
|
+
> rspec-rails 3 will no longer automatically infer an example group's spec type from the file location. You can explicitly opt-in to this feature using this snippet:
|
1302
|
+
>
|
1303
|
+
> ```ruby
|
1304
|
+
> RSpec.configure do |config|
|
1305
|
+
> config.infer_spec_type_from_file_location!
|
1306
|
+
> end
|
1307
|
+
> ```
|
1308
|
+
>
|
1309
|
+
> If you wish to manually label spec types via metadata you can safely ignore this warning and continue upgrading to RSpec 3 without addressing it.
|
1310
|
+
|
1311
|
+
* This conversion can be disabled by: `--keep deprecated`
|
1312
|
+
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1313
|
+
* See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
|
1314
|
+
|
1276
1315
|
### Example groups
|
1277
1316
|
|
1278
1317
|
**This conversion is disabled by default and available only if your project's RSpec is `<%= rspec_version = Transpec::RSpecVersion.non_monkey_patch_example_group_available_version %>` or later.**
|
@@ -1321,8 +1360,8 @@ describe 'example' do
|
|
1321
1360
|
before(:all) { do_something }
|
1322
1361
|
end
|
1323
1362
|
|
1324
|
-
RSpec.configure do |
|
1325
|
-
before(:suite) { do_something }
|
1363
|
+
RSpec.configure do |rspec|
|
1364
|
+
rspec.before(:suite) { do_something }
|
1326
1365
|
end
|
1327
1366
|
END
|
1328
1367
|
-%>
|
data/lib/transpec/cli.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'transpec/commit_message'
|
4
|
-
require 'transpec/
|
4
|
+
require 'transpec/config'
|
5
5
|
require 'transpec/converter'
|
6
6
|
require 'transpec/dynamic_analyzer'
|
7
7
|
require 'transpec/option_parser'
|
@@ -13,7 +13,7 @@ require 'rainbow/ext/string' unless String.method_defined?(:color)
|
|
13
13
|
|
14
14
|
module Transpec
|
15
15
|
class CLI
|
16
|
-
attr_reader :project, :
|
16
|
+
attr_reader :project, :config, :report
|
17
17
|
|
18
18
|
def self.run(args = ARGV)
|
19
19
|
new.run(args)
|
@@ -21,13 +21,13 @@ module Transpec
|
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
@project = Project.new
|
24
|
-
@
|
24
|
+
@config = Config.new
|
25
25
|
@report = Report.new
|
26
26
|
end
|
27
27
|
|
28
28
|
def run(args)
|
29
29
|
begin
|
30
|
-
paths = OptionParser.new(
|
30
|
+
paths = OptionParser.new(config).parse(args)
|
31
31
|
fail_if_should_not_continue!
|
32
32
|
rescue => error
|
33
33
|
warn error.message
|
@@ -51,14 +51,14 @@ module Transpec
|
|
51
51
|
def process(paths)
|
52
52
|
runtime_data = nil
|
53
53
|
|
54
|
-
unless
|
54
|
+
unless config.skip_dynamic_analysis?
|
55
55
|
runtime_data = run_dynamic_analysis(paths)
|
56
56
|
end
|
57
57
|
|
58
58
|
spec_suite = SpecSuite.new(paths, runtime_data)
|
59
59
|
# Actually #analyze does not need to be invoked here, but doing this will avoid long freeze
|
60
60
|
# while conversion of files.
|
61
|
-
puts '
|
61
|
+
puts 'Gathering the spec suite data...'
|
62
62
|
spec_suite.analyze
|
63
63
|
puts
|
64
64
|
|
@@ -70,7 +70,7 @@ module Transpec
|
|
70
70
|
def convert_spec(spec, spec_suite)
|
71
71
|
puts "Converting #{spec.path}"
|
72
72
|
|
73
|
-
converter = Converter.new(spec_suite,
|
73
|
+
converter = Converter.new(spec_suite, config, project.rspec_version)
|
74
74
|
converter.convert_file!(spec)
|
75
75
|
|
76
76
|
warn_annotations(converter.report)
|
@@ -83,7 +83,7 @@ module Transpec
|
|
83
83
|
private
|
84
84
|
|
85
85
|
def fail_if_should_not_continue!
|
86
|
-
unless
|
86
|
+
unless config.forced?
|
87
87
|
if Git.command_available? && Git.inside_of_repository? && !Git.clean?
|
88
88
|
fail 'The current Git repository is not clean. Aborting. ' \
|
89
89
|
'If you want to proceed forcibly, use -f/--force option.'
|
@@ -101,7 +101,7 @@ module Transpec
|
|
101
101
|
|
102
102
|
puts 'Copying the project for dynamic analysis...'
|
103
103
|
|
104
|
-
DynamicAnalyzer.new(rspec_command:
|
104
|
+
DynamicAnalyzer.new(rspec_command: config.rspec_command) do |analyzer|
|
105
105
|
puts "Running dynamic analysis with command #{analyzer.rspec_command.inspect}..."
|
106
106
|
runtime_data = analyzer.analyze(paths)
|
107
107
|
end
|