Skip to content

Commit b615a4d

Browse files
nitishrfloehopper
authored andcommitted
Consistently use instances instance variable in Mockery
Previously we were using a mixture of the instance variable and the Mockery.instance method. Now we initialize the instances instance variable to an empty array on the first call to setup since that should be the first place that references the instance variable.
1 parent 5412d0a commit b615a4d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/mocha/mockery.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ def raise_not_initialized_error
3535

3636
class << self
3737
def instance
38-
instances.last || Null.new
38+
@instances.last || Null.new
3939
end
4040

4141
def setup
42+
@instances ||= []
4243
mockery = new
43-
mockery.logger = instance.logger unless instances.empty?
44+
mockery.logger = instance.logger unless @instances.empty?
4445
@instances.push(mockery)
4546
end
4647

@@ -53,12 +54,6 @@ def teardown
5354
ensure
5455
@instances.pop
5556
end
56-
57-
private
58-
59-
def instances
60-
@instances ||= []
61-
end
6257
end
6358

6459
def named_mock(name)

0 commit comments

Comments
 (0)