-
Notifications
You must be signed in to change notification settings - Fork 0
/
payload_spec.rb
44 lines (38 loc) · 896 Bytes
/
payload_spec.rb
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
# frozen_string_literal: true
module ExcADG
class AnyPayload
include Payload
end
class WithArgsSanitizer < AnyPayload
def sanitize _args
:some
end
end
class CorrectPayload < WithArgsSanitizer
def get
-> { :some }
end
end
describe AnyPayload do
it 'should be of a kind' do
expect(subject).to be_a Payload
end
it 'has args set to nil' do
expect(subject.instance_variable_get(:@args)).to be_nil
end
end
describe WithArgsSanitizer do
it 'has arguments sanitized' do
expect(subject.instance_variable_get(:@args)).to eq :some
end
it 'errors-out on get attempt' do
expect { subject.get }.to raise_error Payload::NoPayloadSet
end
end
describe CorrectPayload do
it 'returns lambda' do
expect(subject.get).to be_a Proc
expect(subject.get.call).to eq :some
end
end
end