File: events_spec.rb

package info (click to toggle)
ruby-wisper 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 276 kB
  • sloc: ruby: 1,231; makefile: 4
file content (107 lines) | stat: -rw-r--r-- 2,610 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
describe Wisper::ValueObjects::Events do
  context 'nil' do
    subject { described_class.new nil }

    describe '#include?' do
      it 'returns true' do
        expect(subject.include? 'foo').to be_truthy
        expect(subject.include? :bar).to be_truthy
      end
    end
  end

  context '"foo"' do
    let(:foo) { Class.new(String).new 'foo' }
    subject   { described_class.new foo }

    describe '#include?' do
      it 'returns true for "foo"' do
        expect(subject.include? 'foo').to be_truthy
      end

      it 'returns true for :foo' do
        expect(subject.include? :foo).to be_truthy
      end

      it 'returns false otherwise' do
        expect(subject.include? 'bar').to be_falsey
        expect(subject.include? :bar).to be_falsey
      end
    end
  end

  context ':foo' do
    subject { described_class.new :foo }

    describe '#include?' do
      it 'returns true for "foo"' do
        expect(subject.include? 'foo').to be_truthy
      end

      it 'returns true for :foo' do
        expect(subject.include? :foo).to be_truthy
      end

      it 'returns false otherwise' do
        expect(subject.include? 'bar').to be_falsey
        expect(subject.include? :bar).to be_falsey
      end
    end
  end

  context '[:foo, "bar"]' do
    subject { described_class.new [:foo, 'bar'] }

    describe '#include?' do
      it 'returns true for "foo"' do
        expect(subject.include? 'foo').to be_truthy
      end

      it 'returns true for :foo' do
        expect(subject.include? :foo).to be_truthy
      end

      it 'returns true for "bar"' do
        expect(subject.include? 'bar').to be_truthy
      end

      it 'returns true for :bar' do
        expect(subject.include? :bar).to be_truthy
      end

      it 'returns false otherwise' do
        expect(subject.include? 'baz').to be_falsey
        expect(subject.include? :baz).to be_falsey
      end
    end
  end

  context 'by /foo/' do
    subject { described_class.new(/foo/) }

    describe '#include?' do
      it 'returns true for "foo"' do
        expect(subject.include? 'foo').to be_truthy
      end

      it 'returns true for :foo' do
        expect(subject.include? :foo).to be_truthy
      end

      it 'returns false otherwise' do
        expect(subject.include? 'bar').to be_falsey
        expect(subject.include? :bar).to be_falsey
      end
    end
  end

  context 'another class' do
    subject { described_class.new Object.new }

    describe '#include?' do
      it 'raises ArgumentError' do
        expect { subject.include? 'foo' }.to raise_error(ArgumentError)
      end
    end
  end
end