Support clearer layout of '.and change(...).to(...)' in RSpec files

This commit is contained in:
Ryan Lue 2019-01-14 12:13:40 +08:00 committed by Thorsten Eckel
parent 0e6a6ff1fd
commit f84408dfc3
4 changed files with 10 additions and 8 deletions

View file

@ -234,8 +234,8 @@ Style/NumericPredicate:
Lint/AmbiguousBlockAssociation:
Description: >-
Checks for ambiguous block association with method when param passed without
parentheses.
Checks for ambiguous block association with method when param
passed without parentheses.
StyleGuide: '#syntax'
Enabled: true
Exclude:
@ -243,6 +243,14 @@ Lint/AmbiguousBlockAssociation:
- "**/*_spec.rb"
- "**/*_examples.rb"
Layout/MultilineMethodCallIndentation:
Description: >-
Checks the indentation of the method name part in method calls
that span more than one line.
EnforcedStyle: indented
Include:
- "**/*_spec.rb"
# Special exceptions
Style/HashSyntax:

View file

@ -77,11 +77,9 @@ RSpec.describe Cache do
Cache.write('123', 'some value')
Cache.write('456', 'some value')
# rubocop:disable Layout/MultilineMethodCallIndentation
expect { Cache.clear }
.to change { Cache.get('123') }.to(nil)
.and change { Cache.get('456') }.to(nil)
# rubocop:enable Layout/MultilineMethodCallIndentation
end
it 'is idempotent' do

View file

@ -9,11 +9,9 @@ RSpec.describe HttpLog do
subject.request[:content] = 'foo'.force_encoding('ascii-8bit')
subject.response[:content] = 'bar'.force_encoding('ascii-8bit')
# rubocop:disable Layout/MultilineMethodCallIndentation
expect { subject.save }
.to change { subject.request[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
.and change { subject.response[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
# rubocop:enable Layout/MultilineMethodCallIndentation
end
end
end

View file

@ -111,11 +111,9 @@ RSpec.describe User do
before { user } # create user
it 'replaces CallerId record' do
# rubocop:disable Layout/MultilineMethodCallIndentation
expect { user.update(phone: new_number) }
.to change { Cti::CallerId.where(caller_id: orig_number).count }.by(-1)
.and change { Cti::CallerId.where(caller_id: new_number).count }.by(1)
# rubocop:enable Layout/MultilineMethodCallIndentation
end
end
end