File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ def on_send(node)
32
32
end
33
33
end
34
34
35
+ alias on_csend on_send
36
+
35
37
def autocorrect ( node )
36
38
lambda do |corrector |
37
39
corrector . replace (
Original file line number Diff line number Diff line change 14
14
book.update(author: "Alice")
15
15
RUBY
16
16
end
17
+
18
+ context 'when using safe navigation operator' , :ruby23 do
19
+ it 'registers an offense' do
20
+ expect_offense ( <<-RUBY . strip_indent )
21
+ book&.update_attributes(author: "Alice")
22
+ ^^^^^^^^^^^^^^^^^ Use `update` instead of `update_attributes`.
23
+ RUBY
24
+ end
25
+
26
+ it 'is autocorrected' do
27
+ new_source = autocorrect_source (
28
+ 'book&.update_attributes(author: "Alice")'
29
+ )
30
+ expect ( new_source ) . to eq 'book&.update(author: "Alice")'
31
+ end
32
+ end
17
33
end
18
34
19
35
describe '#update_attributes!' do
You can’t perform that action at this time.
0 commit comments