File: base.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 (45 lines) | stat: -rw-r--r-- 1,089 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
require 'set'

module AdapterTests
  module Base
    private

    def assert_stubs_work
      subject = Object.new
      stub(subject).foobar { :baz }
      assert_equal :baz, subject.foobar("any", "thing")
    end

    def assert_mocks_work
      subject = Object.new
      mock(subject).foobar(1, 2) { :baz }
      assert_equal :baz, subject.foobar(1, 2)
    end

    def assert_stub_proxies_work
      subject = Object.new
      def subject.foobar; :baz; end
      stub.proxy(subject).foobar
      assert_equal :baz, subject.foobar
    end

    def assert_mock_proxies_work
      subject = Object.new
      def subject.foobar; :baz; end
      mock.proxy(subject).foobar
      assert_equal :baz, subject.foobar
    end

    def assert_times_called_verifications_work
      subject = Object.new
      mock(subject).foobar(1, 2) { :baz }
      assert_raises RR::Errors.error_class(:TimesCalledError) do
        RR.verify
      end
    end

    def assert_adapters_loaded(matching_adapters)
      assert_subset Set.new(matching_adapters), Set.new(RR.loaded_adapter_names)
    end
  end
end