diff options
Diffstat (limited to 'spec/rubocop/cop/performance')
5 files changed, 9 insertions, 19 deletions
diff --git a/spec/rubocop/cop/performance/active_record_subtransaction_methods_spec.rb b/spec/rubocop/cop/performance/active_record_subtransaction_methods_spec.rb index df18121e2df..ac58ca1edf3 100644 --- a/spec/rubocop/cop/performance/active_record_subtransaction_methods_spec.rb +++ b/spec/rubocop/cop/performance/active_record_subtransaction_methods_spec.rb @@ -1,13 +1,11 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require 'rspec-parameterized' require_relative '../../../../rubocop/cop/performance/active_record_subtransaction_methods' RSpec.describe RuboCop::Cop::Performance::ActiveRecordSubtransactionMethods do - subject(:cop) { described_class.new } - let(:message) { described_class::MSG } shared_examples 'a method that uses a subtransaction' do |method_name| diff --git a/spec/rubocop/cop/performance/active_record_subtransactions_spec.rb b/spec/rubocop/cop/performance/active_record_subtransactions_spec.rb index 0da2e30062a..e839a3e9367 100644 --- a/spec/rubocop/cop/performance/active_record_subtransactions_spec.rb +++ b/spec/rubocop/cop/performance/active_record_subtransactions_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/performance/active_record_subtransactions' RSpec.describe RuboCop::Cop::Performance::ActiveRecordSubtransactions do - subject(:cop) { described_class.new } - let(:message) { described_class::MSG } context 'when calling #transaction with only requires_new: true' do diff --git a/spec/rubocop/cop/performance/ar_count_each_spec.rb b/spec/rubocop/cop/performance/ar_count_each_spec.rb index 4aeb9e13b18..a86b3f2b983 100644 --- a/spec/rubocop/cop/performance/ar_count_each_spec.rb +++ b/spec/rubocop/cop/performance/ar_count_each_spec.rb @@ -1,14 +1,12 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/performance/ar_count_each' RSpec.describe RuboCop::Cop::Performance::ARCountEach do - subject(:cop) { described_class.new } - context 'when it is not haml file' do it 'does not flag it as an offense' do - expect(subject).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(false) + expect(cop).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(false) expect_no_offenses <<~SOURCE show(@users.count) @@ -19,7 +17,7 @@ RSpec.describe RuboCop::Cop::Performance::ARCountEach do context 'when it is haml file' do before do - expect(subject).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(true) + expect(cop).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(true) end context 'when the same object uses count and each' do diff --git a/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb b/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb index e95220756ed..070e792eeec 100644 --- a/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb +++ b/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb @@ -1,14 +1,12 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/performance/ar_exists_and_present_blank' RSpec.describe RuboCop::Cop::Performance::ARExistsAndPresentBlank do - subject(:cop) { described_class.new } - context 'when it is not haml file' do it 'does not flag it as an offense' do - expect(subject).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(false) + expect(cop).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(false) expect_no_offenses <<~SOURCE return unless @users.exists? @@ -19,7 +17,7 @@ RSpec.describe RuboCop::Cop::Performance::ARExistsAndPresentBlank do context 'when it is haml file' do before do - expect(subject).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(true) + expect(cop).to receive(:in_haml_file?).with(anything).at_least(:once).and_return(true) end context 'the same object uses exists? and present?' do diff --git a/spec/rubocop/cop/performance/readlines_each_spec.rb b/spec/rubocop/cop/performance/readlines_each_spec.rb index 0a8b168ce5d..d876cbf79a5 100644 --- a/spec/rubocop/cop/performance/readlines_each_spec.rb +++ b/spec/rubocop/cop/performance/readlines_each_spec.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require 'fast_spec_helper' +require 'rubocop_spec_helper' require_relative '../../../../rubocop/cop/performance/readlines_each' RSpec.describe RuboCop::Cop::Performance::ReadlinesEach do - subject(:cop) { described_class.new } - let(:message) { 'Avoid `IO.readlines.each`, since it reads contents into memory in full. Use `IO.each_line` or `IO.each` instead.' } shared_examples_for(:class_read) do |klass| |