Low commit activity in last 3 years
No release in over a year
Adds a method to MiniTest that stubs any instance of a class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.11.2
>= 0
 Project Readme

minitest-stub_any_instance

Adds a method to MiniTest that creates a method stub on any instance of a class for the duration of a block.

Build Status

Usage

String.stub_any_instance(:length, 42) do
  assert_equal "hello".length, 42
end

Installation

Run gem install minitest-stub_any_instance from the command prompt. (Ruby 2.3+ is required.)

or

Put gem "minitest-stub_any_instance" in your Gemfile and run bundle install from the command prompt

Then require 'minitest/stub_any_instance' in your minitest_helper.rb or test file.

Credits

Vasiliy Ermolovich (@nashby) gets credit for writing the code as part of a pull request to minitest. I extracted it into a gem.