Skip to content

Commit ba94dfa

Browse files
committed
stub on the model itself, not a global
1 parent 285b7bd commit ba94dfa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/rspec/active_model/mocks/mocks.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,15 @@ def self.param_delimiter; "-"; end
135135
:blank? => false }.merge(stubs)
136136

137137
double("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|
138-
mock_store_klass = RSpec::ActiveModel::Mocks::Mocks
139138
if model_class.method(:===).owner == Module && !stubs.key?(:===)
140-
allow(mock_store_klass).to receive(:mock_store) do
141-
@mock_store ||= Hash.new { |h, k| h[k] = [] }
139+
allow(model_class).to receive(:__rspec_mocks) do
140+
@__rspec_mocks ||= []
142141
end
143142
allow(model_class).to receive(:===).and_wrap_original do |original, other|
144-
mock_store_klass.mock_store[model_class].any? { |ms| ms === other } || original.call(other)
143+
model_class.__rspec_mocks.include?(other) || original.call(other)
145144
end
146145
end
147-
mock_store_klass.mock_store[model_class] << m if mock_store_klass.respond_to?(:mock_store)
146+
model_class.__rspec_mocks << m if model_class.respond_to?(:__rspec_mocks)
148147
msingleton = class << m; self; end
149148
msingleton.class_eval do
150149
include ActiveModelInstanceMethods

0 commit comments

Comments
 (0)