bigbluebutton-api-ruby 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.rdoc +8 -0
- data/Gemfile.lock +3 -3
- data/README.rdoc +20 -16
- data/Rakefile +5 -4
- data/bigbluebutton-api-ruby.gemspec +1 -1
- data/examples/config_xml.rb +74 -0
- data/examples/create.rb +29 -0
- data/examples/join_example.rb +0 -8
- data/examples/{overall_0.7_example.rb → overall_example.rb} +0 -0
- data/features/config.yml.example +6 -5
- data/features/create_meetings.feature +1 -10
- data/features/end_meetings.feature +3 -21
- data/features/pre_upload_slides.feature +1 -1
- data/features/recordings.feature +1 -1
- data/features/support/features_helpers.rb +1 -1
- data/lib/bigbluebutton_api.rb +342 -176
- data/lib/bigbluebutton_config_layout.rb +56 -0
- data/lib/bigbluebutton_config_xml.rb +122 -0
- data/lib/bigbluebutton_formatter.rb +12 -6
- data/lib/bigbluebutton_hash_to_xml.rb +35 -0
- data/lib/bigbluebutton_modules.rb +1 -2
- data/spec/bigbluebutton_api_0.81_spec.rb +154 -0
- data/spec/bigbluebutton_api_spec.rb +327 -75
- data/spec/bigbluebutton_config_layout_spec.rb +86 -0
- data/spec/bigbluebutton_config_xml_spec.rb +276 -0
- data/spec/bigbluebutton_formatter_spec.rb +28 -6
- data/spec/{hash_to_xml_spec.rb → bigbluebutton_hash_to_xml_spec.rb} +13 -13
- metadata +16 -10
- data/.rvmrc +0 -6
- data/lib/hash_to_xml.rb +0 -33
- data/spec/bigbluebutton_api_0.8_spec.rb +0 -273
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BigBlueButton::BigBlueButtonConfigLayout do
|
4
|
+
|
5
|
+
let(:default_xml) { # a simplified layouts.xml file
|
6
|
+
"<layouts>
|
7
|
+
<layout name=\"Default\" default=\"true\">
|
8
|
+
<window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
|
9
|
+
</layout>
|
10
|
+
<layout name=\"Video Chat\">
|
11
|
+
<window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
|
12
|
+
</layout>
|
13
|
+
</layouts>"
|
14
|
+
}
|
15
|
+
|
16
|
+
describe "#initialize" do
|
17
|
+
context "with a valid xml" do
|
18
|
+
before {
|
19
|
+
XmlSimple.should_receive(:xml_in)
|
20
|
+
.with(default_xml, { 'ForceArray' => false, 'KeepRoot' => true })
|
21
|
+
.and_return("internal_xml")
|
22
|
+
}
|
23
|
+
subject { BigBlueButton::BigBlueButtonConfigLayout.new(default_xml) }
|
24
|
+
it("creates and stores a correct internal xml") { subject.xml.should eql("internal_xml") }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with an empty string as xml" do
|
28
|
+
it "throws an exception" do
|
29
|
+
expect {
|
30
|
+
BigBlueButton::BigBlueButtonConfigLayout.new("")
|
31
|
+
}.to raise_error(BigBlueButton::BigBlueButtonException)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "throws any exception thrown by XmlSimple" do
|
36
|
+
before {
|
37
|
+
XmlSimple.should_receive(:xml_in) { raise Exception }
|
38
|
+
}
|
39
|
+
it {
|
40
|
+
expect {
|
41
|
+
BigBlueButton::BigBlueButtonConfigLayout.new(default_xml)
|
42
|
+
}.to raise_error(BigBlueButton::BigBlueButtonException)
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#get_available_layouts" do
|
48
|
+
subject { target.get_available_layouts }
|
49
|
+
|
50
|
+
context "returns nil if the xml has no <layouts>" do
|
51
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new("<test></test>") }
|
52
|
+
it { should be_nil }
|
53
|
+
end
|
54
|
+
|
55
|
+
context "returns nil if the xml has no <layouts><layout>" do
|
56
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new("<layouts></layouts>") }
|
57
|
+
it { should be_nil }
|
58
|
+
end
|
59
|
+
|
60
|
+
context "returns the correct available layout names" do
|
61
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new(default_xml) }
|
62
|
+
it { should be_instance_of(Array) }
|
63
|
+
it { subject.count.should be(2) }
|
64
|
+
it { should include("Default") }
|
65
|
+
it { should include("Video Chat") }
|
66
|
+
end
|
67
|
+
|
68
|
+
context "doesn't return duplicated layouts" do
|
69
|
+
let(:layouts_xml) {
|
70
|
+
"<layouts>
|
71
|
+
<layout name=\"Default\" default=\"true\">
|
72
|
+
<window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
|
73
|
+
</layout>
|
74
|
+
<layout name=\"Default\">
|
75
|
+
<window name=\"NotesWindow\" hidden=\"true\" width=\"0.7\" height=\"1\" x=\"0\" y=\"0\" draggable=\"false\" resizable=\"false\"/>
|
76
|
+
</layout>
|
77
|
+
</layouts>"
|
78
|
+
}
|
79
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigLayout.new(layouts_xml) }
|
80
|
+
it { should be_instance_of(Array) }
|
81
|
+
it { subject.count.should be(1) }
|
82
|
+
it { should include("Default") }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,276 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BigBlueButton::BigBlueButtonConfigXml do
|
4
|
+
|
5
|
+
let(:default_xml) { # a simplified config.xml file
|
6
|
+
"<config>
|
7
|
+
<help url=\"http://test-server.org/help.html\"/>
|
8
|
+
<modules>
|
9
|
+
<module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\"
|
10
|
+
uri=\"rtmp://test-server.org/bigbluebutton\"
|
11
|
+
layoutConfig=\"http://test-server.org/client/conf/layout.xml\"
|
12
|
+
enableEdit=\"false\"/>
|
13
|
+
</modules>
|
14
|
+
</config>"
|
15
|
+
}
|
16
|
+
|
17
|
+
let(:complex_xml) {
|
18
|
+
"<config>\
|
19
|
+
<localeversion suppressWarning=\"false\">0.8</localeversion>\
|
20
|
+
<version>4357-2014-02-06</version>\
|
21
|
+
<help url=\"http://test-server.org/help.html\"/>\
|
22
|
+
<javaTest url=\"http://test-server.org/testjava.html\"/>\
|
23
|
+
<modules>
|
24
|
+
<module name=\"ChatModule\" url=\"http://test-server.org/client/ChatModule.swf\"
|
25
|
+
uri=\"rtmp://test-server.org/bigbluebutton\"
|
26
|
+
dependsOn=\"UsersModule\" translationOn=\"false\"
|
27
|
+
translationEnabled=\"false\" privateEnabled=\"true\"
|
28
|
+
position=\"top-right\" baseTabIndex=\"701\"/>
|
29
|
+
<module name=\"UsersModule\" url=\"http://test-server.org/client/UsersModule.swf\"
|
30
|
+
uri=\"rtmp://test-server.org/bigbluebutton\"
|
31
|
+
allowKickUser=\"true\" enableRaiseHand=\"true\"
|
32
|
+
enableSettingsButton=\"true\" baseTabIndex=\"301\"/>
|
33
|
+
<module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\"
|
34
|
+
uri=\"rtmp://test-server.org/bigbluebutton\"
|
35
|
+
layoutConfig=\"http://test-server.org/client/conf/layout.xml\"
|
36
|
+
enableEdit=\"false\"/>
|
37
|
+
</modules>
|
38
|
+
</config>"
|
39
|
+
}
|
40
|
+
|
41
|
+
describe "#initialize" do
|
42
|
+
context "with a valid xml" do
|
43
|
+
before {
|
44
|
+
XmlSimple.should_receive(:xml_in)
|
45
|
+
.with(default_xml, { 'ForceArray' => false, 'KeepRoot' => true })
|
46
|
+
.and_return("response")
|
47
|
+
}
|
48
|
+
subject { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
|
49
|
+
it("creates and stores a correct internal xml") { subject.xml.should eql("response") }
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with an empty string as xml" do
|
53
|
+
it "throws an exception" do
|
54
|
+
expect {
|
55
|
+
BigBlueButton::BigBlueButtonConfigXml.new("")
|
56
|
+
}.to raise_error(BigBlueButton::BigBlueButtonException)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "throws any exception thrown by XmlSimple" do
|
61
|
+
before {
|
62
|
+
XmlSimple.should_receive(:xml_in) { raise Exception }
|
63
|
+
}
|
64
|
+
it {
|
65
|
+
expect {
|
66
|
+
BigBlueButton::BigBlueButtonConfigXml.new(default_xml)
|
67
|
+
}.to raise_error(BigBlueButton::BigBlueButtonException)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#get_attribute" do
|
73
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
|
74
|
+
|
75
|
+
context "searching inside a module" do
|
76
|
+
context "if the xml has no <config>" do
|
77
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
|
78
|
+
subject { target.get_attribute("LayoutModule", "layoutConfig") }
|
79
|
+
it { should be_nil }
|
80
|
+
end
|
81
|
+
|
82
|
+
context "if the xml has no <config><modules>" do
|
83
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config></config>") }
|
84
|
+
subject { target.get_attribute("LayoutModule", "layoutConfig") }
|
85
|
+
it { should be_nil }
|
86
|
+
end
|
87
|
+
|
88
|
+
context "if the xml has no <config><modules><module>" do
|
89
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config><modules></modules></config>") }
|
90
|
+
subject { target.get_attribute("LayoutModule", "layoutConfig") }
|
91
|
+
it { should be_nil }
|
92
|
+
end
|
93
|
+
|
94
|
+
context "if the module and attribute are found" do
|
95
|
+
subject { target.get_attribute("LayoutModule", "layoutConfig") }
|
96
|
+
it { should eql("http://test-server.org/client/conf/layout.xml") }
|
97
|
+
end
|
98
|
+
|
99
|
+
context "if the module is not found" do
|
100
|
+
subject { target.get_attribute("InexistentModule", "layoutConfig") }
|
101
|
+
it { should be_nil }
|
102
|
+
end
|
103
|
+
|
104
|
+
context "if the attribute is not found" do
|
105
|
+
subject { target.get_attribute("LayoutModule", "inexistentAttribute") }
|
106
|
+
it { should be_nil }
|
107
|
+
end
|
108
|
+
|
109
|
+
# just to make sure it won't break in a more complete config.xml
|
110
|
+
context "works with a complex xml" do
|
111
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
|
112
|
+
subject { target.get_attribute("LayoutModule", "layoutConfig") }
|
113
|
+
it { should eql("http://test-server.org/client/conf/layout.xml") }
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "searching outside a module" do
|
118
|
+
context "if the xml has no <config>" do
|
119
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
|
120
|
+
subject { target.get_attribute("help", "url", false) }
|
121
|
+
it { should be_nil }
|
122
|
+
end
|
123
|
+
|
124
|
+
context "if the tag and attribute are found" do
|
125
|
+
subject { target.get_attribute("help", "url", false) }
|
126
|
+
it { should eql("http://test-server.org/help.html") }
|
127
|
+
end
|
128
|
+
|
129
|
+
context "if the tag is not found" do
|
130
|
+
subject { target.get_attribute("inexistent", "url", false) }
|
131
|
+
it { should be_nil }
|
132
|
+
end
|
133
|
+
|
134
|
+
context "if the attribute is not found" do
|
135
|
+
subject { target.get_attribute("help", "inexistent", false) }
|
136
|
+
it { should be_nil }
|
137
|
+
end
|
138
|
+
|
139
|
+
# just to make sure it won't break in a more complete config.xml
|
140
|
+
context "works with a complex xml" do
|
141
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
|
142
|
+
subject { target.get_attribute("help", "url", false) }
|
143
|
+
it { should eql("http://test-server.org/help.html") }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#set_attribute" do
|
149
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
|
150
|
+
|
151
|
+
context "setting an attribute inside a module" do
|
152
|
+
context "if the xml has no <config>" do
|
153
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
|
154
|
+
subject { target.set_attribute("LayoutModule", "layoutConfig", "value") }
|
155
|
+
it { should be_nil }
|
156
|
+
end
|
157
|
+
|
158
|
+
context "if the xml has no <config><modules>" do
|
159
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config></config>") }
|
160
|
+
subject { target.set_attribute("LayoutModule", "layoutConfig", "value") }
|
161
|
+
it { should be_nil }
|
162
|
+
end
|
163
|
+
|
164
|
+
context "if the xml has no <config><modules><module>" do
|
165
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<config><modules></modules></config>") }
|
166
|
+
subject { target.set_attribute("LayoutModule", "layoutConfig", "value") }
|
167
|
+
it { should be_nil }
|
168
|
+
end
|
169
|
+
|
170
|
+
context "if the module and attribute are found" do
|
171
|
+
before(:each) {
|
172
|
+
target.set_attribute("LayoutModule", "layoutConfig", "value").should eql("value")
|
173
|
+
}
|
174
|
+
it { target.get_attribute("LayoutModule", "layoutConfig").should eql("value") }
|
175
|
+
end
|
176
|
+
|
177
|
+
context "if the module is not found" do
|
178
|
+
subject { target.set_attribute("InexistentModule", "layoutConfig", "value") }
|
179
|
+
it { should be_nil }
|
180
|
+
end
|
181
|
+
|
182
|
+
context "if the attribute is not found" do
|
183
|
+
subject { target.set_attribute("LayoutModule", "inexistentAttribute", "value") }
|
184
|
+
it { should be_nil }
|
185
|
+
end
|
186
|
+
|
187
|
+
# just to make sure it won't break in a more complete config.xml
|
188
|
+
context "works with a complex xml" do
|
189
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
|
190
|
+
before(:each) {
|
191
|
+
target.set_attribute("LayoutModule", "layoutConfig", "value").should eql("value")
|
192
|
+
}
|
193
|
+
it { target.get_attribute("LayoutModule", "layoutConfig").should eql("value") }
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "setting an attribute outside of a module" do
|
198
|
+
context "if the xml has no <config>" do
|
199
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new("<any></any>") }
|
200
|
+
subject { target.set_attribute("help", "url", "value", false) }
|
201
|
+
it { should be_nil }
|
202
|
+
end
|
203
|
+
|
204
|
+
context "if the module and attribute are found" do
|
205
|
+
before(:each) {
|
206
|
+
target.set_attribute("help", "url", "value", false).should eql("value")
|
207
|
+
}
|
208
|
+
it { target.get_attribute("help", "url", false).should eql("value") }
|
209
|
+
end
|
210
|
+
|
211
|
+
context "if the module is not found" do
|
212
|
+
subject { target.set_attribute("InexistentModule", "url", "value", false) }
|
213
|
+
it { should be_nil }
|
214
|
+
end
|
215
|
+
|
216
|
+
context "if the attribute is not found" do
|
217
|
+
subject { target.set_attribute("help", "inexistentAttribute", "value", false) }
|
218
|
+
it { should be_nil }
|
219
|
+
end
|
220
|
+
|
221
|
+
# just to make sure it won't break in a more complete config.xml
|
222
|
+
context "works with a complex xml" do
|
223
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
|
224
|
+
before(:each) {
|
225
|
+
target.set_attribute("help", "url", "value", false).should eql("value")
|
226
|
+
}
|
227
|
+
it { target.get_attribute("help", "url", false).should eql("value") }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#as_string" do
|
234
|
+
context "for a simple xml" do
|
235
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
|
236
|
+
subject { target.as_string }
|
237
|
+
it {
|
238
|
+
# it is the same XML as `default_xml`, just formatted slightly differently
|
239
|
+
expected = "<config><help url=\"http://test-server.org/help.html\" /><modules><module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\" uri=\"rtmp://test-server.org/bigbluebutton\" layoutConfig=\"http://test-server.org/client/conf/layout.xml\" enableEdit=\"false\" /></modules></config>"
|
240
|
+
should eql(expected)
|
241
|
+
}
|
242
|
+
end
|
243
|
+
|
244
|
+
context "for a complex xml" do
|
245
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(complex_xml) }
|
246
|
+
subject { target.as_string }
|
247
|
+
it {
|
248
|
+
# it is the same XML as `default_xml`, just formatted slightly differently
|
249
|
+
expected = "<config version=\"4357-2014-02-06\"><localeversion suppressWarning=\"false\">0.8</localeversion><help url=\"http://test-server.org/help.html\" /><javaTest url=\"http://test-server.org/testjava.html\" /><modules><module name=\"ChatModule\" url=\"http://test-server.org/client/ChatModule.swf\" uri=\"rtmp://test-server.org/bigbluebutton\" dependsOn=\"UsersModule\" translationOn=\"false\" translationEnabled=\"false\" privateEnabled=\"true\" position=\"top-right\" baseTabIndex=\"701\" /><module name=\"UsersModule\" url=\"http://test-server.org/client/UsersModule.swf\" uri=\"rtmp://test-server.org/bigbluebutton\" allowKickUser=\"true\" enableRaiseHand=\"true\" enableSettingsButton=\"true\" baseTabIndex=\"301\" /><module name=\"LayoutModule\" url=\"http://test-server.org/client/LayoutModule.swf?v=4357\" uri=\"rtmp://test-server.org/bigbluebutton\" layoutConfig=\"http://test-server.org/client/conf/layout.xml\" enableEdit=\"false\" /></modules></config>"
|
250
|
+
should eql(expected)
|
251
|
+
}
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "#is_modified?" do
|
256
|
+
let(:target) { BigBlueButton::BigBlueButtonConfigXml.new(default_xml) }
|
257
|
+
|
258
|
+
context "before any attribute is set" do
|
259
|
+
it { target.is_modified?.should be_false }
|
260
|
+
end
|
261
|
+
|
262
|
+
context "after setting an attribute" do
|
263
|
+
before(:each) { target.set_attribute("LayoutModule", "layoutConfig", "value") }
|
264
|
+
it { target.is_modified?.should be_true }
|
265
|
+
end
|
266
|
+
|
267
|
+
context "if an attribute is set to the same value it already had" do
|
268
|
+
before(:each) {
|
269
|
+
value = target.get_attribute("LayoutModule", "layoutConfig")
|
270
|
+
target.set_attribute("LayoutModule", "layoutConfig", value)
|
271
|
+
}
|
272
|
+
it { target.is_modified?.should be_false }
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|
@@ -70,10 +70,17 @@ describe BigBlueButton::BigBlueButtonFormatter do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "#to_datetime" do
|
73
|
-
let(:hash) {
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
let(:hash) {
|
74
|
+
{ :param1 => "Thu Sep 01 17:51:42 UTC 2011",
|
75
|
+
:param2 => "Thu Sep 08",
|
76
|
+
:param3 => 1315254777880,
|
77
|
+
:param4 => "1315254777880",
|
78
|
+
:param5 => "0",
|
79
|
+
:param6 => 0,
|
80
|
+
:param7 => "NULL",
|
81
|
+
:param8 => nil
|
82
|
+
}
|
83
|
+
}
|
77
84
|
let(:formatter) { BigBlueButton::BigBlueButtonFormatter.new(hash) }
|
78
85
|
before {
|
79
86
|
formatter.to_datetime(:param1)
|
@@ -201,17 +208,25 @@ describe BigBlueButton::BigBlueButtonFormatter do
|
|
201
208
|
|
202
209
|
describe ".format_meeting" do
|
203
210
|
let(:hash) {
|
204
|
-
{ :meetingID => 123, :moderatorPW => 111, :attendeePW => 222,
|
205
|
-
:hasBeenForciblyEnded => "FALSE", :running => "TRUE", :createTime => "123456789"
|
211
|
+
{ :meetingID => 123, :meetingName => 123, :moderatorPW => 111, :attendeePW => 222,
|
212
|
+
:hasBeenForciblyEnded => "FALSE", :running => "TRUE", :createTime => "123456789",
|
213
|
+
:dialNumber => 1234567890, :voiceBridge => "12345",
|
214
|
+
:participantCount => "10", :listenerCount => "3", :videoCount => "5" }
|
206
215
|
}
|
207
216
|
|
208
217
|
subject { BigBlueButton::BigBlueButtonFormatter.format_meeting(hash) }
|
209
218
|
it { subject[:meetingID].should == "123" }
|
219
|
+
it { subject[:meetingName].should == "123" }
|
210
220
|
it { subject[:moderatorPW].should == "111" }
|
211
221
|
it { subject[:attendeePW].should == "222" }
|
212
222
|
it { subject[:hasBeenForciblyEnded].should == false }
|
213
223
|
it { subject[:running].should == true }
|
214
224
|
it { subject[:createTime].should == 123456789 }
|
225
|
+
it { subject[:voiceBridge].should == 12345 }
|
226
|
+
it { subject[:dialNumber].should == "1234567890" }
|
227
|
+
it { subject[:participantCount].should == 10 }
|
228
|
+
it { subject[:listenerCount].should == 3 }
|
229
|
+
it { subject[:videoCount].should == 5 }
|
215
230
|
end
|
216
231
|
|
217
232
|
describe ".format_attendee" do
|
@@ -282,6 +297,13 @@ describe BigBlueButton::BigBlueButtonFormatter do
|
|
282
297
|
it { subject.should == { :objects => [] } }
|
283
298
|
end
|
284
299
|
|
300
|
+
context "when the target key doesn't exist in the hash" do
|
301
|
+
let(:hash) { { } }
|
302
|
+
before { formatter.hash = hash }
|
303
|
+
subject { formatter.flatten_objects(:objects, :object) }
|
304
|
+
it { subject.should == { :objects => [] } } # adds the one the doesn't exist
|
305
|
+
end
|
306
|
+
|
285
307
|
context "when there's only one object in the list" do
|
286
308
|
let(:object_hash) { { :id => 1 } }
|
287
309
|
let(:hash) { { :objects => { :object => object_hash } } }
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe BigBlueButton::BigBlueButtonHash do
|
4
4
|
|
5
5
|
describe ".from_xml" do
|
6
6
|
it "simple example" do
|
7
7
|
xml = "<response><returncode>1</returncode></response>"
|
8
8
|
hash = { :returncode => "1" }
|
9
|
-
|
9
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
10
10
|
end
|
11
11
|
|
12
12
|
it "maintains all values as strings" do
|
@@ -16,7 +16,7 @@ describe Hash do
|
|
16
16
|
" <node3>true</node3>" \
|
17
17
|
"</parent>"
|
18
18
|
hash = { :node1 => "1", :node2 => "string", :node3 => "true" }
|
19
|
-
|
19
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
20
20
|
end
|
21
21
|
|
22
22
|
it "works for xmls with multiple levels" do
|
@@ -28,7 +28,7 @@ describe Hash do
|
|
28
28
|
" </node1>" \
|
29
29
|
"</parent>"
|
30
30
|
hash = { :node1 => { :node2 => { :node3 => "true" } } }
|
31
|
-
|
31
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
32
32
|
end
|
33
33
|
|
34
34
|
it "transforms CDATA fields to string" do
|
@@ -37,7 +37,7 @@ describe Hash do
|
|
37
37
|
" <course><![CDATA[Advanced Ruby]]></course>" \
|
38
38
|
"</parent>"
|
39
39
|
hash = { :name => "Evening Class", :course => "Advanced Ruby" }
|
40
|
-
|
40
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
41
41
|
end
|
42
42
|
|
43
43
|
it "transforms duplicated keys in arrays" do
|
@@ -51,7 +51,7 @@ describe Hash do
|
|
51
51
|
"</parent>"
|
52
52
|
hash = { :meetings => { :meeting => [ "1", "2", { :details => "3" } ],
|
53
53
|
:other => "4" } }
|
54
|
-
|
54
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
55
55
|
end
|
56
56
|
|
57
57
|
it "works with attributes" do
|
@@ -59,7 +59,7 @@ describe Hash do
|
|
59
59
|
" <meeting attr1=\"v1\">1</meeting>" \
|
60
60
|
"</parent>"
|
61
61
|
hash = { :meeting => { :attr1 => "v1", :content => "1" } }
|
62
|
-
|
62
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
63
63
|
end
|
64
64
|
|
65
65
|
it "complex real example" do
|
@@ -104,7 +104,7 @@ describe Hash do
|
|
104
104
|
} ]
|
105
105
|
}
|
106
106
|
}
|
107
|
-
|
107
|
+
BigBlueButton::BigBlueButtonHash.from_xml(xml).should == hash
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -112,31 +112,31 @@ describe Hash do
|
|
112
112
|
it "converts string-keys to symbols" do
|
113
113
|
before = { "one" => 1, "two" => 2, "three" => 3 }
|
114
114
|
after = { :one => 1, :two => 2, :three => 3 }
|
115
|
-
|
115
|
+
BigBlueButton::BigBlueButtonHash.symbolize_keys(before).should == after
|
116
116
|
end
|
117
117
|
|
118
118
|
it "maintains case" do
|
119
119
|
before = { "One" => 1, "tWo" => 2, "thrEE" => 3 }
|
120
120
|
after = { :One => 1, :tWo => 2, :thrEE => 3 }
|
121
|
-
|
121
|
+
BigBlueButton::BigBlueButtonHash.symbolize_keys(before).should == after
|
122
122
|
end
|
123
123
|
|
124
124
|
it "works with multilevel hashes" do
|
125
125
|
before = { "l1" => { "l2" => { "l3" => 1 } }, "l1b" => 2 }
|
126
126
|
after = { :l1 => { :l2 => { :l3 => 1 } }, :l1b => 2 }
|
127
|
-
|
127
|
+
BigBlueButton::BigBlueButtonHash.symbolize_keys(before).should == after
|
128
128
|
end
|
129
129
|
|
130
130
|
it "works with arrays" do
|
131
131
|
before = { "a1" => [ "b1" => 1, "b2" => 2 ], "b2" => 2 }
|
132
132
|
after = { :a1 => [ :b1 => 1, :b2 => 2 ], :b2 => 2 }
|
133
|
-
|
133
|
+
BigBlueButton::BigBlueButtonHash.symbolize_keys(before).should == after
|
134
134
|
end
|
135
135
|
|
136
136
|
it "doesn't convert values" do
|
137
137
|
before = { "a" => "a", "b" => "b" }
|
138
138
|
after = { :a => "a", :b => "b" }
|
139
|
-
|
139
|
+
BigBlueButton::BigBlueButtonHash.symbolize_keys(before).should == after
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|