From 90e62f1ed06b8426f1b9cd701b8e007a5d7f0523 Mon Sep 17 00:00:00 2001 From: Nathaniel Bibler Date: Mon, 30 Mar 2015 15:31:42 -0400 Subject: [PATCH] Correct several Ruby warnings. This included variable shadowing and unconstrained use of ampersand and asterisk parameter modifiers. --- lib/remockable/active_record/have_default_scope.rb | 9 --------- lib/remockable/active_record/have_index.rb | 6 +++--- lib/remockable/active_record/have_scope.rb | 2 -- .../active_record/accept_nested_attributes_for_spec.rb | 6 +++--- spec/active_record/belong_to_spec.rb | 10 +++++----- spec/active_record/have_and_belong_to_many_spec.rb | 10 +++++----- spec/active_record/have_one_spec.rb | 10 +++++----- spec/support/class_builder.rb | 2 +- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/lib/remockable/active_record/have_default_scope.rb b/lib/remockable/active_record/have_default_scope.rb index 25f9a26..c8b8f7b 100644 --- a/lib/remockable/active_record/have_default_scope.rb +++ b/lib/remockable/active_record/have_default_scope.rb @@ -29,15 +29,6 @@ end def method_missing(method, *args, &block) - unsupported_query_methods = %w( - create_with - eager_load - includes - lock - preload - readonly - ) - query_methods = %w( from group diff --git a/lib/remockable/active_record/have_index.rb b/lib/remockable/active_record/have_index.rb index 3093a40..0003b71 100644 --- a/lib/remockable/active_record/have_index.rb +++ b/lib/remockable/active_record/have_index.rb @@ -12,11 +12,11 @@ def column_names unique = options[:unique] indexes = ActiveRecord::Base.connection.indexes(subject.class.table_name) - index = indexes.detect do |index| + index = indexes.detect do |idx| if column_names.any? - index.columns == column_names + idx.columns == column_names elsif name - matches_name?(index, name) + matches_name?(idx, name) end end diff --git a/lib/remockable/active_record/have_scope.rb b/lib/remockable/active_record/have_scope.rb index d7b9ed6..3cdd300 100644 --- a/lib/remockable/active_record/have_scope.rb +++ b/lib/remockable/active_record/have_scope.rb @@ -32,8 +32,6 @@ end def method_missing(method, *args, &block) - unsupported_query_methods = %w(create_with) - query_methods = %w( eager_load from diff --git a/spec/active_record/accept_nested_attributes_for_spec.rb b/spec/active_record/accept_nested_attributes_for_spec.rb index 0129f63..3c0dd50 100644 --- a/spec/active_record/accept_nested_attributes_for_spec.rb +++ b/spec/active_record/accept_nested_attributes_for_spec.rb @@ -33,12 +33,12 @@ let(:options) { :company } it 'matches if the model accepts the nested attributes' do - model.accepts_nested_attributes_for *options - expect(model).to accept_nested_attributes_for *options + model.accepts_nested_attributes_for(*options) + expect(model).to accept_nested_attributes_for(*options) end it 'does not match if the model does not accept the nested attributes' do - expect(model).to_not accept_nested_attributes_for *options + expect(model).to_not accept_nested_attributes_for(*options) end end diff --git a/spec/active_record/belong_to_spec.rb b/spec/active_record/belong_to_spec.rb index 93a59c2..f3e2fc3 100644 --- a/spec/active_record/belong_to_spec.rb +++ b/spec/active_record/belong_to_spec.rb @@ -28,17 +28,17 @@ let(:options) { :company } it 'matches if the association exists' do - model.belongs_to *options - expect(model).to belong_to *options + model.belongs_to(*options) + expect(model).to belong_to(*options) end it 'does not match if the association does not exist' do - expect(model).to_not belong_to *options + expect(model).to_not belong_to(*options) end it 'does not match if the association is of the wrong type' do - model.has_many *options - expect(model).to_not belong_to *options + model.has_many(*options) + expect(model).to_not belong_to(*options) end end diff --git a/spec/active_record/have_and_belong_to_many_spec.rb b/spec/active_record/have_and_belong_to_many_spec.rb index 651226b..1ba6003 100644 --- a/spec/active_record/have_and_belong_to_many_spec.rb +++ b/spec/active_record/have_and_belong_to_many_spec.rb @@ -29,17 +29,17 @@ let(:options) { :tags } it 'matches if the association exists' do - model.has_and_belongs_to_many *options - expect(model).to have_and_belong_to_many *options + model.has_and_belongs_to_many(*options) + expect(model).to have_and_belong_to_many(*options) end it 'does not match if the association does not exist' do - expect(model).to_not have_and_belong_to_many *options + expect(model).to_not have_and_belong_to_many(*options) end it 'does not match if the association is of the wrong type' do - model.has_many *options - expect(model).to_not have_and_belong_to_many *options + model.has_many(*options) + expect(model).to_not have_and_belong_to_many(*options) end end diff --git a/spec/active_record/have_one_spec.rb b/spec/active_record/have_one_spec.rb index a8193aa..7eda1b3 100644 --- a/spec/active_record/have_one_spec.rb +++ b/spec/active_record/have_one_spec.rb @@ -28,17 +28,17 @@ let(:options) { :address } it 'matches if the association exists' do - model.has_one *options - expect(model).to have_one *options + model.has_one(*options) + expect(model).to have_one(*options) end it 'does not match if the association does not exist' do - expect(model).to_not have_one *options + expect(model).to_not have_one(*options) end it 'does not match if the association is of the wrong type' do - model.has_many *options - expect(model).to_not have_one *options + model.has_many(*options) + expect(model).to_not have_one(*options) end end diff --git a/spec/support/class_builder.rb b/spec/support/class_builder.rb index 1fa9ef1..88c3325 100644 --- a/spec/support/class_builder.rb +++ b/spec/support/class_builder.rb @@ -7,7 +7,7 @@ def self.name end EVAL - class_eval &block if block_given? + class_eval(&block) if block_given? end end