File: test_unit.rb

package info (click to toggle)
ruby-rr 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,424 kB
  • sloc: ruby: 11,405; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,105 bytes parent folder | download | duplicates (6)
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
44
45
46
47
require File.expand_path('../base', __FILE__)

module AdapterTests
  module TestUnit
    include Base

    def test_that_stubs_work
      assert_stubs_work
    end

    def test_that_mocks_work
      assert_mocks_work
    end

    def test_that_stub_proxies_work
      assert_stub_proxies_work
    end

    def test_that_mock_proxies_work
      assert_mock_proxies_work
    end

    def test_that_times_called_verifications_work
      assert_times_called_verifications_work
    end

    def test_using_assert_received
      subject = Object.new
      stub(subject).foobar(1, 2)
      subject.foobar(1, 2)
      assert_received(subject) {|s| s.foobar(1, 2) }

      error_class = RR::Errors.error_class(
        RR::Errors::SpyVerificationErrors::InvocationCountError
      )
      assert_raises(error_class) do
        assert_received(subject) {|s| s.foobar(1, 2, 3) }
      end
    end

    def assert_subset(subset, set)
      value = (subset - set).empty?
      message = "Set 1 was not a subset of set 2.\nSet 1: #{subset.inspect}\nSet 2: #{set.inspect}"
      assert value, message
    end
  end
end