diff --git a/.rubocop.yml b/.rubocop.yml index 6c393cf7e..184624970 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -111,6 +111,10 @@ Style/ClassVars: - 'spec/mongoid/clients/transactions_spec_models.rb' - 'spec/mongoid/contextual/mongo/documents_loader_spec.rb' +Style/OpenStructUse: + Exclude: + - 'lib/mongoid/indexable.rb' + Style/CaseEquality: Exclude: - 'lib/mongoid/association/embedded/embeds_many/proxy.rb' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8d77ae1b0..c8ebd04c3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -828,13 +828,6 @@ Style/MultilineBlockChain: - 'spec/mongoid/changeable_spec.rb' - 'spec/mongoid/document_spec.rb' -# Offense count: 4 -Style/OpenStructUse: - Exclude: - - 'lib/mongoid/indexable.rb' - - 'spec/rails/controller_extension/controller_runtime_spec.rb' - - 'spec/support/rails_mock.rb' - # Offense count: 17 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? diff --git a/spec/rails/controller_extension/controller_runtime_spec.rb b/spec/rails/controller_extension/controller_runtime_spec.rb index c61435dfa..0244e60f2 100644 --- a/spec/rails/controller_extension/controller_runtime_spec.rb +++ b/spec/rails/controller_extension/controller_runtime_spec.rb @@ -41,6 +41,10 @@ def clear_metric! describe 'Collector' do + before do + stub_const('EventPayload', Struct.new(:duration)) + end + it 'stores the metric in thread-safe manner' do clear_metric! expect(collector.runtime).to eq(0) @@ -50,7 +54,7 @@ def clear_metric! it 'sets metric on both succeeded and failed' do instance = collector.new - event_payload = OpenStruct.new duration: 42 + event_payload = EventPayload.new(42) clear_metric! instance.succeeded event_payload diff --git a/spec/support/rails_mock.rb b/spec/support/rails_mock.rb index 7d4b1248b..9e65b583d 100644 --- a/spec/support/rails_mock.rb +++ b/spec/support/rails_mock.rb @@ -19,11 +19,15 @@ def eager_load!; end end end +ConfigPaths = Struct.new(:expanded) + +AppConfig = Struct.new(:paths) + Rails.env = 'development' Rails.root = Pathname.new('.') Rails.logger = Logger.new($stdout) Rails.application = Rails::Application -Rails.application.config = OpenStruct.new( - paths: { 'app/models' => OpenStruct.new(expanded: ['app/models']) } +Rails.application.config = AppConfig.new( + paths: { 'app/models' => ConfigPaths.new(['app/models']) } )