transpec 2.2.5 → 2.3.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/transpec/conversion_error.rb +5 -5
  4. data/lib/transpec/converter.rb +14 -12
  5. data/lib/transpec/record.rb +88 -31
  6. data/lib/transpec/report.rb +19 -11
  7. data/lib/transpec/rspec_version.rb +9 -0
  8. data/lib/transpec/syntax/be_boolean.rb +2 -2
  9. data/lib/transpec/syntax/be_close.rb +1 -1
  10. data/lib/transpec/syntax/current_example.rb +35 -17
  11. data/lib/transpec/syntax/double.rb +1 -1
  12. data/lib/transpec/syntax/example.rb +0 -4
  13. data/lib/transpec/syntax/example_group.rb +11 -11
  14. data/lib/transpec/syntax/have/{have_record.rb → record_builder.rb} +15 -17
  15. data/lib/transpec/syntax/have.rb +2 -2
  16. data/lib/transpec/syntax/hook.rb +3 -3
  17. data/lib/transpec/syntax/its.rb +25 -17
  18. data/lib/transpec/syntax/matcher_definition.rb +1 -2
  19. data/lib/transpec/syntax/method_stub.rb +44 -51
  20. data/lib/transpec/syntax/mixin/any_instance_block.rb +8 -6
  21. data/lib/transpec/syntax/mixin/useless_and_return.rb +9 -7
  22. data/lib/transpec/syntax/oneliner_should.rb +29 -27
  23. data/lib/transpec/syntax/operator.rb +3 -3
  24. data/lib/transpec/syntax/pending.rb +0 -4
  25. data/lib/transpec/syntax/raise_error.rb +35 -15
  26. data/lib/transpec/syntax/receive.rb +6 -6
  27. data/lib/transpec/syntax/rspec_configure/config_modification.rb +39 -5
  28. data/lib/transpec/syntax/rspec_configure/framework.rb +27 -7
  29. data/lib/transpec/syntax/rspec_configure/mocks.rb +2 -2
  30. data/lib/transpec/syntax/rspec_configure.rb +35 -4
  31. data/lib/transpec/syntax/should.rb +35 -20
  32. data/lib/transpec/syntax/should_receive.rb +30 -27
  33. data/lib/transpec/syntax.rb +10 -0
  34. data/lib/transpec/version.rb +2 -2
  35. data/spec/integration/configuration_modification_spec.rb +43 -3
  36. data/spec/transpec/record_spec.rb +113 -18
  37. data/spec/transpec/report_spec.rb +15 -6
  38. data/spec/transpec/rspec_version_spec.rb +5 -0
  39. data/spec/transpec/syntax/be_boolean_spec.rb +10 -10
  40. data/spec/transpec/syntax/be_close_spec.rb +2 -2
  41. data/spec/transpec/syntax/current_example_spec.rb +6 -6
  42. data/spec/transpec/syntax/double_spec.rb +2 -2
  43. data/spec/transpec/syntax/example_group_spec.rb +4 -4
  44. data/spec/transpec/syntax/example_spec.rb +8 -8
  45. data/spec/transpec/syntax/have_spec.rb +44 -44
  46. data/spec/transpec/syntax/hook_spec.rb +8 -8
  47. data/spec/transpec/syntax/its_spec.rb +16 -16
  48. data/spec/transpec/syntax/matcher_definition_spec.rb +2 -2
  49. data/spec/transpec/syntax/method_stub_spec.rb +36 -36
  50. data/spec/transpec/syntax/oneliner_should_spec.rb +26 -26
  51. data/spec/transpec/syntax/operator_spec.rb +18 -18
  52. data/spec/transpec/syntax/pending_spec.rb +6 -6
  53. data/spec/transpec/syntax/raise_error_spec.rb +10 -10
  54. data/spec/transpec/syntax/receive_spec.rb +20 -20
  55. data/spec/transpec/syntax/rspec_configure_spec.rb +202 -18
  56. data/spec/transpec/syntax/should_receive_spec.rb +30 -30
  57. data/spec/transpec/syntax/should_spec.rb +8 -8
  58. data/tasks/fixtures/mail/2.99.0/COMMIT_EDITMSG +1 -1
  59. data/tasks/fixtures/mail/3.0.0/COMMIT_EDITMSG +5 -2
  60. data/tasks/fixtures/twitter/2.99.0/COMMIT_EDITMSG +1 -1
  61. data/tasks/fixtures/twitter/3.0.0/COMMIT_EDITMSG +2 -2
  62. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6344cbf3016bb43e49fb70dbe7a4105439b45ef0
4
- data.tar.gz: 8e5692f353278c6cf1cf120d582c504c9859493c
3
+ metadata.gz: 3cc32f4f45ab036ddecaefb46245014a4713fdee
4
+ data.tar.gz: 2b7feec59ef424cb3df9d47145683fcc6c496b9e
5
5
  SHA512:
6
- metadata.gz: 163b3f743c5033a58d8a4c8643f2b71e7c771e79a0183f8c785f56f6fa59fad65e83f291c20973ecc1354fcb453909451f2384d1a7a1617df972a77820502964
7
- data.tar.gz: 6e68356769b715ea2becfcfea1d8e80807b973b2d6322022b79438400b0ffa64fee65b0a82835ecd9284b133017bfcb882f968f26c7a86f2ed65cc7856d80cce
6
+ metadata.gz: b53e41a17861208c396e6955152123dca5a623041265987c8f03caf3f3bb14fb28ddaabcd1f46dad918a477ad499e155e801e042ab3b6464ccc46d0ebdb7f361
7
+ data.tar.gz: 3b3cf2d94a9a6adfd671235d639ae65a2cf8c8887acccb28b6b4eee9c9dabd266a84d195f680b425410685f466a3e726f07610e9045750b6e3377427044d3002
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v2.3.0
6
+
7
+ * Report configuration modifications of `RSpec.configure` in the final summary.
8
+ * Support conversion of configuration options `backtrace_clean_patterns`, `backtrace_clean_patterns=`, `color_enabled=`, `output`, `output=`, `out`, `out=`, `filename_pattern`, `filename_pattern=`, `backtrace_cleaner`, `backtrace_cleaner=`, `color?` and `warnings`.
9
+
5
10
  ## v2.2.5
6
11
 
7
12
  * Fix invalid conversion of `unstub` without parentheses (`obj.unstub :message`). ([#74](https://github.com/yujinakayama/transpec/pull/74))
@@ -8,16 +8,16 @@ module Transpec
8
8
  end
9
9
 
10
10
  class ContextError < ConversionError
11
- def initialize(original_syntax, target_syntax, source_range)
12
- message = build_message(original_syntax, target_syntax)
11
+ def initialize(old_syntax, new_syntax, source_range)
12
+ message = build_message(old_syntax, new_syntax)
13
13
  super(message, source_range)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def build_message(original_syntax, target_syntax)
19
- "Cannot convert #{original_syntax} into #{target_syntax} " \
20
- "since #{target_syntax} is not available in the context."
18
+ def build_message(old_syntax, new_syntax)
19
+ "Cannot convert #{old_syntax} into #{new_syntax} " \
20
+ "since #{new_syntax} is not available in the context."
21
21
  end
22
22
  end
23
23
  end
@@ -165,21 +165,23 @@ module Transpec
165
165
  end
166
166
 
167
167
  def process_rspec_configure(rspec_configure)
168
- return unless spec_suite.main_rspec_configure_node?(rspec_configure.node)
168
+ rspec_configure.convert_deprecated_options!(rspec_version)
169
169
 
170
- if rspec_version.non_monkey_patch_example_group_available? &&
171
- config.convert_example_group?
172
- rspec_configure.expose_dsl_globally = false
173
- end
170
+ if spec_suite.main_rspec_configure_node?(rspec_configure.node)
171
+ if rspec_version.non_monkey_patch_example_group_available? &&
172
+ config.convert_example_group?
173
+ rspec_configure.expose_dsl_globally = false
174
+ end
174
175
 
175
- if need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?
176
- should_yield = config.add_receiver_arg_to_any_instance_implementation_block?
177
- rspec_configure.mocks.yield_receiver_to_any_instance_implementation_blocks = should_yield
178
- end
176
+ if need_to_modify_yield_receiver_to_any_instance_implementation_blocks_config?
177
+ should_yield = config.add_receiver_arg_to_any_instance_implementation_block?
178
+ rspec_configure.mocks.yield_receiver_to_any_instance_implementation_blocks = should_yield
179
+ end
179
180
 
180
- if rspec_version.implicit_spec_type_disablement_available? &&
181
- !config.add_explicit_type_metadata_to_example_group?
182
- rspec_configure.infer_spec_type_from_file_location!
181
+ if rspec_version.implicit_spec_type_disablement_available? &&
182
+ !config.add_explicit_type_metadata_to_example_group?
183
+ rspec_configure.infer_spec_type_from_file_location!
184
+ end
183
185
  end
184
186
  end
185
187
 
@@ -4,66 +4,123 @@ require 'transpec/annotatable'
4
4
 
5
5
  module Transpec
6
6
  class Record
7
- OVERRIDE_FORBIDDEN_METHODS = [
8
- :original_syntax,
9
- :original_syntax_type,
10
- :converted_syntax,
11
- :converted_syntax_type
12
- ]
7
+ include Comparable
13
8
 
14
- attr_reader :original_syntax_type, :converted_syntax_type, :annotation
9
+ TYPES = [:conversion, :addition, :removal, :modification]
10
+ COMPARISON_ATTRIBUTES = [:type_sort_key, :old_syntax, :new_syntax].freeze
15
11
 
16
- def initialize(original_syntax, converted_syntax, annotation = nil)
17
- @original_syntax_type = original_syntax.to_sym
18
- @converted_syntax_type = converted_syntax.to_sym
19
- @annotation = annotation
20
- end
12
+ attr_reader :old_syntax_type, :new_syntax_type, :annotation
13
+
14
+ def initialize(old_syntax, new_syntax, options = {})
15
+ # Keep these syntax data as symbols for:
16
+ # * Better memory footprint
17
+ # * Better summarizing performance in Report
18
+ @old_syntax_type = old_syntax && old_syntax.to_sym
19
+ @new_syntax_type = new_syntax && new_syntax.to_sym
20
+
21
+ @type = options[:type]
22
+ @annotation = options[:annotation]
21
23
 
22
- def original_syntax
23
- original_syntax_type.to_s
24
+ fail ArgumentError, "Invalid type: #{type}" unless TYPES.include?(type)
24
25
  end
25
26
 
26
- def converted_syntax
27
- converted_syntax_type.to_s
27
+ def type
28
+ @type ||= if old_syntax_type && new_syntax_type
29
+ :conversion
30
+ elsif new_syntax_type
31
+ :addition
32
+ else
33
+ :removal
34
+ end
28
35
  end
29
36
 
30
- def original_syntax_type
31
- @original_syntax_type ||= build_original_syntax.to_sym
37
+ def old_syntax
38
+ old_syntax_type && old_syntax_type.to_s
32
39
  end
33
40
 
34
- def converted_syntax_type
35
- @converted_syntax_type ||= build_converted_syntax.to_sym
41
+ def new_syntax
42
+ new_syntax_type && new_syntax_type.to_s
36
43
  end
37
44
 
38
45
  def ==(other)
39
46
  self.class == other.class &&
40
- original_syntax_type == other.original_syntax_type &&
41
- converted_syntax_type == other.converted_syntax_type
47
+ old_syntax_type == other.old_syntax_type &&
48
+ new_syntax_type == other.new_syntax_type
42
49
  end
43
50
 
44
51
  alias_method :eql?, :==
45
52
 
46
53
  def hash
47
- original_syntax_type.hash ^ converted_syntax_type.hash
54
+ old_syntax_type.hash ^ new_syntax_type.hash
48
55
  end
49
56
 
50
57
  def to_s
51
- "`#{original_syntax_type}` -> `#{converted_syntax_type}`"
58
+ string = type.to_s.capitalize
59
+
60
+ string << case type
61
+ when :conversion, :modification
62
+ " from `#{old_syntax_type}` to `#{new_syntax_type}`"
63
+ when :addition
64
+ " of `#{new_syntax_type}`"
65
+ when :removal
66
+ " of `#{old_syntax_type}`"
67
+ end
68
+ end
69
+
70
+ def <=>(other)
71
+ COMPARISON_ATTRIBUTES.each do |attribute|
72
+ result = send(attribute) <=> other.send(attribute)
73
+ return result unless result == 0
74
+ end
75
+ 0
76
+ end
77
+
78
+ private
79
+
80
+ def type_sort_key
81
+ case type
82
+ when :conversion then 1
83
+ when :modification then 2
84
+ when :addition then 3
85
+ when :removal then 4
86
+ end
87
+ end
88
+ end
89
+
90
+ # This class is intended to be inherited to build complex record.
91
+ # The reasons why you should inherit this class rather than Record are:
92
+ # * You need to care about String and Symbol around Record#old_syntax and #new_syntax.
93
+ # * All record instances are kept in a Report until the end of Transpec process.
94
+ # This mean that if a custom record keeps a syntax object as an ivar,
95
+ # the AST kept by the syntax object won't be GCed.
96
+ class RecordBuilder
97
+ def self.build(*args)
98
+ new(*args).build
99
+ end
100
+
101
+ def build
102
+ Record.new(old_syntax, new_syntax, { type: type, annotation: annotation })
52
103
  end
53
104
 
54
105
  private
55
106
 
56
- def build_original_syntax
57
- fail NotImplementedError
107
+ def initialize(*)
108
+ end
109
+
110
+ def old_syntax
111
+ nil
112
+ end
113
+
114
+ def new_syntax
115
+ nil
58
116
  end
59
117
 
60
- def build_converted_syntax
61
- fail NotImplementedError
118
+ def type
119
+ nil
62
120
  end
63
121
 
64
- def self.method_added(method_name)
65
- return unless OVERRIDE_FORBIDDEN_METHODS.include?(method_name)
66
- fail "Do not override Record##{method_name}."
122
+ def annotation
123
+ nil
67
124
  end
68
125
  end
69
126
 
@@ -27,7 +27,7 @@ module Transpec
27
27
  end
28
28
 
29
29
  sorted_record_counts = record_counts.sort_by do |record, count|
30
- [-count, record.original_syntax_type, record.converted_syntax_type]
30
+ [-count, record]
31
31
  end
32
32
 
33
33
  Hash[sorted_record_counts]
@@ -85,16 +85,24 @@ module Transpec
85
85
  end
86
86
 
87
87
  def format_record(record, count, bullet = nil)
88
- entry_prefix = bullet ? bullet + ' ' : ''
89
- indentation = if bullet
90
- ' ' * entry_prefix.length
91
- else
92
- ''
93
- end
94
-
95
- text = entry_prefix + colorize(pluralize(count, 'conversion'), :cyan) + "\n"
96
- text << indentation + ' ' + colorize('from: ', :cyan) + record.original_syntax + "\n"
97
- text << indentation + ' ' + colorize('to: ', :cyan) + record.converted_syntax + "\n"
88
+ entry_prefix = bullet ? "#{bullet} " : ''
89
+ text = entry_prefix + colorize(pluralize(count, record.type), :cyan) + "\n"
90
+
91
+ justification = entry_prefix.length + 6
92
+
93
+ case record.type
94
+ when :conversion
95
+ text << labeled_line('from', record.old_syntax, justification)
96
+ text << labeled_line('to', record.new_syntax, justification)
97
+ when :addition
98
+ text << labeled_line('of', record.new_syntax, justification)
99
+ when :removal
100
+ text << labeled_line('of', record.old_syntax, justification)
101
+ end
102
+ end
103
+
104
+ def labeled_line(label, content, justification)
105
+ colorize("#{label.rjust(justification)}: ", :cyan) + content + "\n"
98
106
  end
99
107
 
100
108
  def conversion_incomplete_warning_stats(color)
@@ -43,11 +43,20 @@ module Transpec
43
43
 
44
44
  define_feature :be_truthy, '2.99.0.beta1'
45
45
  define_feature :yielded_example, '2.99.0.beta1'
46
+ define_feature :config_output_stream, '2.99.0.beta1'
46
47
  define_feature :yielding_receiver_to_any_instance_implementation_block, '2.99.0.beta1'
47
48
 
48
49
  define_feature :oneliner_is_expected, '2.99.0.beta2', except: '3.0.0.beta1'
49
50
  define_feature :skip, '2.99.0.beta2', except: '3.0.0.beta1'
50
51
 
52
+ define_feature :config_pattern, '2.99.0.rc1',
53
+ except: ['3.0.0.beta1', '3.0.0.beta2']
54
+ define_feature :config_backtrace_formatter, '2.99.0.rc1',
55
+ except: ['3.0.0.beta1', '3.0.0.beta2']
56
+ define_feature :config_predicate_color_enabled, '2.99.0.rc1',
57
+ except: ['3.0.0.beta1', '3.0.0.beta2']
58
+ define_feature :config_predicate_warnings, '2.99.0.rc1',
59
+ except: ['3.0.0.beta1', '3.0.0.beta2']
51
60
  define_feature :implicit_spec_type_disablement, '2.99.0.rc1',
52
61
  except: ['3.0.0.beta1', '3.0.0.beta2']
53
62
 
@@ -30,8 +30,8 @@ module Transpec
30
30
 
31
31
  private
32
32
 
33
- def add_record(converted_syntax)
34
- report.records << Record.new(method_name.to_s, converted_syntax)
33
+ def add_record(new_syntax)
34
+ super(method_name, new_syntax)
35
35
  end
36
36
  end
37
37
  end
@@ -29,7 +29,7 @@ module Transpec
29
29
  private
30
30
 
31
31
  def add_record
32
- report.records << Record.new('be_close(expected, delta)', 'be_within(delta).of(expected)')
32
+ super('be_close(expected, delta)', 'be_within(delta).of(expected)')
33
33
  end
34
34
  end
35
35
  end
@@ -28,13 +28,7 @@ module Transpec
28
28
  replace(selector_range, 'RSpec.current_example')
29
29
  end
30
30
 
31
- add_record
32
- end
33
-
34
- private
35
-
36
- def block_has_argument?
37
- block_arg_node || block_node.metadata[:added_example_block_arg]
31
+ add_record(RecordBuilder.build(self))
38
32
  end
39
33
 
40
34
  def block_node
@@ -51,6 +45,12 @@ module Transpec
51
45
  method_name_of_block_node(block_node)
52
46
  end
53
47
 
48
+ private
49
+
50
+ def block_has_argument?
51
+ block_arg_node || block_node.metadata[:added_example_block_arg]
52
+ end
53
+
54
54
  def block_arg_node
55
55
  args_node = block_node.children[1]
56
56
  args_node.children.first
@@ -69,18 +69,36 @@ module Transpec
69
69
  send_node.children[1]
70
70
  end
71
71
 
72
- def add_record
73
- if block_node
74
- prefix = "#{block_method_name}"
75
- prefix << '(:name)' if HELPER_METHODS.include?(block_method_name)
76
- original_syntax = "#{prefix} { example }"
77
- converted_syntax = "#{prefix} { |example| example }"
78
- else
79
- original_syntax = 'def helper_method example; end'
80
- converted_syntax = 'def helper_method RSpec.current_example; end'
72
+ class RecordBuilder < Transpec::RecordBuilder
73
+ include RSpecDSL
74
+
75
+ attr_reader :current_example
76
+
77
+ def initialize(current_example)
78
+ @current_example = current_example
81
79
  end
82
80
 
83
- report.records << Record.new(original_syntax, converted_syntax)
81
+ def old_syntax
82
+ if current_example.block_node
83
+ "#{base_dsl} { example }"
84
+ else
85
+ 'def helper_method example; end'
86
+ end
87
+ end
88
+
89
+ def new_syntax
90
+ if current_example.block_node
91
+ "#{base_dsl} { |example| example }"
92
+ else
93
+ 'def helper_method RSpec.current_example; end'
94
+ end
95
+ end
96
+
97
+ def base_dsl
98
+ dsl = "#{current_example.block_method_name}"
99
+ dsl << '(:name)' if HELPER_METHODS.include?(current_example.block_method_name)
100
+ dsl
101
+ end
84
102
  end
85
103
  end
86
104
  end
@@ -21,7 +21,7 @@ module Transpec
21
21
  private
22
22
 
23
23
  def add_record
24
- report.records << Record.new("#{method_name}('something')", "double('something')")
24
+ super("#{method_name}('something')", "double('something')")
25
25
  end
26
26
  end
27
27
  end
@@ -64,10 +64,6 @@ module Transpec
64
64
  range
65
65
  end
66
66
  end
67
-
68
- def add_record(original_syntax, converted_syntax)
69
- report.records << Record.new(original_syntax, converted_syntax)
70
- end
71
67
  end
72
68
  end
73
69
  end
@@ -39,7 +39,7 @@ module Transpec
39
39
  def convert_to_non_monkey_patch!
40
40
  return if receiver_node
41
41
  insert_before(expression_range, 'RSpec.')
42
- report.records << NonMonkeyPatchDescribeRecord.new(self)
42
+ add_record(NonMonkeyPatchRecordBuilder.build(self))
43
43
  end
44
44
 
45
45
  def add_explicit_type_metadata!
@@ -59,7 +59,7 @@ module Transpec
59
59
 
60
60
  insert_after(arg_node.loc.expression, code)
61
61
 
62
- report.records << ExplicitTypeMetadataRecord.new(self)
62
+ add_record(ExplicitTypeMetadataRecordBuilder.build(self))
63
63
  end
64
64
 
65
65
  def implicit_type_metadata
@@ -96,18 +96,18 @@ module Transpec
96
96
  end
97
97
  end
98
98
 
99
- class NonMonkeyPatchDescribeRecord < Record
99
+ class NonMonkeyPatchRecordBuilder < RecordBuilder
100
100
  attr_reader :example_group
101
101
 
102
102
  def initialize(example_group)
103
103
  @example_group = example_group
104
104
  end
105
105
 
106
- def build_original_syntax
106
+ def old_syntax
107
107
  base_syntax
108
108
  end
109
109
 
110
- def build_converted_syntax
110
+ def new_syntax
111
111
  "RSpec.#{base_syntax}"
112
112
  end
113
113
 
@@ -116,22 +116,22 @@ module Transpec
116
116
  end
117
117
  end
118
118
 
119
- class ExplicitTypeMetadataRecord < Record
119
+ class ExplicitTypeMetadataRecordBuilder < RecordBuilder
120
120
  attr_reader :example_group
121
121
 
122
122
  def initialize(example_group)
123
123
  @example_group = example_group
124
124
  end
125
125
 
126
- def build_original_syntax
127
- "describe 'some #{type}' { }"
126
+ def old_syntax
127
+ "describe 'some #{spec_type}' { }"
128
128
  end
129
129
 
130
- def build_converted_syntax
131
- "describe 'some #{type}', :type => #{type.inspect} { }"
130
+ def new_syntax
131
+ "describe 'some #{spec_type}', :type => #{spec_type.inspect} { }"
132
132
  end
133
133
 
134
- def type
134
+ def spec_type
135
135
  example_group.implicit_type_metadata
136
136
  end
137
137
  end
@@ -5,7 +5,7 @@ require 'transpec/syntax/have'
5
5
  module Transpec
6
6
  class Syntax
7
7
  class Have
8
- class HaveRecord < Record
8
+ class RecordBuilder < Transpec::RecordBuilder
9
9
  attr_reader :have
10
10
 
11
11
  def initialize(have)
@@ -22,17 +22,15 @@ module Transpec
22
22
  end
23
23
  end
24
24
 
25
- private
26
-
27
- def build_original_syntax
25
+ def old_syntax
28
26
  type = have.expectation.class.snake_case_name.to_sym
29
- syntax = build_expectation(original_subject, type)
30
- syntax << " #{have.method_name}(n).#{original_items}"
27
+ syntax = build_expectation(old_subject, type)
28
+ syntax << " #{have.method_name}(n).#{old_items}"
31
29
  end
32
30
 
33
- def build_converted_syntax
31
+ def new_syntax
34
32
  type = have.expectation.current_syntax_type
35
- syntax = build_expectation(converted_subject, type)
33
+ syntax = build_expectation(new_subject, type)
36
34
  syntax << " #{source_builder.replacement_matcher_source}"
37
35
  end
38
36
 
@@ -53,7 +51,7 @@ module Transpec
53
51
  have.expectation.positive?
54
52
  end
55
53
 
56
- def original_subject
54
+ def old_subject
57
55
  if have.subject_is_owner_of_collection?
58
56
  'obj'
59
57
  else
@@ -61,7 +59,7 @@ module Transpec
61
59
  end
62
60
  end
63
61
 
64
- def original_items
62
+ def old_items
65
63
  if have.subject_is_owner_of_collection?
66
64
  if have.items_method_has_arguments?
67
65
  "#{have.collection_accessor}(...)"
@@ -73,23 +71,23 @@ module Transpec
73
71
  end
74
72
  end
75
73
 
76
- def converted_subject
77
- if @have.subject_is_owner_of_collection?
78
- build_converted_subject('obj')
74
+ def new_subject
75
+ if have.subject_is_owner_of_collection?
76
+ build_new_subject('obj')
79
77
  else
80
- build_converted_subject('collection')
78
+ build_new_subject('collection')
81
79
  end
82
80
  end
83
81
 
84
- def build_converted_subject(subject)
82
+ def build_new_subject(subject)
85
83
  if have.subject_is_owner_of_collection?
86
- converted_owner_of_collection(subject)
84
+ new_owner_of_collection(subject)
87
85
  else
88
86
  subject << ".#{have.default_query_method}"
89
87
  end
90
88
  end
91
89
 
92
- def converted_owner_of_collection(subject)
90
+ def new_owner_of_collection(subject)
93
91
  subject << '.'
94
92
 
95
93
  if have.collection_accessor_is_private?
@@ -8,8 +8,8 @@ module Transpec
8
8
  class Syntax
9
9
  class Have < Syntax
10
10
  require 'transpec/syntax/have/dynamic_analysis'
11
+ require 'transpec/syntax/have/record_builder'
11
12
  require 'transpec/syntax/have/source_builder'
12
- require 'transpec/syntax/have/have_record'
13
13
 
14
14
  include Mixin::Send, Mixin::OwnedMatcher, DynamicAnalysis
15
15
 
@@ -132,7 +132,7 @@ module Transpec
132
132
  end
133
133
 
134
134
  def add_record
135
- report.records << HaveRecord.new(self)
135
+ super(Have::RecordBuilder.build(self))
136
136
  end
137
137
  end
138
138
  end
@@ -36,9 +36,9 @@ module Transpec
36
36
  end
37
37
 
38
38
  def add_record
39
- original_syntax = "#{method_name}(#{scope_name.inspect}) { }"
40
- converted_syntax = "#{method_name}(#{replacement_scope_name.inspect}) { }"
41
- report.records << Record.new(original_syntax, converted_syntax)
39
+ old_syntax = "#{method_name}(#{scope_name.inspect}) { }"
40
+ new_syntax = "#{method_name}(#{replacement_scope_name.inspect}) { }"
41
+ super(old_syntax, new_syntax)
42
42
  end
43
43
  end
44
44
  end
@@ -120,23 +120,7 @@ module Transpec
120
120
  end
121
121
 
122
122
  def add_record
123
- report.records << Record.new(original_syntax, converted_syntax)
124
- end
125
-
126
- def original_syntax
127
- if attribute_expression.brackets?
128
- 'its([:key]) { }'
129
- else
130
- 'its(:attr) { }'
131
- end
132
- end
133
-
134
- def converted_syntax
135
- if attribute_expression.brackets?
136
- "describe '[:key]' do subject { super()[:key] }; it { } end"
137
- else
138
- "describe '#attr' do subject { super().attr }; it { } end"
139
- end
123
+ super(RecordBuilder.build(self))
140
124
  end
141
125
 
142
126
  class AttributeExpression
@@ -196,6 +180,30 @@ module Transpec
196
180
  end
197
181
 
198
182
  Attribute = Struct.new(:selector, :description)
183
+
184
+ class RecordBuilder < Transpec::RecordBuilder
185
+ attr_reader :its
186
+
187
+ def initialize(its)
188
+ @its = its
189
+ end
190
+
191
+ def old_syntax
192
+ if its.attribute_expression.brackets?
193
+ 'its([:key]) { }'
194
+ else
195
+ 'its(:attr) { }'
196
+ end
197
+ end
198
+
199
+ def new_syntax
200
+ if its.attribute_expression.brackets?
201
+ "describe '[:key]' do subject { super()[:key] }; it { } end"
202
+ else
203
+ "describe '#attr' do subject { super().attr }; it { } end"
204
+ end
205
+ end
206
+ end
199
207
  end
200
208
  end
201
209
  end