diff --git a/lib/rspec/active_model/mocks/mocks.rb b/lib/rspec/active_model/mocks/mocks.rb index e99890b..6c42f53 100644 --- a/lib/rspec/active_model/mocks/mocks.rb +++ b/lib/rspec/active_model/mocks/mocks.rb @@ -74,6 +74,8 @@ def association(association_name) end end + # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity + # Creates a test double representing `string_or_model_class` with common # ActiveModel methods stubbed out. Additional methods may be easily # stubbed (via add_stubs) if `stubs` is passed. This is most useful for @@ -194,6 +196,7 @@ def self.param_delimiter; "-"; end yield m if block_given? end end + # rubocop:enable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity module ActiveModelStubExtensions # Stubs `persisted` to return false and `id` to return nil @@ -229,6 +232,8 @@ def connection end end + # rubocop:disable Metrics/AbcSize,Metrics/MethodLength + # Creates an instance of `Model` with `to_param` stubbed using a # generated value that is unique to each object. If `Model` is an # `ActiveRecord` model, it is prohibited from accessing the database. @@ -285,14 +290,17 @@ def stub_model(model_class, stubs={}) yield m if block_given? end end + # rubocop:enable Metrics/AbcSize,Metrics/MethodLength private + # rubocop:disable Style/ClassVars @@model_id = 1000 def next_id @@model_id += 1 end + # rubocop:enable Style/ClassVars end end diff --git a/spec/rspec/active_model/mocks/mock_model_spec.rb b/spec/rspec/active_model/mocks/mock_model_spec.rb index 2177956..1603f6b 100644 --- a/spec/rspec/active_model/mocks/mock_model_spec.rb +++ b/spec/rspec/active_model/mocks/mock_model_spec.rb @@ -470,6 +470,7 @@ def self.===(_other) end describe "ActiveModel Lint tests" do + # rubocop:disable Lint/EmptyExpression,Metrics/BlockNesting begin require 'minitest/assertions' include Minitest::Assertions @@ -525,6 +526,7 @@ def self.===(_other) end end end + # rubocop:enable Lint/EmptyExpression,Metrics/BlockNesting require 'active_model/lint' include ActiveModel::Lint::Tests