Skip to content

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

License

Notifications You must be signed in to change notification settings

codeodor/minitest-stub_any_instance

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages