wamp_client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +464 -0
- data/Rakefile +3 -0
- data/circle.yml +3 -0
- data/lib/wamp_client/auth.rb +18 -0
- data/lib/wamp_client/check.rb +57 -0
- data/lib/wamp_client/connection.rb +194 -0
- data/lib/wamp_client/message.rb +1283 -0
- data/lib/wamp_client/serializer.rb +40 -0
- data/lib/wamp_client/session.rb +776 -0
- data/lib/wamp_client/transport.rb +129 -0
- data/lib/wamp_client/version.rb +3 -0
- data/lib/wamp_client.rb +7 -0
- data/scripts/gen_message.rb +537 -0
- data/spec/auth_spec.rb +18 -0
- data/spec/check_spec.rb +197 -0
- data/spec/message_spec.rb +1478 -0
- data/spec/session_spec.rb +1004 -0
- data/spec/spec_helper.rb +43 -0
- data/tasks/rspec.rake +3 -0
- data/wamp_client.gemspec +29 -0
- metadata +170 -0
data/spec/check_spec.rb
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WampClient::Check do
|
4
|
+
|
5
|
+
class DummyClass
|
6
|
+
include WampClient::Check
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#check_equal' do
|
10
|
+
|
11
|
+
it 'raises exception when value does not equal expected' do
|
12
|
+
expect { DummyClass.check_equal('test', false, true) }.to raise_exception("The 'test' argument must have the value 'false'. Instead the value was 'true'")
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'does not raise exception when value equals expected' do
|
16
|
+
expect { DummyClass.check_equal('test', true, true) }.not_to raise_exception
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#check_gte' do
|
22
|
+
|
23
|
+
it 'raises exception when value is less than expected' do
|
24
|
+
expect { DummyClass.check_gte('test', 3, 2) }.to raise_exception("The 'test' argument must be greater than or equal to '3'. Instead the value was '2'")
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'does not raise exception when value equals expected' do
|
28
|
+
expect { DummyClass.check_gte('test', 3, 3) }.not_to raise_exception
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not raise exception when value is greater than expected' do
|
32
|
+
expect { DummyClass.check_gte('test', 3, 4) }.not_to raise_exception
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#check_nil' do
|
38
|
+
|
39
|
+
it 'raises exception when nil and nil is not allowed' do
|
40
|
+
expect { DummyClass.check_nil('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'does not raise exception when nil and nil is allowed' do
|
44
|
+
expect { DummyClass.check_nil('test', nil, true) }.not_to raise_exception
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not raise exception when not nil and nil is not allowed' do
|
48
|
+
expect { DummyClass.check_nil('test', 'value', false) }.not_to raise_exception
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does not raise exception when not nil and nil is allowed' do
|
52
|
+
expect { DummyClass.check_nil('test', 'value', true) }.not_to raise_exception
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#check_integer' do
|
58
|
+
|
59
|
+
it 'raises exception when nil and nil is not allowed' do
|
60
|
+
expect { DummyClass.check_int('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'does not raise exception when nil and nil is allowed' do
|
64
|
+
expect { DummyClass.check_int('test', nil, true) }.not_to raise_exception
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'raises exception when not an integer' do
|
68
|
+
expect { DummyClass.check_int('test', '1') }.to raise_exception("The 'test' argument must be an integer")
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'does not raise exception when it is an integer' do
|
72
|
+
expect { DummyClass.check_int('test', 1) }.not_to raise_exception
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#check_string' do
|
78
|
+
|
79
|
+
it 'raises exception when nil and nil is not allowed' do
|
80
|
+
expect { DummyClass.check_string('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'does not raise exception when nil and nil is allowed' do
|
84
|
+
expect { DummyClass.check_string('test', nil, true) }.not_to raise_exception
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'raises exception when not an integer' do
|
88
|
+
expect { DummyClass.check_string('test', 1) }.to raise_exception("The 'test' argument must be a string")
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'does not raise exception when it is an integer' do
|
92
|
+
expect { DummyClass.check_string('test', '1') }.not_to raise_exception
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#check_bool' do
|
98
|
+
|
99
|
+
it 'raises exception when nil and nil is not allowed' do
|
100
|
+
expect { DummyClass.check_bool('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'does not raise exception when nil and nil is allowed' do
|
104
|
+
expect { DummyClass.check_bool('test', nil, true) }.not_to raise_exception
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'raises exception when not a boolean' do
|
108
|
+
expect { DummyClass.check_bool('test', 1) }.to raise_exception("The 'test' argument must be a boolean")
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'does not raise exception when it is a boolean' do
|
112
|
+
expect { DummyClass.check_bool('test', true) }.not_to raise_exception
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#check_dict' do
|
118
|
+
|
119
|
+
it 'raises exception when nil and nil is not allowed' do
|
120
|
+
expect { DummyClass.check_dict('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'does not raise exception when nil and nil is allowed' do
|
124
|
+
expect { DummyClass.check_dict('test', nil, true) }.not_to raise_exception
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'raises exception when not a hash' do
|
128
|
+
expect { DummyClass.check_dict('test', 1) }.to raise_exception("The 'test' argument must be a hash")
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'does not raise exception when it is a hash' do
|
132
|
+
expect { DummyClass.check_dict('test', {}) }.not_to raise_exception
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#check_list' do
|
138
|
+
|
139
|
+
it 'raises exception when nil and nil is not allowed' do
|
140
|
+
expect { DummyClass.check_list('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'does not raise exception when nil and nil is allowed' do
|
144
|
+
expect { DummyClass.check_list('test', nil, true) }.not_to raise_exception
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'raises exception when not a hash' do
|
148
|
+
expect { DummyClass.check_list('test', 1) }.to raise_exception("The 'test' argument must be an array")
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'does not raise exception when it is a hash' do
|
152
|
+
expect { DummyClass.check_list('test', []) }.not_to raise_exception
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
describe '#check_id' do
|
158
|
+
|
159
|
+
it 'raises exception when nil and nil is not allowed' do
|
160
|
+
expect { DummyClass.check_id('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'does not raise exception when nil and nil is allowed' do
|
164
|
+
expect { DummyClass.check_id('test', nil, true) }.not_to raise_exception
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'raises exception when not an integer' do
|
168
|
+
expect { DummyClass.check_id('test', '1') }.to raise_exception("The 'test' argument must be an integer")
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'does not raise exception when it is an integer' do
|
172
|
+
expect { DummyClass.check_id('test', 1) }.not_to raise_exception
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '#check_uri' do
|
178
|
+
|
179
|
+
it 'raises exception when nil and nil is not allowed' do
|
180
|
+
expect { DummyClass.check_uri('test', nil, false) }.to raise_exception("The 'test' argument cannot be nil")
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'does not raise exception when nil and nil is allowed' do
|
184
|
+
expect { DummyClass.check_uri('test', nil, true) }.not_to raise_exception
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'raises exception when not an integer' do
|
188
|
+
expect { DummyClass.check_uri('test', 1) }.to raise_exception("The 'test' argument must be a string")
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'does not raise exception when it is an integer' do
|
192
|
+
expect { DummyClass.check_uri('test', '1') }.not_to raise_exception
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|