transpec 2.1.0 → 2.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +66 -63
- data/README.md.erb +35 -62
- data/lib/transpec/option_parser.rb +11 -3
- data/lib/transpec/syntax/its.rb +5 -1
- data/lib/transpec/syntax/rspec_configure.rb +32 -2
- data/lib/transpec/syntax/rspec_configure/config_modification.rb +19 -8
- data/lib/transpec/syntax/rspec_configure/framework.rb +1 -1
- data/lib/transpec/syntax/rspec_configure/mocks.rb +16 -1
- data/lib/transpec/version.rb +1 -1
- data/spec/acceptance/configuration_modification_spec.rb +14 -0
- data/spec/transpec/option_parser_spec.rb +22 -1
- data/spec/transpec/syntax/its_spec.rb +28 -0
- data/spec/transpec/syntax/rspec_configure_spec.rb +87 -4
- data/transpec.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d068540b9a2d9d54a04b4314bd3c5156c423ba4f
|
4
|
+
data.tar.gz: cbbb7e6061a8d5cf4ee52054e1e7bb1da4ea8a08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb03eeaa658581eb344bafff2a1bd0e38931bdd804b76be305fab9154efdb858306f8a5db2c7292210289ba5dfe74af02797a9d49896aab229c46af6ae2124a7
|
7
|
+
data.tar.gz: e7c2dfa4ba98e945c3d0d9363a1151d68eba25ea8c869191212b8dbc6cca7b04fd64b51af38c8b0f3855288b798f74c06719d234ab7a1723acdbed1421533802
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Development
|
4
4
|
|
5
|
+
## v2.2.0
|
6
|
+
|
7
|
+
* Add descriptive comments to auto-added configurations in `RSpec.configure`.
|
8
|
+
* Deprecate `--no-parentheses-matcher-arg` option in favor of `--no-parens-matcher-arg`.
|
9
|
+
* Remove consecutive white spaces between `its` and the block.
|
10
|
+
|
5
11
|
## v2.1.0
|
6
12
|
|
7
13
|
* Disable invalid conversion of `expect(model).to have(n).errors_on(:attr)`. ([#62](https://github.com/yujinakayama/transpec/issues/62))
|
data/README.md
CHANGED
@@ -8,17 +8,20 @@
|
|
8
8
|
|
9
9
|
**Transpec** is a tool for converting your specs to the latest [RSpec](http://rspec.info/) syntax with static and dynamic code analysis.
|
10
10
|
|
11
|
-
|
11
|
+
With Transpec you can upgrade your RSpec 2 specs to RSpec 3 in no time.
|
12
|
+
It supports [conversions](#supported-conversions) for almost all of the RSpec 3 changes – not only the `expect` syntax.
|
13
|
+
Also, you can use it on your RSpec 2 project even if you're not going to upgrade it to RSpec 3 for now.
|
12
14
|
|
13
|
-
|
15
|
+
Check out the following pages for the new RSpec syntax and the changes in RSpec 3:
|
14
16
|
|
15
17
|
* [Myron Marston » RSpec's New Expectation Syntax](http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax)
|
16
18
|
* [RSpec's new message expectation syntax - Tea is awesome.](http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/)
|
17
|
-
* [Myron Marston »
|
19
|
+
* [Myron Marston » Notable Changes in RSpec 3](http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3)
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
If you are going to use Transpec in the upgrade process to RSpec 3,
|
22
|
+
read the RSpec official guide:
|
23
|
+
|
24
|
+
* https://relishapp.com/rspec/docs/upgrade
|
22
25
|
|
23
26
|
## Examples
|
24
27
|
|
@@ -193,13 +196,6 @@ $ transpec --keep its --convert example_group
|
|
193
196
|
|
194
197
|
See [`-k/--keep`](#-k--keep) and [`-v/--convert`](#-v--convert) for more details.
|
195
198
|
|
196
|
-
## Upgrade Process to RSpec 3 beta
|
197
|
-
|
198
|
-
If you are going to use Transpec in the upgrade process to RSpec 3 beta,
|
199
|
-
read this article by [Myron Marston](https://github.com/myronmarston), who is the lead maintainer of RSpec:
|
200
|
-
|
201
|
-
* [Myron Marston » RSpec 2.99 and 3.0 betas have been released!](http://myronmars.to/n/dev-blog/2013/11/rspec-2-99-and-3-0-betas-have-been-released)
|
202
|
-
|
203
199
|
## Options
|
204
200
|
|
205
201
|
Though Transpec ships with sensible defaults that essentially conform to the RSpec 3 defaults,
|
@@ -329,7 +325,7 @@ Note that this is not same as `--keep deprecated` since this configures `yield_r
|
|
329
325
|
|
330
326
|
See [Supported Conversions - `any_instance` implementation blocks](#any_instance-implementation-blocks) for more details.
|
331
327
|
|
332
|
-
### `-p/--no-
|
328
|
+
### `-p/--no-parens-matcher-arg`
|
333
329
|
|
334
330
|
Suppress parenthesizing arguments of matchers when converting
|
335
331
|
`should` with operator matcher to `expect` with non-operator matcher
|
@@ -358,7 +354,7 @@ describe 'converted spec' do
|
|
358
354
|
end
|
359
355
|
end
|
360
356
|
|
361
|
-
describe 'converted spec with -p/--no-
|
357
|
+
describe 'converted spec with -p/--no-parens-matcher-arg option' do
|
362
358
|
it 'is an example' do
|
363
359
|
expect(1).to eq 1
|
364
360
|
expect(2).to be > 1
|
@@ -483,7 +479,7 @@ The one-liner (implicit receiver) `should`:
|
|
483
479
|
* [Current example object](#current-example-object)
|
484
480
|
* [Custom matcher DSL](#custom-matcher-dsl)
|
485
481
|
* [Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails)
|
486
|
-
* [
|
482
|
+
* [Monkey-patched example groups](#monkey-patched-example-groups)
|
487
483
|
* [Hook scope aliases](#hook-scope-aliases)
|
488
484
|
|
489
485
|
### Standard expectations
|
@@ -509,7 +505,7 @@ expect(obj).to_not matcher # with `--negative-form to_not`
|
|
509
505
|
|
510
506
|
### One-liner expectations
|
511
507
|
|
512
|
-
|
508
|
+
This conversion is available only if your project's RSpec is **2.99.0.beta2 or later**.
|
513
509
|
|
514
510
|
Targets:
|
515
511
|
|
@@ -566,7 +562,7 @@ This conversion is combined with the conversion of [standard expectations](#stan
|
|
566
562
|
|
567
563
|
### Boolean matchers
|
568
564
|
|
569
|
-
|
565
|
+
This conversion is available only if your project's RSpec is **2.99.0.beta1 or later**.
|
570
566
|
|
571
567
|
Targets:
|
572
568
|
|
@@ -622,7 +618,7 @@ expect(1.0 / 3.0).to be_within(0.001).of(0.333)
|
|
622
618
|
|
623
619
|
### `have(n).items` matcher
|
624
620
|
|
625
|
-
|
621
|
+
This conversion will be **disabled automatically if `rspec-collection_matchers` is loaded** in your spec.
|
626
622
|
|
627
623
|
Targets:
|
628
624
|
|
@@ -696,7 +692,7 @@ So using rspec-collection_matchers gem is recommended for now.
|
|
696
692
|
|
697
693
|
### One-liner expectations with `have(n).items` matcher
|
698
694
|
|
699
|
-
|
695
|
+
This conversion will be **disabled automatically if `rspec-collection_matchers` is loaded** in your spec.
|
700
696
|
|
701
697
|
Targets:
|
702
698
|
|
@@ -746,7 +742,7 @@ expect { do_something }.to raise_error
|
|
746
742
|
|
747
743
|
### Expectations on attribute of subject with `its`
|
748
744
|
|
749
|
-
|
745
|
+
This conversion will be **disabled automatically if `rspec-its` is loaded** in your spec.
|
750
746
|
|
751
747
|
Targets:
|
752
748
|
|
@@ -791,7 +787,9 @@ If you choose to do so, disable this conversion by either:
|
|
791
787
|
* Specify `--keep its` option manually.
|
792
788
|
* Require `rspec-its` in your spec so that Transpec automatically disables this conversion.
|
793
789
|
|
794
|
-
|
790
|
+
Note that this conversion is a sort of first-aid
|
791
|
+
and ideally the expectations should be rewritten to be more expressive by yourself.
|
792
|
+
Read [this post](https://gist.github.com/myronmarston/4503509) for the rationale.
|
795
793
|
|
796
794
|
* This conversion can be disabled by: `--keep its`
|
797
795
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
@@ -1008,7 +1006,7 @@ allow(obj).to receive(:message)
|
|
1008
1006
|
|
1009
1007
|
### `any_instance` implementation blocks
|
1010
1008
|
|
1011
|
-
|
1009
|
+
This conversion is available only if your project's RSpec is **`>= 2.99.0.beta1` and `< 3.0.0.beta1`**.
|
1012
1010
|
|
1013
1011
|
Targets:
|
1014
1012
|
|
@@ -1029,6 +1027,13 @@ Will be converted to:
|
|
1029
1027
|
```ruby
|
1030
1028
|
RSpec.configure do |rspec|
|
1031
1029
|
rspec.mock_with :rspec do |mocks|
|
1030
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
1031
|
+
# instance as the first block argument to allow the implementation block to use
|
1032
|
+
# the state of the receiver.
|
1033
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
1034
|
+
# this config option to `false` OR set this to `true` and update your
|
1035
|
+
# `any_instance` implementation blocks to account for the first block argument
|
1036
|
+
# being the receiving instance.
|
1032
1037
|
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
1033
1038
|
end
|
1034
1039
|
end
|
@@ -1039,10 +1044,20 @@ describe 'example' do
|
|
1039
1044
|
allow_any_instance_of(Klass).to receive(:message) { |instance, arg| puts arg }
|
1040
1045
|
end
|
1041
1046
|
end
|
1047
|
+
```
|
1048
|
+
|
1049
|
+
Or with `--no-yield-any-instance` option they will be converted to:
|
1042
1050
|
|
1043
|
-
|
1051
|
+
```
|
1044
1052
|
RSpec.configure do |rspec|
|
1045
1053
|
rspec.mock_with :rspec do |mocks|
|
1054
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
1055
|
+
# instance as the first block argument to allow the implementation block to use
|
1056
|
+
# the state of the receiver.
|
1057
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
1058
|
+
# this config option to `false` OR set this to `true` and update your
|
1059
|
+
# `any_instance` implementation blocks to account for the first block argument
|
1060
|
+
# being the receiving instance.
|
1046
1061
|
mocks.yield_receiver_to_any_instance_implementation_blocks = false
|
1047
1062
|
end
|
1048
1063
|
end
|
@@ -1055,25 +1070,6 @@ describe 'example' do
|
|
1055
1070
|
end
|
1056
1071
|
```
|
1057
1072
|
|
1058
|
-
Here's an excerpt from [the warning](https://github.com/rspec/rspec-mocks/blob/aab8dc9/lib/rspec/mocks/message_expectation.rb#L478-L491) for `any_instance` implementation blocks in RSpec 2.99:
|
1059
|
-
|
1060
|
-
> In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
1061
|
-
> instance as the first block argument to allow the implementation block to use
|
1062
|
-
> the state of the receiver. To maintain compatibility with RSpec 3 you need to
|
1063
|
-
> either set rspec-mocks' `yield_receiver_to_any_instance_implementation_blocks`
|
1064
|
-
> config option to `false` OR set it to `true` and update your `any_instance`
|
1065
|
-
> implementation blocks to account for the first block argument being the receiving instance.
|
1066
|
-
>
|
1067
|
-
> To set the config option, use a snippet like:
|
1068
|
-
>
|
1069
|
-
> ```ruby
|
1070
|
-
> RSpec.configure do |rspec|
|
1071
|
-
> rspec.mock_with :rspec do |mocks|
|
1072
|
-
> mocks.yield_receiver_to_any_instance_implementation_blocks = false
|
1073
|
-
> end
|
1074
|
-
> end
|
1075
|
-
> ```
|
1076
|
-
|
1077
1073
|
* This conversion can be disabled by: `--keep deprecated`
|
1078
1074
|
* Deprecation: deprecated since RSpec 2.99
|
1079
1075
|
* See also: [Mocks: `any_instance` block implementations will yield the receiver](http://myronmars.to/n/dev-blog/2013/07/the-plan-for-rspec-3#mocks__block_implementations_will_yield_the_receiver)
|
@@ -1099,7 +1095,7 @@ double('something')
|
|
1099
1095
|
|
1100
1096
|
### Pending examples
|
1101
1097
|
|
1102
|
-
|
1098
|
+
This conversion is available only if your project's RSpec is **`>= 2.99.0.beta1` and `< 3.0.0.beta1`**.
|
1103
1099
|
|
1104
1100
|
Targets:
|
1105
1101
|
|
@@ -1168,7 +1164,7 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/v2
|
|
1168
1164
|
|
1169
1165
|
### Current example object
|
1170
1166
|
|
1171
|
-
|
1167
|
+
This conversion is available only if your project's RSpec is **2.99.0.beta1 or later**.
|
1172
1168
|
|
1173
1169
|
Targets:
|
1174
1170
|
|
@@ -1226,7 +1222,7 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/7d
|
|
1226
1222
|
|
1227
1223
|
### Custom matcher DSL
|
1228
1224
|
|
1229
|
-
|
1225
|
+
This conversion is available only if your project's RSpec is **3.0.0.beta2 or later**.
|
1230
1226
|
|
1231
1227
|
Targets:
|
1232
1228
|
|
@@ -1256,7 +1252,7 @@ end
|
|
1256
1252
|
|
1257
1253
|
### Implicit spec types in rspec-rails
|
1258
1254
|
|
1259
|
-
|
1255
|
+
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**.
|
1260
1256
|
|
1261
1257
|
Targets:
|
1262
1258
|
|
@@ -1277,9 +1273,21 @@ end
|
|
1277
1273
|
|
1278
1274
|
describe SomeModel, :type => :model do
|
1279
1275
|
end
|
1276
|
+
```
|
1280
1277
|
|
1281
|
-
|
1278
|
+
Or with `--no-explicit-spec-type` option they will be converted to:
|
1279
|
+
|
1280
|
+
```
|
1282
1281
|
RSpec.configure do |rspec|
|
1282
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
1283
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
1284
|
+
# config option.
|
1285
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
1286
|
+
# metadata manually:
|
1287
|
+
#
|
1288
|
+
# describe ThingsController, :type => :controller do
|
1289
|
+
# # Equivalent to being in spec/controllers
|
1290
|
+
# end
|
1283
1291
|
rspec.infer_spec_type_from_file_location!
|
1284
1292
|
end
|
1285
1293
|
|
@@ -1287,25 +1295,13 @@ describe SomeModel do
|
|
1287
1295
|
end
|
1288
1296
|
```
|
1289
1297
|
|
1290
|
-
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:
|
1291
|
-
|
1292
|
-
> 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:
|
1293
|
-
>
|
1294
|
-
> ```ruby
|
1295
|
-
> RSpec.configure do |config|
|
1296
|
-
> config.infer_spec_type_from_file_location!
|
1297
|
-
> end
|
1298
|
-
> ```
|
1299
|
-
>
|
1300
|
-
> 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.
|
1301
|
-
|
1302
1298
|
* This conversion can be disabled by: `--keep deprecated`
|
1303
1299
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1304
1300
|
* See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
|
1305
1301
|
|
1306
|
-
###
|
1302
|
+
### Monkey-patched example groups
|
1307
1303
|
|
1308
|
-
|
1304
|
+
This conversion is **disabled by default** and available only if your project's RSpec is **3.0.0.beta2 or later**.
|
1309
1305
|
|
1310
1306
|
Targets:
|
1311
1307
|
|
@@ -1326,6 +1322,13 @@ Will be converted to:
|
|
1326
1322
|
|
1327
1323
|
```ruby
|
1328
1324
|
RSpec.configure do |rspec|
|
1325
|
+
# Setting this config option `false` removes rspec-core's monkey patching of the
|
1326
|
+
# top level methods like `describe`, `shared_examples_for` and `shared_context`
|
1327
|
+
# on `main` and `Module`. The methods are always available through the `RSpec`
|
1328
|
+
# module like `RSpec.describe` regardless of this setting.
|
1329
|
+
# For backwards compatibility this defaults to `true`.
|
1330
|
+
#
|
1331
|
+
# https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
1329
1332
|
rspec.expose_dsl_globally = false
|
1330
1333
|
end
|
1331
1334
|
|
@@ -1344,7 +1347,7 @@ end
|
|
1344
1347
|
|
1345
1348
|
### Hook scope aliases
|
1346
1349
|
|
1347
|
-
|
1350
|
+
This conversion is **disabled by default** and available only if your project's RSpec is **3.0.0.beta2 or later**.
|
1348
1351
|
|
1349
1352
|
Targets:
|
1350
1353
|
|
data/README.md.erb
CHANGED
@@ -8,17 +8,20 @@
|
|
8
8
|
|
9
9
|
**Transpec** is a tool for converting your specs to the latest [RSpec](http://rspec.info/) syntax with static and dynamic code analysis.
|
10
10
|
|
11
|
-
|
11
|
+
With Transpec you can upgrade your RSpec 2 specs to RSpec 3 in no time.
|
12
|
+
It supports [conversions](#supported-conversions) for almost all of the RSpec 3 changes – not only the `expect` syntax.
|
13
|
+
Also, you can use it on your RSpec 2 project even if you're not going to upgrade it to RSpec 3 for now.
|
12
14
|
|
13
|
-
|
15
|
+
Check out the following pages for the new RSpec syntax and the changes in RSpec 3:
|
14
16
|
|
15
17
|
* [Myron Marston » RSpec's New Expectation Syntax](http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax)
|
16
18
|
* [RSpec's new message expectation syntax - Tea is awesome.](http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/)
|
17
|
-
* [Myron Marston »
|
19
|
+
* [Myron Marston » Notable Changes in RSpec 3](http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3)
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
If you are going to use Transpec in the upgrade process to RSpec 3,
|
22
|
+
read the RSpec official guide:
|
23
|
+
|
24
|
+
* https://relishapp.com/rspec/docs/upgrade
|
22
25
|
|
23
26
|
## Examples
|
24
27
|
|
@@ -167,13 +170,6 @@ $ transpec --keep its --convert example_group
|
|
167
170
|
|
168
171
|
See [`-k/--keep`](#-k--keep) and [`-v/--convert`](#-v--convert) for more details.
|
169
172
|
|
170
|
-
## Upgrade Process to RSpec 3 beta
|
171
|
-
|
172
|
-
If you are going to use Transpec in the upgrade process to RSpec 3 beta,
|
173
|
-
read this article by [Myron Marston](https://github.com/myronmarston), who is the lead maintainer of RSpec:
|
174
|
-
|
175
|
-
* [Myron Marston » RSpec 2.99 and 3.0 betas have been released!](http://myronmars.to/n/dev-blog/2013/11/rspec-2-99-and-3-0-betas-have-been-released)
|
176
|
-
|
177
173
|
## Options
|
178
174
|
|
179
175
|
Though Transpec ships with sensible defaults that essentially conform to the RSpec 3 defaults,
|
@@ -317,7 +313,7 @@ Note that this is not same as `--keep deprecated` since this configures `yield_r
|
|
317
313
|
|
318
314
|
See [Supported Conversions - `any_instance` implementation blocks](#any_instance-implementation-blocks) for more details.
|
319
315
|
|
320
|
-
### `-p/--no-
|
316
|
+
### `-p/--no-parens-matcher-arg`
|
321
317
|
|
322
318
|
Suppress parenthesizing arguments of matchers when converting
|
323
319
|
`should` with operator matcher to `expect` with non-operator matcher
|
@@ -346,7 +342,7 @@ END
|
|
346
342
|
convert(example, cli: ['-p'])
|
347
343
|
.gsub(
|
348
344
|
'original spec',
|
349
|
-
'converted spec with -p/--no-
|
345
|
+
'converted spec with -p/--no-parens-matcher-arg option'
|
350
346
|
)
|
351
347
|
.gsub(/^.+\{ key: value \}/) do |match|
|
352
348
|
" # With non-operator method, the parentheses are always required\n" +
|
@@ -481,7 +477,7 @@ Will be converted to:
|
|
481
477
|
|
482
478
|
### One-liner expectations
|
483
479
|
|
484
|
-
|
480
|
+
This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.oneliner_is_expected_available_version %> or later**.
|
485
481
|
|
486
482
|
Targets:
|
487
483
|
|
@@ -546,7 +542,7 @@ This conversion is combined with the conversion of [standard expectations](#stan
|
|
546
542
|
|
547
543
|
### Boolean matchers
|
548
544
|
|
549
|
-
|
545
|
+
This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.be_truthy_available_version %> or later**.
|
550
546
|
|
551
547
|
Targets:
|
552
548
|
|
@@ -607,7 +603,7 @@ Will be converted to:
|
|
607
603
|
|
608
604
|
### `have(n).items` matcher
|
609
605
|
|
610
|
-
|
606
|
+
This conversion will be **disabled automatically if `rspec-collection_matchers` is loaded** in your spec.
|
611
607
|
|
612
608
|
Targets:
|
613
609
|
|
@@ -751,7 +747,7 @@ So using rspec-collection_matchers gem is recommended for now.
|
|
751
747
|
|
752
748
|
### One-liner expectations with `have(n).items` matcher
|
753
749
|
|
754
|
-
|
750
|
+
This conversion will be **disabled automatically if `rspec-collection_matchers` is loaded** in your spec.
|
755
751
|
|
756
752
|
Targets:
|
757
753
|
|
@@ -819,7 +815,7 @@ Will be converted to:
|
|
819
815
|
|
820
816
|
### Expectations on attribute of subject with `its`
|
821
817
|
|
822
|
-
|
818
|
+
This conversion will be **disabled automatically if `rspec-its` is loaded** in your spec.
|
823
819
|
|
824
820
|
Targets:
|
825
821
|
|
@@ -848,7 +844,9 @@ If you choose to do so, disable this conversion by either:
|
|
848
844
|
* Specify `--keep its` option manually.
|
849
845
|
* Require `rspec-its` in your spec so that Transpec automatically disables this conversion.
|
850
846
|
|
851
|
-
|
847
|
+
Note that this conversion is a sort of first-aid
|
848
|
+
and ideally the expectations should be rewritten to be more expressive by yourself.
|
849
|
+
Read [this post](https://gist.github.com/myronmarston/4503509) for the rationale.
|
852
850
|
|
853
851
|
* This conversion can be disabled by: `--keep its`
|
854
852
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
@@ -1110,7 +1108,7 @@ Will be converted to:
|
|
1110
1108
|
|
1111
1109
|
### `any_instance` implementation blocks
|
1112
1110
|
|
1113
|
-
|
1111
|
+
This conversion is available only if your project's RSpec is **`>= <%= Transpec::RSpecVersion::RSPEC_2_99 %>` and `< <%= Transpec::RSpecVersion::RSPEC_3_0 %>`**.
|
1114
1112
|
|
1115
1113
|
Targets:
|
1116
1114
|
|
@@ -1135,29 +1133,13 @@ Will be converted to:
|
|
1135
1133
|
```ruby
|
1136
1134
|
<% rspec_version = Transpec::RSpecVersion.yielding_receiver_to_any_instance_implementation_block_available_version -%>
|
1137
1135
|
<%= convert(example, rspec_version: rspec_version) -%>
|
1138
|
-
|
1139
|
-
# With `--no-yield-any-instance`
|
1140
|
-
<%= convert(example, cli: ['--no-yield-any-instance'], rspec_version: rspec_version) -%>
|
1141
1136
|
```
|
1142
1137
|
|
1143
|
-
|
1138
|
+
Or with `--no-yield-any-instance` option they will be converted to:
|
1144
1139
|
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
> either set rspec-mocks' `yield_receiver_to_any_instance_implementation_blocks`
|
1149
|
-
> config option to `false` OR set it to `true` and update your `any_instance`
|
1150
|
-
> implementation blocks to account for the first block argument being the receiving instance.
|
1151
|
-
>
|
1152
|
-
> To set the config option, use a snippet like:
|
1153
|
-
>
|
1154
|
-
> ```ruby
|
1155
|
-
> RSpec.configure do |rspec|
|
1156
|
-
> rspec.mock_with :rspec do |mocks|
|
1157
|
-
> mocks.yield_receiver_to_any_instance_implementation_blocks = false
|
1158
|
-
> end
|
1159
|
-
> end
|
1160
|
-
> ```
|
1140
|
+
```
|
1141
|
+
<%= convert(example, cli: ['--no-yield-any-instance'], rspec_version: rspec_version) -%>
|
1142
|
+
```
|
1161
1143
|
|
1162
1144
|
* This conversion can be disabled by: `--keep deprecated`
|
1163
1145
|
* Deprecation: deprecated since RSpec 2.99
|
@@ -1188,7 +1170,7 @@ Will be converted to:
|
|
1188
1170
|
|
1189
1171
|
### Pending examples
|
1190
1172
|
|
1191
|
-
|
1173
|
+
This conversion is available only if your project's RSpec is **`>= <%= Transpec::RSpecVersion::RSPEC_2_99 %>` and `< <%= Transpec::RSpecVersion::RSPEC_3_0 %>`**.
|
1192
1174
|
|
1193
1175
|
Targets:
|
1194
1176
|
|
@@ -1246,7 +1228,7 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/v2
|
|
1246
1228
|
|
1247
1229
|
### Current example object
|
1248
1230
|
|
1249
|
-
|
1231
|
+
This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.yielded_example_available_version %> or later**.
|
1250
1232
|
|
1251
1233
|
Targets:
|
1252
1234
|
|
@@ -1296,7 +1278,7 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/7d
|
|
1296
1278
|
|
1297
1279
|
### Custom matcher DSL
|
1298
1280
|
|
1299
|
-
|
1281
|
+
This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.non_should_matcher_protocol_available_version %> or later**.
|
1300
1282
|
|
1301
1283
|
Targets:
|
1302
1284
|
|
@@ -1325,7 +1307,7 @@ Will be converted to:
|
|
1325
1307
|
|
1326
1308
|
### Implicit spec types in rspec-rails
|
1327
1309
|
|
1328
|
-
|
1310
|
+
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**.
|
1329
1311
|
|
1330
1312
|
Targets:
|
1331
1313
|
|
@@ -1346,30 +1328,21 @@ Will be converted to:
|
|
1346
1328
|
|
1347
1329
|
```ruby
|
1348
1330
|
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb') -%>
|
1349
|
-
|
1350
|
-
# With `--no-explicit-spec-type`
|
1351
|
-
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb', cli: ['--no-explicit-spec-type']) -%>
|
1352
1331
|
```
|
1353
1332
|
|
1354
|
-
|
1333
|
+
Or with `--no-explicit-spec-type` option they will be converted to:
|
1355
1334
|
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
> RSpec.configure do |config|
|
1360
|
-
> config.infer_spec_type_from_file_location!
|
1361
|
-
> end
|
1362
|
-
> ```
|
1363
|
-
>
|
1364
|
-
> 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.
|
1335
|
+
```
|
1336
|
+
<%= convert(example, rspec_version: rspec_version, path: 'spec/models/some_model_spec.rb', cli: ['--no-explicit-spec-type']) -%>
|
1337
|
+
```
|
1365
1338
|
|
1366
1339
|
* This conversion can be disabled by: `--keep deprecated`
|
1367
1340
|
* Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
|
1368
1341
|
* See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
|
1369
1342
|
|
1370
|
-
###
|
1343
|
+
### Monkey-patched example groups
|
1371
1344
|
|
1372
|
-
|
1345
|
+
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**.
|
1373
1346
|
|
1374
1347
|
Targets:
|
1375
1348
|
|
@@ -1402,7 +1375,7 @@ Will be converted to:
|
|
1402
1375
|
|
1403
1376
|
### Hook scope aliases
|
1404
1377
|
|
1405
|
-
|
1378
|
+
This conversion is **disabled by default** and available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.hook_scope_alias_available_version %> or later**.
|
1406
1379
|
|
1407
1380
|
Targets:
|
1408
1381
|
|
@@ -95,7 +95,7 @@ module Transpec
|
|
95
95
|
config.add_explicit_type_metadata_to_example_group = false
|
96
96
|
end
|
97
97
|
|
98
|
-
define_option('-p', '--no-
|
98
|
+
define_option('-p', '--no-parens-matcher-arg') do
|
99
99
|
config.parenthesize_matcher_arg = false
|
100
100
|
end
|
101
101
|
|
@@ -207,12 +207,20 @@ module Transpec
|
|
207
207
|
end
|
208
208
|
|
209
209
|
def convert_deprecated_options(raw_args)
|
210
|
-
raw_args.
|
210
|
+
raw_args.each_with_object([]) do |arg, args|
|
211
|
+
case arg
|
212
|
+
when '--no-parentheses-matcher-arg'
|
213
|
+
deprecate('--no-parentheses-matcher-arg option', '--no-parens-matcher-arg')
|
214
|
+
args << '--no-parens-matcher-arg'
|
215
|
+
else
|
216
|
+
args << arg
|
217
|
+
end
|
218
|
+
end
|
211
219
|
end
|
212
220
|
|
213
221
|
def deprecate(subject, alternative = nil)
|
214
222
|
message = "DEPRECATION: #{subject} is deprecated."
|
215
|
-
message << "
|
223
|
+
message << " Use #{alternative} instead." if alternative
|
216
224
|
warn message
|
217
225
|
end
|
218
226
|
|
data/lib/transpec/syntax/its.rb
CHANGED
@@ -27,7 +27,7 @@ module Transpec
|
|
27
27
|
front, rear = build_wrapper_codes
|
28
28
|
|
29
29
|
insert_before(beginning_of_line_range(block_node), front)
|
30
|
-
replace(
|
30
|
+
replace(range_from_its_to_front_of_block, 'it ')
|
31
31
|
insert_after(block_node.loc.expression, rear)
|
32
32
|
|
33
33
|
register_record
|
@@ -89,6 +89,10 @@ module Transpec
|
|
89
89
|
@base_indentation ||= indentation_of_line(node)
|
90
90
|
end
|
91
91
|
|
92
|
+
def range_from_its_to_front_of_block
|
93
|
+
expression_range.join(block_node.loc.begin.begin)
|
94
|
+
end
|
95
|
+
|
92
96
|
def register_record
|
93
97
|
report.records << Record.new(original_syntax, converted_syntax)
|
94
98
|
end
|
@@ -26,13 +26,43 @@ module Transpec
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def expose_dsl_globally=(boolean)
|
29
|
-
|
29
|
+
comment = <<-END.gsub(/^\s+\|/, '').chomp
|
30
|
+
|Setting this config option `false` removes rspec-core's monkey patching of the
|
31
|
+
|top level methods like `describe`, `shared_examples_for` and `shared_context`
|
32
|
+
|on `main` and `Module`. The methods are always available through the `RSpec`
|
33
|
+
|module like `RSpec.describe` regardless of this setting.
|
34
|
+
|For backwards compatibility this defaults to `true`.
|
35
|
+
|
|
36
|
+
|https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
37
|
+
END
|
38
|
+
set_config!(:expose_dsl_globally, boolean, comment)
|
30
39
|
end
|
31
40
|
|
32
41
|
def infer_spec_type_from_file_location!
|
33
42
|
return if infer_spec_type_from_file_location?
|
34
43
|
return unless rspec_rails?
|
35
|
-
|
44
|
+
|
45
|
+
# rubocop:disable LineLength
|
46
|
+
#
|
47
|
+
# Based on the deprecation warning in RSpec 2.99:
|
48
|
+
# https://github.com/rspec/rspec-rails/blob/ab6313b/lib/rspec/rails/infer_type_configuration.rb#L13-L22
|
49
|
+
# and the Myron's post:
|
50
|
+
# http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#filetype_inference_disabled_by_default
|
51
|
+
#
|
52
|
+
# rubocop:enable LineLength
|
53
|
+
comment = <<-END.gsub(/^\s+\|/, '').chomp
|
54
|
+
|rspec-rails 3 will no longer automatically infer an example group's spec type
|
55
|
+
|from the file location. You can explicitly opt-in to the feature using this
|
56
|
+
|config option.
|
57
|
+
|To explicitly tag specs without using automatic inference, set the `:type`
|
58
|
+
|metadata manually:
|
59
|
+
|
|
60
|
+
| describe ThingsController, :type => :controller do
|
61
|
+
| # Equivalent to being in spec/controllers
|
62
|
+
| end
|
63
|
+
END
|
64
|
+
|
65
|
+
add_config!(:infer_spec_type_from_file_location!, nil, comment)
|
36
66
|
end
|
37
67
|
|
38
68
|
def infer_spec_type_from_file_location?
|
@@ -15,14 +15,14 @@ module Transpec
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def set_config!(config_name, value)
|
18
|
+
def set_config!(config_name, value, comment = nil)
|
19
19
|
setter_node = find_config_node("#{config_name}=")
|
20
20
|
|
21
21
|
if setter_node
|
22
22
|
arg_node = setter_node.children[2]
|
23
23
|
source_rewriter.replace(arg_node.loc.expression, value.to_s)
|
24
24
|
else
|
25
|
-
add_config!(config_name, value)
|
25
|
+
add_config!(config_name, value, comment)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -46,8 +46,8 @@ module Transpec
|
|
46
46
|
|
47
47
|
# TODO: Refactor this to remove messy overrides in Framework.
|
48
48
|
module ConfigAddition
|
49
|
-
def add_config!(config_name, value = nil)
|
50
|
-
lines = generate_config_lines(config_name, value)
|
49
|
+
def add_config!(config_name, value = nil, comment = nil)
|
50
|
+
lines = generate_config_lines(config_name, value, comment)
|
51
51
|
lines.unshift('') unless empty_block_body?
|
52
52
|
lines.map! { |line| line + "\n" }
|
53
53
|
|
@@ -57,10 +57,21 @@ module Transpec
|
|
57
57
|
block_node_to_insert_code.metadata[:added_config] = true
|
58
58
|
end
|
59
59
|
|
60
|
-
def generate_config_lines(config_name, value = nil)
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
def generate_config_lines(config_name, value = nil, comment = nil)
|
61
|
+
lines = []
|
62
|
+
|
63
|
+
if comment
|
64
|
+
comment_lines = comment.each_line.map do |line|
|
65
|
+
"#{body_indentation}# #{line.chomp}".rstrip
|
66
|
+
end
|
67
|
+
lines.concat(comment_lines)
|
68
|
+
end
|
69
|
+
|
70
|
+
config_line = body_indentation + "#{config_variable_name}.#{config_name}"
|
71
|
+
config_line << " = #{value}" unless value.nil?
|
72
|
+
lines << config_line
|
73
|
+
|
74
|
+
lines
|
64
75
|
end
|
65
76
|
|
66
77
|
def config_variable_name
|
@@ -11,7 +11,22 @@ module Transpec
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def yield_receiver_to_any_instance_implementation_blocks=(boolean)
|
14
|
-
|
14
|
+
# rubocop:disable LineLength
|
15
|
+
#
|
16
|
+
# Based on the deprecation warning in RSpec 2.99:
|
17
|
+
# https://github.com/rspec/rspec-mocks/blob/aab8dc9/lib/rspec/mocks/message_expectation.rb#L478-L491
|
18
|
+
#
|
19
|
+
# rubocop:enable LineLength
|
20
|
+
comment = <<-END.gsub(/^\s+\|/, '').chomp
|
21
|
+
|In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
22
|
+
|instance as the first block argument to allow the implementation block to use
|
23
|
+
|the state of the receiver.
|
24
|
+
|In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
25
|
+
|this config option to `false` OR set this to `true` and update your
|
26
|
+
|`any_instance` implementation blocks to account for the first block argument
|
27
|
+
|being the receiving instance.
|
28
|
+
END
|
29
|
+
set_config!(:yield_receiver_to_any_instance_implementation_blocks, boolean, comment)
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
data/lib/transpec/version.rb
CHANGED
@@ -48,6 +48,13 @@ module Transpec
|
|
48
48
|
File.read('spec/spec_helper.rb').should == <<-END
|
49
49
|
RSpec.configure do |config|
|
50
50
|
config.mock_with :rspec do |mocks|
|
51
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
52
|
+
# instance as the first block argument to allow the implementation block to use
|
53
|
+
# the state of the receiver.
|
54
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
55
|
+
# this config option to `false` OR set this to `true` and update your
|
56
|
+
# `any_instance` implementation blocks to account for the first block argument
|
57
|
+
# being the receiving instance.
|
51
58
|
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
52
59
|
end
|
53
60
|
end
|
@@ -97,6 +104,13 @@ module Transpec
|
|
97
104
|
File.read(spec_helper_path).should == <<-END
|
98
105
|
RSpec.configure do |config|
|
99
106
|
config.mock_with :rspec do |mocks|
|
107
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
108
|
+
# instance as the first block argument to allow the implementation block to use
|
109
|
+
# the state of the receiver.
|
110
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
111
|
+
# this config option to `false` OR set this to `true` and update your
|
112
|
+
# `any_instance` implementation blocks to account for the first block argument
|
113
|
+
# being the receiving instance.
|
100
114
|
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
101
115
|
end
|
102
116
|
end
|
@@ -172,13 +172,34 @@ module Transpec
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
describe '-p/--no-
|
175
|
+
describe '-p/--no-parens-matcher-arg option' do
|
176
|
+
let(:args) { ['--no-parens-matcher-arg'] }
|
177
|
+
|
178
|
+
it 'sets Config#parenthesize_matcher_arg? false' do
|
179
|
+
parser.parse(args)
|
180
|
+
config.parenthesize_matcher_arg.should be_false
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe '--no-parentheses-matcher-arg option' do
|
176
185
|
let(:args) { ['--no-parentheses-matcher-arg'] }
|
177
186
|
|
187
|
+
before do
|
188
|
+
parser.stub(:warn)
|
189
|
+
end
|
190
|
+
|
178
191
|
it 'sets Config#parenthesize_matcher_arg? false' do
|
179
192
|
parser.parse(args)
|
180
193
|
config.parenthesize_matcher_arg.should be_false
|
181
194
|
end
|
195
|
+
|
196
|
+
it 'is deprecated' do
|
197
|
+
parser.should_receive(:warn) do |message|
|
198
|
+
message.should =~ /--no-parentheses-matcher-arg.+deprecated/i
|
199
|
+
end
|
200
|
+
|
201
|
+
parser.parse(args)
|
202
|
+
end
|
182
203
|
end
|
183
204
|
|
184
205
|
describe '--no-color option' do
|
@@ -92,6 +92,34 @@ module Transpec
|
|
92
92
|
record.converted_syntax.should == "describe '#attr' do subject { super().attr }; it { } end"
|
93
93
|
end
|
94
94
|
|
95
|
+
context 'and there are consecutive blanks between the #its and the block' do
|
96
|
+
let(:source) do
|
97
|
+
<<-END
|
98
|
+
describe 'example' do
|
99
|
+
subject { ['foo'] }
|
100
|
+
its(:size) { should == 1 }
|
101
|
+
end
|
102
|
+
END
|
103
|
+
end
|
104
|
+
|
105
|
+
let(:expected_source) do
|
106
|
+
<<-END
|
107
|
+
describe 'example' do
|
108
|
+
subject { ['foo'] }
|
109
|
+
|
110
|
+
describe '#size' do
|
111
|
+
subject { super().size }
|
112
|
+
it { should == 1 }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
END
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'removes the redundant blanks' do
|
119
|
+
rewritten_source.should == expected_source
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
95
123
|
context 'and there is no blank line before #its' do
|
96
124
|
context 'and the indentation level of the previous line is same as the target line' do
|
97
125
|
let(:source) do
|
@@ -25,8 +25,24 @@ module Transpec
|
|
25
25
|
let(:expected_source) do
|
26
26
|
<<-END
|
27
27
|
RSpec.configure do |config|
|
28
|
+
# Setting this config option `false` removes rspec-core's monkey patching of the
|
29
|
+
# top level methods like `describe`, `shared_examples_for` and `shared_context`
|
30
|
+
# on `main` and `Module`. The methods are always available through the `RSpec`
|
31
|
+
# module like `RSpec.describe` regardless of this setting.
|
32
|
+
# For backwards compatibility this defaults to `true`.
|
33
|
+
#
|
34
|
+
# https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
28
35
|
config.expose_dsl_globally = true
|
29
36
|
|
37
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
38
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
39
|
+
# config option.
|
40
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
41
|
+
# metadata manually:
|
42
|
+
#
|
43
|
+
# describe ThingsController, :type => :controller do
|
44
|
+
# # Equivalent to being in spec/controllers
|
45
|
+
# end
|
30
46
|
config.infer_spec_type_from_file_location!
|
31
47
|
end
|
32
48
|
END
|
@@ -75,12 +91,19 @@ module Transpec
|
|
75
91
|
let(:expected_source) do
|
76
92
|
<<-END
|
77
93
|
RSpec.configure do |config|
|
94
|
+
# Setting this config option `false` removes rspec-core's monkey patching of the
|
95
|
+
# top level methods like `describe`, `shared_examples_for` and `shared_context`
|
96
|
+
# on `main` and `Module`. The methods are always available through the `RSpec`
|
97
|
+
# module like `RSpec.describe` regardless of this setting.
|
98
|
+
# For backwards compatibility this defaults to `true`.
|
99
|
+
#
|
100
|
+
# https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
78
101
|
config.expose_dsl_globally = true
|
79
102
|
end
|
80
103
|
END
|
81
104
|
end
|
82
105
|
|
83
|
-
it 'adds #expose_dsl_globally= statement' do
|
106
|
+
it 'adds #expose_dsl_globally= statement along with comment' do
|
84
107
|
rewritten_source.should == expected_source
|
85
108
|
end
|
86
109
|
end
|
@@ -99,6 +122,13 @@ module Transpec
|
|
99
122
|
RSpec.configure do |config|
|
100
123
|
config.foo = 1
|
101
124
|
|
125
|
+
# Setting this config option `false` removes rspec-core's monkey patching of the
|
126
|
+
# top level methods like `describe`, `shared_examples_for` and `shared_context`
|
127
|
+
# on `main` and `Module`. The methods are always available through the `RSpec`
|
128
|
+
# module like `RSpec.describe` regardless of this setting.
|
129
|
+
# For backwards compatibility this defaults to `true`.
|
130
|
+
#
|
131
|
+
# https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
102
132
|
config.expose_dsl_globally = true
|
103
133
|
end
|
104
134
|
END
|
@@ -126,12 +156,21 @@ module Transpec
|
|
126
156
|
let(:expected_source) do
|
127
157
|
<<-END
|
128
158
|
RSpec.configure do |config|
|
159
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
160
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
161
|
+
# config option.
|
162
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
163
|
+
# metadata manually:
|
164
|
+
#
|
165
|
+
# describe ThingsController, :type => :controller do
|
166
|
+
# # Equivalent to being in spec/controllers
|
167
|
+
# end
|
129
168
|
config.infer_spec_type_from_file_location!
|
130
169
|
end
|
131
170
|
END
|
132
171
|
end
|
133
172
|
|
134
|
-
it 'adds #infer_spec_type_from_file_location! statement' do
|
173
|
+
it 'adds #infer_spec_type_from_file_location! statement along with comment' do
|
135
174
|
rewritten_source.should == expected_source
|
136
175
|
end
|
137
176
|
end
|
@@ -174,6 +213,15 @@ module Transpec
|
|
174
213
|
end
|
175
214
|
|
176
215
|
RSpec.configure do |config|
|
216
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
217
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
218
|
+
# config option.
|
219
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
220
|
+
# metadata manually:
|
221
|
+
#
|
222
|
+
# describe ThingsController, :type => :controller do
|
223
|
+
# # Equivalent to being in spec/controllers
|
224
|
+
# end
|
177
225
|
config.infer_spec_type_from_file_location!
|
178
226
|
end
|
179
227
|
END
|
@@ -498,13 +546,20 @@ module Transpec
|
|
498
546
|
<<-END
|
499
547
|
RSpec.configure do |config|
|
500
548
|
config.mock_with :rspec do |c|
|
549
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
550
|
+
# instance as the first block argument to allow the implementation block to use
|
551
|
+
# the state of the receiver.
|
552
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
553
|
+
# this config option to `false` OR set this to `true` and update your
|
554
|
+
# `any_instance` implementation blocks to account for the first block argument
|
555
|
+
# being the receiving instance.
|
501
556
|
c.yield_receiver_to_any_instance_implementation_blocks = true
|
502
557
|
end
|
503
558
|
end
|
504
559
|
END
|
505
560
|
end
|
506
561
|
|
507
|
-
it 'adds #yield_receiver_to_any_instance_implementation_blocks= statement' do
|
562
|
+
it 'adds #yield_receiver_to_any_instance_implementation_blocks= statement along with comment' do
|
508
563
|
rewritten_source.should == expected_source
|
509
564
|
end
|
510
565
|
end
|
@@ -523,6 +578,13 @@ module Transpec
|
|
523
578
|
<<-END
|
524
579
|
RSpec.configure do |config|
|
525
580
|
config.mock_with :rspec do |mocks|
|
581
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
582
|
+
# instance as the first block argument to allow the implementation block to use
|
583
|
+
# the state of the receiver.
|
584
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
585
|
+
# this config option to `false` OR set this to `true` and update your
|
586
|
+
# `any_instance` implementation blocks to account for the first block argument
|
587
|
+
# being the receiving instance.
|
526
588
|
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
527
589
|
end
|
528
590
|
end
|
@@ -530,7 +592,7 @@ module Transpec
|
|
530
592
|
end
|
531
593
|
|
532
594
|
it 'adds #mock_with block ' \
|
533
|
-
'and #yield_receiver_to_any_instance_implementation_blocks= statement' do
|
595
|
+
'and #yield_receiver_to_any_instance_implementation_blocks= statement along with comment' do
|
534
596
|
rewritten_source.should == expected_source
|
535
597
|
end
|
536
598
|
|
@@ -546,6 +608,13 @@ module Transpec
|
|
546
608
|
<<-END
|
547
609
|
RSpec.configure do |mocks|
|
548
610
|
mocks.mock_with :rspec do |config|
|
611
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
612
|
+
# instance as the first block argument to allow the implementation block to use
|
613
|
+
# the state of the receiver.
|
614
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
615
|
+
# this config option to `false` OR set this to `true` and update your
|
616
|
+
# `any_instance` implementation blocks to account for the first block argument
|
617
|
+
# being the receiving instance.
|
549
618
|
config.yield_receiver_to_any_instance_implementation_blocks = true
|
550
619
|
end
|
551
620
|
end
|
@@ -576,9 +645,23 @@ module Transpec
|
|
576
645
|
let(:expected_source) do
|
577
646
|
<<-END
|
578
647
|
RSpec.configure do |config|
|
648
|
+
# Setting this config option `false` removes rspec-core's monkey patching of the
|
649
|
+
# top level methods like `describe`, `shared_examples_for` and `shared_context`
|
650
|
+
# on `main` and `Module`. The methods are always available through the `RSpec`
|
651
|
+
# module like `RSpec.describe` regardless of this setting.
|
652
|
+
# For backwards compatibility this defaults to `true`.
|
653
|
+
#
|
654
|
+
# https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
|
579
655
|
config.expose_dsl_globally = true
|
580
656
|
|
581
657
|
config.mock_with :rspec do |mocks|
|
658
|
+
# In RSpec 3, `any_instance` implementation blocks will be yielded the receiving
|
659
|
+
# instance as the first block argument to allow the implementation block to use
|
660
|
+
# the state of the receiver.
|
661
|
+
# In RSpec 2.99, to maintain compatibility with RSpec 3 you need to either set
|
662
|
+
# this config option to `false` OR set this to `true` and update your
|
663
|
+
# `any_instance` implementation blocks to account for the first block argument
|
664
|
+
# being the receiving instance.
|
582
665
|
mocks.yield_receiver_to_any_instance_implementation_blocks = false
|
583
666
|
end
|
584
667
|
end
|
data/transpec.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'activesupport', '>= 3.0', '< 5.0'
|
30
30
|
|
31
31
|
spec.add_development_dependency 'rake', '~> 10.1'
|
32
|
-
spec.add_development_dependency 'rspec', '~> 2.14'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
33
33
|
spec.add_development_dependency 'fuubar', '~> 1.3'
|
34
34
|
spec.add_development_dependency 'simplecov', '~> 0.7'
|
35
35
|
spec.add_development_dependency 'rubocop', '~> 0.19'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transpec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -118,14 +118,14 @@ dependencies:
|
|
118
118
|
requirements:
|
119
119
|
- - "~>"
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
121
|
+
version: 2.14.0
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
124
|
version_requirements: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
126
|
- - "~>"
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
128
|
+
version: 2.14.0
|
129
129
|
- !ruby/object:Gem::Dependency
|
130
130
|
name: fuubar
|
131
131
|
requirement: !ruby/object:Gem::Requirement
|