transpec 3.0.2 → 3.0.3
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 +4 -0
- data/lib/transpec/syntax/operator.rb +10 -6
- data/lib/transpec/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 202c5b3a6677c5a08f53787a4b92a1da72a16d6d
|
4
|
+
data.tar.gz: 7cde03bd6520c7a25a890f436ece6644d182cfdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c3b3fce8aa0a69802afef630b80b074143cbb0573c035b277ac69e3be9da12f5b66ed95a8a2a7f5263ea3cc24fec1e32d4a9545cd7b38743097ae9c22a2d60
|
7
|
+
data.tar.gz: fe8b7f7d45c7eb1ee68c449dca9f457fe91fa32fe0e548836c1e8d6ef9e0bff459d599055f5cff2a2c51d890dce88739972f68b5cfdde70ee45ccadc191cd57c
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Development
|
4
4
|
|
5
|
+
## v3.0.3
|
6
|
+
|
7
|
+
* Fix a bug where `obj.should =~ an_activerecord_relation` was converted to `expect(obj).to match(an_activerecord_relation)` rather than `match_array`. ([#92](https://github.com/yujinakayama/transpec/issues/92))
|
8
|
+
|
5
9
|
## v3.0.2
|
6
10
|
|
7
11
|
* Fix a bug where `have(n).errors_on(:attr)` was unintentionally converted when combined with one-liner `should`. ([#95](https://github.com/yujinakayama/transpec/issues/95))
|
@@ -17,7 +17,11 @@ module Transpec
|
|
17
17
|
|
18
18
|
define_dynamic_analysis do |rewriter|
|
19
19
|
if method_name == :=~
|
20
|
-
|
20
|
+
# https://github.com/rspec/rspec-expectations/blob/v2.14.5/lib/rspec/matchers.rb#L692
|
21
|
+
# https://github.com/rspec/rspec-rails/blob/v2.14.2/lib/rspec/rails/matchers/relation_match_array.rb
|
22
|
+
code = 'is_a?(Enumerable) || ' \
|
23
|
+
'self.class.ancestors.any? { |klass| klass.name == "ActiveRecord::Relation" }'
|
24
|
+
rewriter.register_request(arg_node, :using_match_array?, code)
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
@@ -78,7 +82,7 @@ module Transpec
|
|
78
82
|
def convert_to_match!(parenthesize_arg)
|
79
83
|
handle_anterior_of_operator!
|
80
84
|
|
81
|
-
if
|
85
|
+
if using_match_array?
|
82
86
|
replace(selector_range, 'match_array')
|
83
87
|
else
|
84
88
|
replace(selector_range, 'match')
|
@@ -86,11 +90,11 @@ module Transpec
|
|
86
90
|
|
87
91
|
parenthesize!(parenthesize_arg)
|
88
92
|
|
89
|
-
accurate = !
|
93
|
+
accurate = !using_match_array?.nil? # rubocop:disable NonNilCheck
|
90
94
|
|
91
95
|
# Need to register record after all source rewrites are done
|
92
96
|
# to avoid false record when failed with overlapped rewrite.
|
93
|
-
if
|
97
|
+
if using_match_array?
|
94
98
|
add_record('=~ [1, 2]', 'match_array([1, 2])', accurate)
|
95
99
|
else
|
96
100
|
add_record('=~ /pattern/', 'match(/pattern/)', accurate)
|
@@ -105,14 +109,14 @@ module Transpec
|
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
108
|
-
def
|
112
|
+
def using_match_array?
|
109
113
|
case arg_node.type
|
110
114
|
when :array
|
111
115
|
true
|
112
116
|
when :regexp
|
113
117
|
false
|
114
118
|
else
|
115
|
-
runtime_data[arg_node, :
|
119
|
+
runtime_data[arg_node, :using_match_array?]
|
116
120
|
end
|
117
121
|
end
|
118
122
|
|
data/lib/transpec/version.rb
CHANGED