transpec 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cc32f4f45ab036ddecaefb46245014a4713fdee
4
- data.tar.gz: 2b7feec59ef424cb3df9d47145683fcc6c496b9e
3
+ metadata.gz: c90c3e229024fe5588256af42c0ac3fdc30f146a
4
+ data.tar.gz: 3d786286cac9c9298c9aaa073288ad2bb1e83a50
5
5
  SHA512:
6
- metadata.gz: b53e41a17861208c396e6955152123dca5a623041265987c8f03caf3f3bb14fb28ddaabcd1f46dad918a477ad499e155e801e042ab3b6464ccc46d0ebdb7f361
7
- data.tar.gz: 3b3cf2d94a9a6adfd671235d639ae65a2cf8c8887acccb28b6b4eee9c9dabd266a84d195f680b425410685f466a3e726f07610e9045750b6e3377427044d3002
6
+ metadata.gz: 28e8ac6dacd5834196381b9510bd3b4d8394f084eedfb584407a7a6234d68cd3fe6da89957a7b7be2f7481c0f3ab0aa43e25655554885bd3258a626faf59f793
7
+ data.tar.gz: ee3405cacf7e33bcfe378ebc55af52e9b69d4e2041bc78cdbb8e363706ae0b9011f65db64c6a8b94ea69a5291b0aa9e74c0827fb50254baa974a6d3d19d47c7f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v2.3.1
6
+
7
+ * Remove conversion support for non-existent configuration option `backtrace_cleaner=`.
8
+ * Add missing way to disable conversion of deprecated configuration options with `--keep deprecated`.
9
+
5
10
  ## v2.3.0
6
11
 
7
12
  * Report configuration modifications of `RSpec.configure` in the final summary.
data/README.md CHANGED
@@ -479,6 +479,7 @@ The one-liner (implicit receiver) `should`:
479
479
  * [Current example object](#current-example-object)
480
480
  * [Custom matcher DSL](#custom-matcher-dsl)
481
481
  * [Implicit spec types in rspec-rails](#implicit-spec-types-in-rspec-rails)
482
+ * [Deprecated configuration options](#deprecated-configuration-options)
482
483
  * [Monkey-patched example groups](#monkey-patched-example-groups)
483
484
  * [Hook scope aliases](#hook-scope-aliases)
484
485
 
@@ -1300,6 +1301,54 @@ end
1300
1301
  * Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
1301
1302
  * See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
1302
1303
 
1304
+ ### Deprecated configuration options
1305
+
1306
+ Targets:
1307
+
1308
+ ```ruby
1309
+ RSpec.configure do |c|
1310
+ c.backtrace_clean_patterns
1311
+ c.backtrace_clean_patterns = [/lib\/something/]
1312
+ c.color_enabled = true
1313
+
1314
+ c.out
1315
+ c.out = File.open('output.txt', 'w')
1316
+ c.output
1317
+ c.output = File.open('output.txt', 'w')
1318
+
1319
+ c.backtrace_cleaner
1320
+ c.color?(output)
1321
+ c.filename_pattern
1322
+ c.filename_pattern = '**/*_test.rb'
1323
+ c.warnings
1324
+ end
1325
+ ```
1326
+
1327
+ Will be converted to:
1328
+
1329
+ ```ruby
1330
+ RSpec.configure do |c|
1331
+ c.backtrace_exclusion_patterns
1332
+ c.backtrace_exclusion_patterns = [/lib\/something/]
1333
+ c.color = true
1334
+
1335
+ # RSpec 2.99.0.beta1 or later
1336
+ c.output_stream
1337
+ c.output_stream = File.open('output.txt', 'w')
1338
+ c.output_stream
1339
+ c.output_stream = File.open('output.txt', 'w')
1340
+
1341
+ # RSpec 2.99.0.rc1 or later
1342
+ c.backtrace_formatter
1343
+ c.color_enabled?(output)
1344
+ c.pattern
1345
+ c.pattern = '**/*_test.rb'
1346
+ c.warnings?
1347
+ end
1348
+ ```
1349
+
1350
+ * This conversion can be disabled by: `--keep deprecated`
1351
+
1303
1352
  ### Monkey-patched example groups
1304
1353
 
1305
1354
  This conversion is **disabled by default** and available only if your project's RSpec is **3.0.0.beta2 or later**.
data/README.md.erb CHANGED
@@ -234,7 +234,7 @@ conversion_type_table = <<END
234
234
  `deprecated` | All other deprecated syntaxes | Latest syntaxes
235
235
  END
236
236
 
237
- validate_syntax_type_table(conversion_type_table, Transpec::OptionParser::CONFIG_ATTRS_FOR_KEEP_TYPES.keys)
237
+ validate_syntax_type_table(conversion_type_table, OptionParser::CONFIG_ATTRS_FOR_KEEP_TYPES.keys)
238
238
  conversion_type_table
239
239
  -%>
240
240
 
@@ -263,7 +263,7 @@ conversion_type_table = <<END
263
263
  `stub_with_hash` | `obj.stub(:message => value)` | `allow(obj).to receive(:message).and_return(value)`
264
264
  END
265
265
 
266
- validate_syntax_type_table(conversion_type_table, Transpec::OptionParser::CONFIG_ATTRS_FOR_CONVERT_TYPES.keys)
266
+ validate_syntax_type_table(conversion_type_table, OptionParser::CONFIG_ATTRS_FOR_CONVERT_TYPES.keys)
267
267
  conversion_type_table
268
268
  -%>
269
269
 
@@ -339,16 +339,15 @@ END
339
339
  <%= convert(example).gsub('original spec', 'converted spec') -%>
340
340
 
341
341
  <%=
342
- convert(example, cli: ['-p'])
343
- .gsub(
344
- 'original spec',
345
- 'converted spec with -p/--no-parens-matcher-arg option'
346
- )
347
- .gsub(/^.+\{ key: value \}/) do |match|
348
- " # With non-operator method, the parentheses are always required\n" +
349
- " # to prevent the hash from being interpreted as a block.\n" +
350
- match
351
- end
342
+ converted = convert(example, cli: ['-p'])
343
+ converted.gsub!(
344
+ 'original spec',
345
+ 'converted spec with -p/--no-parens-matcher-arg option'
346
+ )
347
+ insert_comment_above(converted, '{ key: value }', [
348
+ 'With non-operator method, the parentheses are always required',
349
+ 'to prevent the hash from being interpreted as a block.'
350
+ ])
352
351
  -%>
353
352
  ```
354
353
 
@@ -477,7 +476,7 @@ Will be converted to:
477
476
 
478
477
  ### One-liner expectations
479
478
 
480
- This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.oneliner_is_expected_available_version %> or later**.
479
+ This conversion is available only if your project's RSpec is **<%= rspec_version = RSpecVersion.oneliner_is_expected_available_version %> or later**.
481
480
 
482
481
  Targets:
483
482
 
@@ -542,7 +541,7 @@ This conversion is combined with the conversion of [standard expectations](#stan
542
541
 
543
542
  ### Boolean matchers
544
543
 
545
- This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.be_truthy_available_version %> or later**.
544
+ This conversion is available only if your project's RSpec is **<%= rspec_version = RSpecVersion.be_truthy_available_version %> or later**.
546
545
 
547
546
  Targets:
548
547
 
@@ -978,7 +977,7 @@ Will be converted to:
978
977
  <%= convert(example, wrap_with: :example).lines.to_a.uniq.join("\n") -%>
979
978
 
980
979
  # Conversion from `stub_chain` to `receive_message_chain` is available
981
- # only if the target project's RSpec is <%= rspec_version = Transpec::RSpecVersion.receive_message_chain_available_version %> or later
980
+ # only if the target project's RSpec is <%= rspec_version = RSpecVersion.receive_message_chain_available_version %> or later
982
981
  <%= convert(stub_chain_example, wrap_with: :example, rspec_version: rspec_version) -%>
983
982
 
984
983
  <%= convert(any_instance_example, wrap_with: :example) -%>
@@ -1007,13 +1006,13 @@ END
1007
1006
  Will be converted to:
1008
1007
 
1009
1008
  ```ruby
1010
- # If the target project's RSpec is <%= rspec_version = Transpec::RSpecVersion.receive_messages_available_version %> or later
1009
+ # If the target project's RSpec is <%= rspec_version = RSpecVersion.receive_messages_available_version %> or later
1011
1010
  <%= convert(example, wrap_with: :example, rspec_version: rspec_version) -%>
1012
1011
 
1013
- # If the target project's RSpec is prior to <%= Transpec::RSpecVersion.receive_messages_available_version %>
1012
+ # If the target project's RSpec is prior to <%= RSpecVersion.receive_messages_available_version %>
1014
1013
  <%= convert(example, wrap_with: :example, rspec_version: Transpec.required_rspec_version).chomp -%> # No conversion
1015
1014
 
1016
- # If the target project's RSpec is prior to <%= Transpec::RSpecVersion.receive_messages_available_version %>
1015
+ # If the target project's RSpec is prior to <%= RSpecVersion.receive_messages_available_version %>
1017
1016
  # and `--convert stub-with-hash` is specified
1018
1017
  <%= convert(example, wrap_with: :example, rspec_version: Transpec.required_rspec_version, cli: ['--convert', 'stub_with_hash']) -%>
1019
1018
  ```
@@ -1109,7 +1108,7 @@ Will be converted to:
1109
1108
 
1110
1109
  ### `any_instance` implementation blocks
1111
1110
 
1112
- This conversion is available only if your project's RSpec is **`>= <%= Transpec::RSpecVersion::RSPEC_2_99 %>` and `< <%= Transpec::RSpecVersion::RSPEC_3_0 %>`**.
1111
+ This conversion is available only if your project's RSpec is **`>= <%= RSpecVersion::RSPEC_2_99 %>` and `< <%= RSpecVersion::RSPEC_3_0 %>`**.
1113
1112
 
1114
1113
  Targets:
1115
1114
 
@@ -1132,7 +1131,7 @@ END
1132
1131
  Will be converted to:
1133
1132
 
1134
1133
  ```ruby
1135
- <% rspec_version = Transpec::RSpecVersion.yielding_receiver_to_any_instance_implementation_block_available_version -%>
1134
+ <% rspec_version = RSpecVersion.yielding_receiver_to_any_instance_implementation_block_available_version -%>
1136
1135
  <%= convert(example, rspec_version: rspec_version) -%>
1137
1136
  ```
1138
1137
 
@@ -1171,7 +1170,7 @@ Will be converted to:
1171
1170
 
1172
1171
  ### Pending examples
1173
1172
 
1174
- This conversion is available only if your project's RSpec is **`>= <%= Transpec::RSpecVersion::RSPEC_2_99 %>` and `< <%= Transpec::RSpecVersion::RSPEC_3_0 %>`**.
1173
+ This conversion is available only if your project's RSpec is **`>= <%= RSpecVersion::RSPEC_2_99 %>` and `< <%= RSpecVersion::RSPEC_3_0 %>`**.
1175
1174
 
1176
1175
  Targets:
1177
1176
 
@@ -1206,7 +1205,7 @@ Will be converted to:
1206
1205
 
1207
1206
  ```ruby
1208
1207
  <%=
1209
- convert(example, rspec_version: Transpec::RSpecVersion.skip_available_version)
1208
+ convert(example, rspec_version: RSpecVersion.skip_available_version)
1210
1209
  .gsub('pending', 'pending # #pending with block is no longer supported')
1211
1210
  -%>
1212
1211
  ```
@@ -1229,7 +1228,7 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/v2
1229
1228
 
1230
1229
  ### Current example object
1231
1230
 
1232
- This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.yielded_example_available_version %> or later**.
1231
+ This conversion is available only if your project's RSpec is **<%= rspec_version = RSpecVersion.yielded_example_available_version %> or later**.
1233
1232
 
1234
1233
  Targets:
1235
1234
 
@@ -1279,7 +1278,7 @@ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/7d
1279
1278
 
1280
1279
  ### Custom matcher DSL
1281
1280
 
1282
- This conversion is available only if your project's RSpec is **<%= rspec_version = Transpec::RSpecVersion.non_should_matcher_protocol_available_version %> or later**.
1281
+ This conversion is available only if your project's RSpec is **<%= rspec_version = RSpecVersion.non_should_matcher_protocol_available_version %> or later**.
1283
1282
 
1284
1283
  Targets:
1285
1284
 
@@ -1308,7 +1307,7 @@ Will be converted to:
1308
1307
 
1309
1308
  ### Implicit spec types in rspec-rails
1310
1309
 
1311
- 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**.
1310
+ This conversion is **available only if `rspec-rails` is loaded** in your spec and your project's RSpec is **<%= rspec_version = RSpecVersion.implicit_spec_type_disablement_available_version %> or later**.
1312
1311
 
1313
1312
  Targets:
1314
1313
 
@@ -1341,9 +1340,56 @@ Or with `--no-explicit-spec-type` option they will be converted to:
1341
1340
  * Deprecation: deprecated since RSpec 2.99, removed in RSpec 3.0
1342
1341
  * See also: [Consider making example group mixins more explicit · rspec/rspec-rails](https://github.com/rspec/rspec-rails/issues/662)
1343
1342
 
1343
+ ### Deprecated configuration options
1344
+
1345
+ Targets:
1346
+
1347
+ ```ruby
1348
+ <%=
1349
+ example = <<END
1350
+ RSpec.configure do |c|
1351
+ c.backtrace_clean_patterns
1352
+ c.backtrace_clean_patterns = [/lib\\/something/]
1353
+ c.color_enabled = true
1354
+
1355
+ c.out
1356
+ c.out = File.open('output.txt', 'w')
1357
+ c.output
1358
+ c.output = File.open('output.txt', 'w')
1359
+
1360
+ c.backtrace_cleaner
1361
+ c.color?(output)
1362
+ c.filename_pattern
1363
+ c.filename_pattern = '**/*_test.rb'
1364
+ c.warnings
1365
+ end
1366
+ END
1367
+ -%>
1368
+ ```
1369
+
1370
+ Will be converted to:
1371
+
1372
+ ```ruby
1373
+ <%=
1374
+ converted = convert(example, rspec_version: RSpecVersion.new('3.0.0'))
1375
+
1376
+ [
1377
+ ['c.output_stream', :config_output_stream],
1378
+ ['c.backtrace_formatter', :config_backtrace_formatter],
1379
+ ].each do |pattern, feature|
1380
+ rspec_version = RSpecVersion.send("#{feature}_available_version")
1381
+ converted = insert_comment_above(converted, pattern, "RSpec #{rspec_version} or later")
1382
+ end
1383
+
1384
+ converted
1385
+ -%>
1386
+ ```
1387
+
1388
+ * This conversion can be disabled by: `--keep deprecated`
1389
+
1344
1390
  ### Monkey-patched example groups
1345
1391
 
1346
- 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**.
1392
+ This conversion is **disabled by default** and available only if your project's RSpec is **<%= rspec_version = RSpecVersion.non_monkey_patch_example_group_available_version %> or later**.
1347
1393
 
1348
1394
  Targets:
1349
1395
 
@@ -1376,7 +1422,7 @@ Will be converted to:
1376
1422
 
1377
1423
  ### Hook scope aliases
1378
1424
 
1379
- 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**.
1425
+ This conversion is **disabled by default** and available only if your project's RSpec is **<%= rspec_version = RSpecVersion.hook_scope_alias_available_version %> or later**.
1380
1426
 
1381
1427
  Targets:
1382
1428
 
@@ -165,7 +165,9 @@ module Transpec
165
165
  end
166
166
 
167
167
  def process_rspec_configure(rspec_configure)
168
- rspec_configure.convert_deprecated_options!(rspec_version)
168
+ if config.convert_deprecated_method?
169
+ rspec_configure.convert_deprecated_options!(rspec_version)
170
+ end
169
171
 
170
172
  if spec_suite.main_rspec_configure_node?(rspec_configure.node)
171
173
  if rspec_version.non_monkey_patch_example_group_available? &&
@@ -88,7 +88,6 @@ module Transpec
88
88
 
89
89
  if rspec_version.config_backtrace_formatter_available?
90
90
  replace_config!(:backtrace_cleaner, :backtrace_formatter)
91
- replace_config!(:backtrace_cleaner=, :backtrace_formatter=)
92
91
  end
93
92
 
94
93
  if rspec_version.config_predicate_color_enabled_available?
@@ -5,7 +5,7 @@ module Transpec
5
5
  module Version
6
6
  MAJOR = 2
7
7
  MINOR = 3
8
- PATCH = 0
8
+ PATCH = 1
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
@@ -1140,6 +1140,24 @@ module Transpec
1140
1140
  ).as_null_object
1141
1141
  end
1142
1142
 
1143
+ context 'when Config#convert_deprecated_method? returns true' do
1144
+ before { config.convert_deprecated_method = true }
1145
+
1146
+ it 'invokes RSpecConfigure#convert_deprecated_options! with RSpecVersion' do
1147
+ rspec_configure.should_receive(:convert_deprecated_options!).with(rspec_version)
1148
+ converter.process_rspec_configure(rspec_configure)
1149
+ end
1150
+ end
1151
+
1152
+ context 'when Config#convert_deprecated_method? returns false' do
1153
+ before { config.convert_deprecated_method = false }
1154
+
1155
+ it 'does not invoke RSpecConfigure#convert_deprecated_options!' do
1156
+ rspec_configure.should_not_receive(:convert_deprecated_options!)
1157
+ converter.process_rspec_configure(rspec_configure)
1158
+ end
1159
+ end
1160
+
1143
1161
  context 'when RSpecVersion#rspec_2_99? returns true' do
1144
1162
  before do
1145
1163
  rspec_version.stub(:rspec_2_99?).and_return(true)
data/tasks/readme.rake CHANGED
@@ -1,5 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'transpec'
4
+
3
5
  desc 'Generate README.md'
4
6
  task :readme do
5
7
  puts 'Generating README.md...'
@@ -33,11 +35,12 @@ def generate_readme
33
35
  end
34
36
 
35
37
  class READMEContext
38
+ include Transpec
39
+
36
40
  attr_reader :readme
37
41
 
38
42
  def initialize(readme)
39
43
  @readme = readme
40
- require 'transpec'
41
44
  require 'transpec/cli'
42
45
  require 'stringio'
43
46
  require 'tmpdir'
@@ -159,4 +162,18 @@ class READMEContext
159
162
  fail "No descriptions for syntax types #{types_missing_description}"
160
163
  end
161
164
  end
165
+
166
+ def insert_comment_above(code, pattern, comments)
167
+ regexp = Regexp.new('^([ \t]*).*' + Regexp.escape(pattern))
168
+
169
+ code.sub(regexp) do |match|
170
+ indentation = Regexp.last_match(1)
171
+ replacement = ''
172
+ Array(comments).each do |comment|
173
+ comment = comment.to_s.chomp
174
+ replacement << "#{indentation}# #{comment}\n"
175
+ end
176
+ replacement << match
177
+ end
178
+ end
162
179
  end
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.3.0
4
+ version: 2.3.1
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-06-15 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser