From f84408dfc32b4219296f0a1e0699d44bf59617c8 Mon Sep 17 00:00:00 2001 From: Ryan Lue Date: Mon, 14 Jan 2019 12:13:40 +0800 Subject: [PATCH] Support clearer layout of '.and change(...).to(...)' in RSpec files --- .rubocop.yml | 12 ++++++++++-- spec/lib/cache_spec.rb | 2 -- spec/models/http_log_spec.rb | 2 -- spec/models/user_spec.rb | 2 -- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6b00d273d..cc625b5b5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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: diff --git a/spec/lib/cache_spec.rb b/spec/lib/cache_spec.rb index e54208ca2..07041c913 100644 --- a/spec/lib/cache_spec.rb +++ b/spec/lib/cache_spec.rb @@ -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 diff --git a/spec/models/http_log_spec.rb b/spec/models/http_log_spec.rb index 3fff8aaa9..a5b82c9a6 100644 --- a/spec/models/http_log_spec.rb +++ b/spec/models/http_log_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 71c01815c..e82221753 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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