File: utilities_spec.rb

package info (click to toggle)
ruby-rspec 3.8.0c0e1m0s0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,640 kB
  • sloc: ruby: 65,844; sh: 807; makefile: 99
file content (40 lines) | stat: -rw-r--r-- 1,071 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
require 'rspec/core/bisect/utilities'

module RSpec::Core
  RSpec.describe Bisect::Notifier do
    class ExampleFormatterClass
      def foo(notification); end
    end

    let(:formatter) { instance_spy(ExampleFormatterClass) }
    let(:notifier) { Bisect::Notifier.new(formatter) }

    it 'publishes events to the wrapped formatter' do
      notifier.publish :foo, :length => 15, :width => 12

      expect(formatter).to have_received(:foo).with(an_object_having_attributes(
        :length => 15, :width => 12
      ))
    end

    it 'does not publish events the formatter does not recognize' do
      expect {
        notifier.publish :unrecognized_event, :length => 15, :width => 12
      }.not_to raise_error
    end
  end

  RSpec.describe Bisect::Channel do
    include RSpec::Support::InSubProcess

    it "supports sending objects from a child process back to the parent" do
      channel = Bisect::Channel.new

      in_sub_process do
        channel.send(:value_from_child)
      end

      expect(channel.receive).to eq :value_from_child
    end
  end
end