sdp 0.2.8 → 0.2.9

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.
Files changed (110) hide show
  1. data/ChangeLog.rdoc +13 -0
  2. data/LICENSE.rdoc +1 -1
  3. data/README.rdoc +31 -11
  4. data/Rakefile +3 -10
  5. data/lib/sdp/description.rb +132 -16
  6. data/lib/sdp/parser.rb +4 -4
  7. data/lib/sdp/version.rb +1 -1
  8. data/sdp.gemspec +15 -15
  9. data/spec/integration/builds_descriptions_spec.rb +39 -0
  10. data/spec/integration/coverage/assets/0.7.1/application.css +1110 -0
  11. data/spec/integration/coverage/assets/0.7.1/application.js +626 -0
  12. data/spec/integration/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  13. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  14. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  15. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  16. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  17. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  18. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  19. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  20. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  21. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  22. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  23. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  24. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  25. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  26. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  27. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  28. data/spec/integration/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  29. data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  30. data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  31. data/spec/integration/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  32. data/spec/integration/coverage/assets/0.7.1/favicon_green.png +0 -0
  33. data/spec/integration/coverage/assets/0.7.1/favicon_red.png +0 -0
  34. data/spec/integration/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  35. data/spec/integration/coverage/assets/0.7.1/loading.gif +0 -0
  36. data/spec/integration/coverage/assets/0.7.1/magnify.png +0 -0
  37. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  38. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  39. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  40. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  41. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  42. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  43. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  44. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  45. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  46. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  47. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  48. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  49. data/spec/integration/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  50. data/spec/integration/coverage/index.html +72 -0
  51. data/spec/integration/parses_descriptions_spec.rb +129 -0
  52. data/spec/spec_helper.rb +2 -1
  53. data/spec/support/parser_matcher.rb +33 -0
  54. data/{features → spec}/support/sdp_file.txt +0 -0
  55. data/spec/support/test_descriptions.rb +137 -0
  56. data/spec/unit/sdp/coverage/assets/0.7.1/application.css +1110 -0
  57. data/spec/unit/sdp/coverage/assets/0.7.1/application.js +626 -0
  58. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  59. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  60. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  61. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  62. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  63. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  64. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  65. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  66. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  67. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  68. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  69. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  70. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  71. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  72. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  73. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  74. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  75. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  76. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  77. data/spec/unit/sdp/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  78. data/spec/unit/sdp/coverage/assets/0.7.1/favicon_green.png +0 -0
  79. data/spec/unit/sdp/coverage/assets/0.7.1/favicon_red.png +0 -0
  80. data/spec/unit/sdp/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  81. data/spec/unit/sdp/coverage/assets/0.7.1/loading.gif +0 -0
  82. data/spec/unit/sdp/coverage/assets/0.7.1/magnify.png +0 -0
  83. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  84. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  85. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  86. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  87. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  88. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  89. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  90. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  91. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  92. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  93. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  94. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  95. data/spec/unit/sdp/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  96. data/spec/unit/sdp/coverage/index.html +72 -0
  97. data/spec/unit/sdp/description_spec.rb +321 -0
  98. data/spec/unit/sdp/parser_spec.rb +154 -0
  99. data/spec/{sdp_spec.rb → unit/sdp_spec.rb} +2 -2
  100. metadata +189 -43
  101. data/features/accepts_description_text.feature +0 -12
  102. data/features/sdp_create.feature +0 -15
  103. data/features/sdp_get.feature +0 -37
  104. data/features/step_definitions/accepts_description_text_steps.rb +0 -15
  105. data/features/step_definitions/sdp_create_steps.rb +0 -48
  106. data/features/step_definitions/sdp_get_steps.rb +0 -23
  107. data/features/support/env.rb +0 -3
  108. data/lib/sdp/session_template.erb +0 -46
  109. data/spec/sdp/description_spec.rb +0 -392
  110. data/spec/sdp/parser_spec.rb +0 -207
@@ -0,0 +1,72 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Code coverage for Sdp</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <script src='./assets/0.7.1/application.js' type='text/javascript'></script>
7
+ <link href='./assets/0.7.1/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
8
+ <link rel="shortcut icon" type="image/png" href="./assets/0.7.1/favicon_green.png" />
9
+ <link rel="icon" type="image/png" href="./assets/0.7.1/favicon.png" />
10
+ </head>
11
+
12
+ <body>
13
+ <div id="loading">
14
+ <img src="./assets/0.7.1/loading.gif" alt="loading"/>
15
+ </div>
16
+ <div id="wrapper" style="display:none;">
17
+ <div class="timestamp">Generated <abbr class="timeago" title="2012-11-19T16:44:35-08:00">2012-11-19T16:44:35-08:00</abbr></div>
18
+ <ul class="group_tabs"></ul>
19
+
20
+ <div id="content">
21
+ <div class="file_list_container" id="AllFiles">
22
+ <h2>
23
+ <span class="group_name">All Files</span>
24
+ (<span class="covered_percent"><span class="green">100.0%</span></span>
25
+ covered at
26
+ <span class="covered_strength">
27
+ <span class="red">
28
+ 0.0
29
+ </span>
30
+ </span> hits/line)
31
+ </h2>
32
+ <a name="AllFiles"></a>
33
+ <div>
34
+ <b>0</b> files in total.
35
+ <b>0.0</b> relevant lines.
36
+ <span class="green"><b>0.0</b> lines covered</span> and
37
+ <span class="red"><b>0.0</b> lines missed </span>
38
+ </div>
39
+ <table class="file_list">
40
+ <thead>
41
+ <tr>
42
+ <th>File</th>
43
+ <th>% covered</th>
44
+ <th>Lines</th>
45
+ <th>Relevant Lines</th>
46
+ <th>Lines covered</th>
47
+ <th>Lines missed</th>
48
+ <th>Avg. Hits / Line</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+
53
+ </tbody>
54
+ </table>
55
+ </div>
56
+
57
+
58
+
59
+ </div>
60
+
61
+ <div id="footer">
62
+ Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.7.1
63
+ and simplecov-html v0.7.1<br/>
64
+ using RSpec
65
+ </div>
66
+
67
+ <div class="source_files">
68
+
69
+ </div>
70
+ </div>
71
+ </body>
72
+ </html>
@@ -0,0 +1,321 @@
1
+ require 'spec_helper'
2
+ require 'sdp'
3
+ require 'sdp/description'
4
+ require 'base64'
5
+
6
+ describe SDP::Description do
7
+ describe "#initialize" do
8
+ it "protocol_version value set" do
9
+ subject.protocol_version.should == SDP::PROTOCOL_VERSION
10
+ end
11
+ end
12
+
13
+ describe "getter/setter methods with basic values" do
14
+ {
15
+ :protocol_version => 1,
16
+ :username => "jdoe",
17
+ :id => 2890844526,
18
+ :version => 2890842807,
19
+ :network_type => :IN,
20
+ :address_type => :IP4,
21
+ :unicast_address => "10.47.16.5",
22
+ :name => "This is a session",
23
+ :information => "This is a session",
24
+ :uri => "http://localhost",
25
+ :email_address => "me@me.com",
26
+ :phone_number => "+1 555 123 4567",
27
+ :connection_network_type => "IN",
28
+ :connection_address_type => "IP4",
29
+ :connection_address => 'localhost',
30
+ :bandwidth_type => :CT,
31
+ :bandwidth => 100,
32
+ :start_time => 99112299,
33
+ :stop_time => 99999999,
34
+ :repeat_interval => 12345,
35
+ :active_duration => 12345,
36
+ :offsets_from_start_time => 99,
37
+ }.each do |k, v|
38
+ describe "##{k}=" do
39
+ specify {
40
+ subject.send("#{k}=".to_sym, v)
41
+ subject.send("#{k}".to_sym).should == v
42
+ }
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "#name=" do
48
+ it "can be a ' '" do
49
+ subject.name = " "
50
+ subject.name.should == " "
51
+ end
52
+ end
53
+
54
+ describe "#email_address" do
55
+ it "in alternate form" do
56
+ subject.email_address = "Jane Doe <j.doe@example.com>"
57
+ subject.email_address.should == "Jane Doe <j.doe@example.com>"
58
+ end
59
+ end
60
+
61
+ describe "#connection_address=" do
62
+ context "using TTL" do
63
+ specify {
64
+ subject.connection_address = "224.2.36.42/127"
65
+ subject.connection_address.should == "224.2.36.42/127"
66
+ }
67
+ end
68
+
69
+ context "using IPv6 address and count" do
70
+ specify {
71
+ subject.connection_address = "FF15::101/3"
72
+ subject.connection_address.should == "FF15::101/3"
73
+ }
74
+ end
75
+ end
76
+
77
+ describe "#time_zones" do
78
+ it "one time zone" do
79
+ new_values = { :adjustment_time => 111111,
80
+ :offset => 99 }
81
+ subject.time_zones << new_values
82
+ subject.time_zones.should == [new_values]
83
+ end
84
+
85
+ it "two time_zones" do
86
+ new_values1 = { :adjustment_time => 111111,
87
+ :offset => 99 }
88
+ new_values2 = { :adjustment_time => 222222,
89
+ :offset => 88 }
90
+ subject.time_zones << new_values1
91
+ subject.time_zones << new_values2
92
+ subject.time_zones.should == [new_values1, new_values2]
93
+ end
94
+ end
95
+
96
+ describe "#encryption_keys" do
97
+ context "encryption_method = clear" do
98
+ specify {
99
+ subject.encryption_method = 'clear'
100
+ subject.encryption_method.should == 'clear'
101
+ subject.encryption_key = 'password'
102
+ subject.encryption_key.should == 'password'
103
+ }
104
+ end
105
+
106
+ context "encryption_method = base64" do
107
+ specify {
108
+ subject.encryption_method = 'base64'
109
+ subject.encryption_method.should == 'base64'
110
+ enc = Base64.encode64('password')
111
+ subject.encryption_key = enc
112
+ subject.encryption_key.should == enc
113
+ }
114
+ end
115
+
116
+ context "encryption_method = uri" do
117
+ specify {
118
+ subject.encryption_method = 'uri'
119
+ subject.encryption_method.should == 'uri'
120
+ uri = "http://aserver.com/thing.pdf"
121
+ subject.encryption_key = uri
122
+ subject.encryption_key.should == uri
123
+ }
124
+ end
125
+
126
+ context "encryption_method = prompt" do
127
+ specify {
128
+ subject.encryption_method = 'prompt'
129
+ subject.encryption_method.should == 'prompt'
130
+ subject.encryption_key.should be_nil
131
+ }
132
+ end
133
+ end
134
+
135
+ describe "#attributes" do
136
+ context "one attribute with value" do
137
+ specify {
138
+ new_values = { :attribute => 'rtpmap',
139
+ :value => "99 h263-1998/90000" }
140
+ subject.attributes << new_values
141
+ subject.attributes.first.should == new_values
142
+ }
143
+ end
144
+
145
+ context "one attribute with empty value" do
146
+ specify {
147
+ new_values = { :attribute => 'rtpmap',
148
+ :value => "" }
149
+ subject.attributes << new_values
150
+ subject.attributes.first.should == new_values
151
+ }
152
+ end
153
+
154
+ context "one attribute with nil value" do
155
+ specify {
156
+ new_values = { :attribute => 'rtpmap' }
157
+ subject.attributes << new_values
158
+ subject.attributes.first.should == new_values
159
+ }
160
+ end
161
+
162
+ context "two attributes" do
163
+ specify {
164
+ new_values1 = { :attribute => 'test' }
165
+ new_values2 = { :attribute => 'rtpmap',
166
+ :value => "99 h263-1998/90000" }
167
+ subject.attributes << new_values1
168
+ subject.attributes << new_values2
169
+ subject.attributes.should == [new_values1, new_values2]
170
+ }
171
+ end
172
+ end
173
+
174
+ describe "#media_sections" do
175
+ it "can add a basic media section" do
176
+ new_values = { :media => 'audio',
177
+ :port => 12345,
178
+ :protocol => 'RTP/AVP',
179
+ :format => 99 }
180
+ subject.media_sections << new_values
181
+ subject.media_sections.first.should == new_values
182
+ end
183
+
184
+ it "can add a basic media section with attributes" do
185
+ new_values = { :media => 'audio',
186
+ :port => 12345,
187
+ :protocol => 'RTP/AVP',
188
+ :format => 99,
189
+ :attributes => [
190
+ {
191
+ :attribute => "rtpmap",
192
+ :value => "99 h263-1998/90000"
193
+ }
194
+ ]
195
+ }
196
+ subject.media_sections << new_values
197
+ subject.media_sections.first.should == new_values
198
+ end
199
+
200
+ it "can add 2 basic media sections" do
201
+ new_values = []
202
+ new_values << { :media => 'audio',
203
+ :port => 12345,
204
+ :protocol => 'RTP/AVP',
205
+ :format => 99 }
206
+ subject.media_sections << new_values[0]
207
+
208
+ new_values << { :media => 'video',
209
+ :port => 5678,
210
+ :protocol => 'RTP/AVP',
211
+ :format => 33 }
212
+ subject.media_sections << new_values[1]
213
+
214
+ subject.media_sections.class.should == Array
215
+ subject.media_sections[0].should == new_values[0]
216
+ subject.media_sections[1].should == new_values[1]
217
+ end
218
+ end
219
+
220
+ context "#to_s" do
221
+ it "contains required session section values" do
222
+ subject.to_s.should match /v=0/
223
+ subject.to_s.should match /o=/
224
+ subject.to_s.should match /s=/
225
+ subject.to_s.should match /t=/
226
+ end
227
+
228
+ it "ends each line with \r\n" do
229
+ subject.to_s.each_line do |l|
230
+ l.should match /\r\n$/
231
+ end
232
+ end
233
+
234
+ it "handles descriptions with no time zone" do
235
+ sdp = SDP.parse(SDP_MISSING_TIME)
236
+ expect { sdp.to_s }.to_not raise_error
237
+ end
238
+ end
239
+
240
+ describe "#valid?" do
241
+ before do
242
+ subject.protocol_version = 0
243
+ subject.username = "jdoe"
244
+ subject.id = 12345
245
+ subject.version = 12345
246
+ subject.network_type = :IN
247
+ subject.address_type = :IP4
248
+ subject.unicast_address = "127.0.0.1"
249
+ subject.connection_network_type = :IN
250
+ subject.connection_address_type = :IP4
251
+ subject.connection_address = "127.0.0.1"
252
+ subject.name = "This is a test"
253
+ subject.start_time = 12345678
254
+ subject.stop_time = 12345680
255
+ end
256
+
257
+ context "all required fields set" do
258
+ specify { subject.should be_a_valid_description }
259
+ end
260
+
261
+ %w[protocol_version username id version network_type address_type
262
+ unicast_address name start_time stop_time].each do |value|
263
+ context "#{value} isn't set" do
264
+ before { subject.send("#{value}=".to_sym, nil) }
265
+ specify { subject.should_not be_a_valid_description }
266
+ end
267
+ end
268
+
269
+ context "name is ' '" do
270
+ before { subject.name = ' ' }
271
+ specify { subject.should be_a_valid_description }
272
+ end
273
+
274
+ context "media_sections is empty" do
275
+ before { subject[:media_sections] = [] }
276
+ specify { subject.should be_a_valid_description }
277
+ end
278
+ end
279
+
280
+ describe "#has_session_connection_fields?" do
281
+ context "connection fields in session section" do
282
+ before do
283
+ subject.connection_network_type = "IN"
284
+ subject.connection_address_type = "IP4"
285
+ subject.connection_address = "0.0.0.0"
286
+ end
287
+
288
+ specify do
289
+ subject.send(:has_session_connection_fields?).should be_true
290
+ end
291
+ end
292
+
293
+ context "no connection fields in session section" do
294
+ before do
295
+ subject.connection_network_type = nil
296
+ subject.connection_address_type = nil
297
+ subject.connection_address = nil
298
+ end
299
+
300
+ specify do
301
+ subject.send(:has_session_connection_fields?).should be_false
302
+ end
303
+ end
304
+ end
305
+
306
+ context "bad initialize values" do
307
+ it "ensures a Hash is passed in" do
308
+ expect {
309
+ SDP::Description.new 1
310
+ }.to raise_error SDP::RuntimeError
311
+ end
312
+
313
+ it "handles a Hash with irrelvant keys" do
314
+ session_values = { :bobo => "thing" }
315
+
316
+ expect {
317
+ SDP::Description.new session_values
318
+ }.to raise_error SDP::RuntimeError
319
+ end
320
+ end
321
+ end