How to stub a method in minitest
In minitest you can stub a method my calling .stub and passing a method name:
class User
def self.all
42
end
end
User.stub(:all, [1, 2, 3]) do
assert_equal [1, 2, 3], User.all
end
In minitest you can stub a method my calling .stub and passing a method name:
class User
def self.all
42
end
end
User.stub(:all, [1, 2, 3]) do
assert_equal [1, 2, 3], User.all
end