Does Minitest Have A Version Of RSpec's Anything?
minitest, ruby
Solution
Minitest, since it's included to Ruby 1.9, provides `MiniTest::Spec`, a contextual RSpec like syntax. It's not RSpec.
From the Github Page, this is what Minitest provides
- minitest/autorun - the easy and explicit way to run all your tests.
- minitest/unit - a very fast, simple, and clean test system.
- minitest/spec - a very fast, simple, and clean spec system.
- minitest/mock - a simple and clean mock/stub system.
- minitest/benchmark - an awesome way to assert your algorithm's performance.
- minitest/pride - show your pride in testing!
- Incredibly small and fast runner, but no bells and whistles.
To do the same than `mock_obj.should_receive(:method).with(anything)`, you'll write
require 'minitest/autorun'
describe YourClass do
it 'should receive a call to method' do
mock_obj = Minitest::Mock.new
mock_obj.expect(:method, :your_return, [anything])
# ...
mock_obj.verify # verify that the expected call has been made
end
end
Problem
In RSpec I can do `mock_obj.should_receive(:method).with(anything)...` where 'anything' is any variable. Can I do this in Minitest?