Skip to content

Commit c3fbf50

Browse files
committed
Fix rake test fails with mocha > 2.1.0 #72
Using Mocha::Mock.new is not supported in mocha, and mock() does not work in a subclass. As we just need a stub for File:Statt an no mock, we just create an Object (instead of a mock) and stub it. This commit fixes #72
1 parent 1ef2c90 commit c3fbf50

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/common.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def name
8787
end
8888

8989
def stub!
90-
stat = Mocha::Mock.new('file::stat')
90+
# Stub for File::Stat
91+
stat = Object.new
9192
stat.stubs(size: contents.length, mode: mode, mtime: mtime, atime: atime, directory?: false)
9293

9394
File.stubs(:stat).with(path).returns(stat)
@@ -128,7 +129,8 @@ def directory(name, *args)
128129
def stub!
129130
Dir.stubs(:mkdir).with { |*a| a.first == path }
130131

131-
stat = Mocha::Mock.new('file::stat')
132+
# Stub for File::Stat
133+
stat = Object.new
132134
stat.stubs(size: 1024, mode: mode, mtime: mtime, atime: atime, directory?: true)
133135

134136
File.stubs(:stat).with(path).returns(stat)

0 commit comments

Comments
 (0)