No commit activity in last 3 years
No release in over 3 years
Use rspec-mocks with minitest. A description of what this does doesn't get longer than that.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

< 5.99, >= 4.0
< 3.99, >= 2.14
 Project Readme

minitest-rspec_mocks

Build Status

Monkeypatches to have minitest work with rspec-mocks. Note the name changed from minitest_rspec_mocks to minitest-rspec_mocks for consistency with the idea that this is a plugin for minitest.

Use it:

include Minitest::RSpecMocks in whichever test case base classes you want rspec-mocks to be available. For example, if you're in a Rails project that uses minitest and you want rspec-mocks everywhere, you might do:

class ActiveSupport::TestCase
  include Minitest::RSpecMocks
end

class TestSomething < ActiveSupport::TestCase
  def test_it_should_use_rspec_stub
    RSpec::Mocks.configuration.syntax = :should
    string = "hello"
    assert string.to_i == 0
    string.stub(to_i: 100)
    assert string.to_i == 100
  end

  def test_it_should_use_rspec_expect
    RSpec::Mocks.configuration.syntax = :expect
    string = "hello"
    assert string.to_i == 0
    expect(string).to receive(:to_i).and_return 100
    assert string.to_i == 100
  end
end

Note that you must include it in a base class for your tests. Including it in the test class itself will not work.

Note that RSpec 3 deprecates the object.should (where you use object.stub(to_i: 100)) style in favor of using the expect style syntax.

Why?

If you use minitest/autorun, it patches its stub method onto Object. RSpec puts its version on BasicObject so it being further up the ancestor chain, it will rarely be used.

Also there is a little bit of setup / teardown you need to do a la http://myronmars.to/n/dev-blog/2012/07/mixing-and-matching-parts-of-rspec

Install:

gem "minitest-rspec_mocks" in your Gemfile

Run the tests:

git clone this repository, then cd into it and run bundle exec ruby test/minitest/rspec_mocks_test.rb