To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorTest::Unit integration
rspec-mocks is a stand-alone gem that can be used without the rest of
RSpec. If you like the way Test::Unit (or MiniTest) organizes tests, but
prefer RSpec's approach to mocking/stubbing/doubles etc, you can have both.
The one downside is that failures are reported as errors with MiniTest.
- Scenarios
-
- use rspec/mocks with Test::Unit
-
- Given
-
a file named "rspec_mocks_test.rb" with:
require 'test/unit' require 'rspec/mocks' class RSpecMocksTest < Test::Unit::TestCase def setup RSpec::Mocks.setup(Object) RSpec::Mocks.setup(self) end def test_passing_expectation obj = Object.new expect(obj).to receive(:message) obj.message end def test_failing_expectation obj = Object.new expect(obj).to_not receive(:message) obj.message end def test_with_deprecation_warning obj = Object.new obj.stub(:old_message) { RSpec.deprecate(:old_message, :replacement => :message) } obj.old_message end end
- When
-
I run
ruby rspec_mocks_test.rb
- Then
- the output should contain "3 tests, 0 assertions, 0 failures, 1 errors" or "3 tests, 0 assertions, 1 failures, 0 errors"
- And
- the output should contain "expected: 0 times with any arguments"
- And
- the output should contain "old_message is deprecated. Use message instead."
Last published over 7 years ago by myronmarston.