File: test_unit.feature

package info (click to toggle)
ruby-rspec-mocks 2.14.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 868 kB
  • ctags: 725
  • sloc: ruby: 8,227; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Feature: Test::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.

  Scenario: use rspec/mocks with Test::Unit
    Given a file named "rspec_mocks_test.rb" with:
      """ruby
      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."