Skip to content

Commit

Permalink
Fix rake test fails with mocha > 2.1.0 #72
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tibob committed Aug 18, 2024
1 parent 1ef2c90 commit c3fbf50
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def name
end

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

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

stat = Mocha::Mock.new('file::stat')
# Stub for File::Stat
stat = Object.new
stat.stubs(size: 1024, mode: mode, mtime: mtime, atime: atime, directory?: true)

File.stubs(:stat).with(path).returns(stat)
Expand Down

0 comments on commit c3fbf50

Please sign in to comment.