Skip to content

Commit 105d6f1

Browse files
committed
Use Hash#key? instead of Hash#has_key?
1 parent 4a3ee40 commit 105d6f1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/rspec/active_model/mocks/mocks.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def self.param_delimiter; "-"; end
133133
:blank? => false }.merge(stubs)
134134

135135
double("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|
136-
if model_class.method(:===).owner == Module && !stubs.has_key?(:===)
136+
if model_class.method(:===).owner == Module && !stubs.key?(:===)
137137
allow(model_class).to receive(:===).and_wrap_original do |original, other|
138138
m === other || original.call(other)
139139
end
@@ -152,28 +152,28 @@ def self.param_delimiter; "-"; end
152152

153153
msingleton.__send__(:define_method, :is_a?) do |other|
154154
model_class.ancestors.include?(other)
155-
end unless stubs.has_key?(:is_a?)
155+
end unless stubs.key?(:is_a?)
156156

157157
msingleton.__send__(:define_method, :kind_of?) do |other|
158158
model_class.ancestors.include?(other)
159-
end unless stubs.has_key?(:kind_of?)
159+
end unless stubs.key?(:kind_of?)
160160

161161
msingleton.__send__(:define_method, :instance_of?) do |other|
162162
other == model_class
163-
end unless stubs.has_key?(:instance_of?)
163+
end unless stubs.key?(:instance_of?)
164164

165165
msingleton.__send__(:define_method, :__model_class_has_column?) do |method_name|
166166
model_class.respond_to?(:column_names) && model_class.column_names.include?(method_name.to_s)
167167
end
168168

169169
msingleton.__send__(:define_method, :has_attribute?) do |attr_name|
170170
__model_class_has_column?(attr_name)
171-
end unless stubs.has_key?(:has_attribute?)
171+
end unless stubs.key?(:has_attribute?)
172172

173173
msingleton.__send__(:define_method, :respond_to?) do |method_name, *args|
174174
include_private = args.first || false
175175
__model_class_has_column?(method_name) ? true : super(method_name, include_private)
176-
end unless stubs.has_key?(:respond_to?)
176+
end unless stubs.key?(:respond_to?)
177177

178178
msingleton.__send__(:define_method, :method_missing) do |m, *a, &b|
179179
if respond_to?(m)
@@ -185,12 +185,12 @@ def self.param_delimiter; "-"; end
185185

186186
msingleton.__send__(:define_method, :class) do
187187
model_class
188-
end unless stubs.has_key?(:class)
188+
end unless stubs.key?(:class)
189189

190190
mock_param = to_param
191191
msingleton.__send__(:define_method, :to_s) do
192192
"#{model_class.name}_#{mock_param}"
193-
end unless stubs.has_key?(:to_s)
193+
end unless stubs.key?(:to_s)
194194
yield m if block_given?
195195
end
196196
end

0 commit comments

Comments
 (0)