sippy_cup 0.2.3 → 0.3.0

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.
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe SippyCup::XMLScenario do
4
+ include FakeFS::SpecHelpers
5
+
6
+ before do
7
+ Dir.mkdir("/tmp") unless Dir.exist?("/tmp")
8
+ Dir.chdir "/tmp"
9
+ end
10
+
11
+ let(:default_args) { {source: '127.0.0.1:5060', destination: '10.0.0.1:5080'} }
12
+ let(:args) { {} }
13
+
14
+ let(:xml) do
15
+ <<-XML
16
+ <?xml version="1.0"?>
17
+ <scenario name="Test">
18
+ <send retrans="500">
19
+ <![CDATA[
20
+ INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
21
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
22
+ From: "sipp" <sip:sipp@[local_ip]>;tag=[call_number]
23
+ To: <sip:[service]@[remote_ip]:[remote_port]>
24
+ Call-ID: [call_id]
25
+ CSeq: [cseq] INVITE
26
+ Contact: <sip:sipp@[local_ip]:[local_port];transport=[transport]>
27
+ Max-Forwards: 100
28
+ User-Agent: SIPp/sippy_cup
29
+ Content-Type: application/sdp
30
+ Content-Length: [len]
31
+
32
+ v=0
33
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
34
+ s=-
35
+ c=IN IP[media_ip_type] [media_ip]
36
+ t=0 0
37
+ m=audio [media_port] RTP/AVP 0 101
38
+ a=rtpmap:0 PCMU/8000
39
+ a=rtpmap:101 telephone-event/8000
40
+ a=fmtp:101 0-15
41
+ ]]>
42
+ </send>
43
+ </scenario>
44
+ XML
45
+ end
46
+ let(:media) do
47
+ FakeFS.deactivate!
48
+ media = File.read(File.expand_path('dtmf_2833_1.pcap', File.join(File.dirname(__FILE__), '..', 'fixtures')), mode: 'rb')
49
+ FakeFS.activate!
50
+ media
51
+ end
52
+
53
+ subject(:scenario) { described_class.new 'Test', xml, media, default_args.merge(args) }
54
+
55
+ describe "#to_xml" do
56
+ it "should return the XML representation of the scenario" do
57
+ subject.to_xml.should == xml
58
+ end
59
+ end
60
+
61
+ describe "#to_tmpfiles" do
62
+ it "writes the scenario XML to a Tempfile and returns it" do
63
+ files = scenario.to_tmpfiles
64
+ files[:scenario].should be_a(Tempfile)
65
+ files[:scenario].read.should eql(xml)
66
+ end
67
+
68
+ it "allows the scenario XML to be read from disk independently" do
69
+ files = scenario.to_tmpfiles
70
+ File.read(files[:scenario].path).should eql(xml)
71
+ end
72
+
73
+ it "writes the PCAP media to a Tempfile and returns it" do
74
+ files = scenario.to_tmpfiles
75
+ files[:media].should be_a(Tempfile)
76
+ files[:media].read.should eql(media)
77
+ end
78
+
79
+ it "allows the PCAP media to be read from disk independently" do
80
+ files = scenario.to_tmpfiles
81
+ File.read(files[:media].path).should eql(media)
82
+ end
83
+
84
+ context "when media is not provided" do
85
+ let(:media) { nil }
86
+
87
+ it "should not create a media file" do
88
+ files = scenario.to_tmpfiles
89
+ files[:media].should be_nil
90
+ end
91
+ end
92
+ end
93
+
94
+ describe "#scenario_options" do
95
+ it "should return options passed to the initializer" do
96
+ scenario.scenario_options.should == {
97
+ name: 'Test',
98
+ source: '127.0.0.1:5060',
99
+ destination: '10.0.0.1:5080'
100
+ }
101
+ end
102
+ end
103
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- $testing = true
4
-
5
3
  %w{
6
4
  sippy_cup
5
+ fakefs/spec_helpers
7
6
  }.each { |f| require f }
8
7
 
9
8
  RSpec.configure do |config|
@@ -11,4 +10,8 @@ RSpec.configure do |config|
11
10
  config.filter_run :focus => true
12
11
  config.run_all_when_everything_filtered = true
13
12
  config.color_enabled = true
13
+
14
+ config.around(:each) do |example|
15
+ quietly { example.run }
16
+ end
14
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sippy_cup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Klang
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-06 00:00:00.000000000 Z
12
+ date: 2013-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: packetfu
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ! '>'
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: psych
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 2.0.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.0
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: guard-rspec
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +124,7 @@ dependencies:
110
124
  - !ruby/object:Gem::Version
111
125
  version: '0'
112
126
  - !ruby/object:Gem::Dependency
113
- name: ci_reporter
127
+ name: fakefs
114
128
  requirement: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - ! '>='
@@ -133,7 +147,9 @@ extensions: []
133
147
  extra_rdoc_files: []
134
148
  files:
135
149
  - .gitignore
150
+ - .rspec
136
151
  - .ruby-version
152
+ - .travis.yml
137
153
  - CHANGELOG.md
138
154
  - Gemfile
139
155
  - Guardfile
@@ -152,12 +168,16 @@ files:
152
168
  - lib/sippy_cup/scenario.rb
153
169
  - lib/sippy_cup/tasks.rb
154
170
  - lib/sippy_cup/version.rb
171
+ - lib/sippy_cup/xml_scenario.rb
155
172
  - sippy_cup.gemspec
173
+ - spec/fixtures/dtmf_2833_1.pcap
174
+ - spec/fixtures/scenario.xml
175
+ - spec/sippy_cup/fixtures/test.yml
156
176
  - spec/sippy_cup/media_spec.rb
157
177
  - spec/sippy_cup/runner_spec.rb
158
178
  - spec/sippy_cup/scenario_spec.rb
179
+ - spec/sippy_cup/xml_scenario_spec.rb
159
180
  - spec/spec_helper.rb
160
- - tmp/rspec_guard_result
161
181
  homepage: https://github.com/bklang/sippy_cup
162
182
  licenses:
163
183
  - MIT
@@ -178,12 +198,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
198
  version: '0'
179
199
  requirements: []
180
200
  rubyforge_project:
181
- rubygems_version: 2.0.7
201
+ rubygems_version: 2.1.10
182
202
  signing_key:
183
203
  specification_version: 4
184
204
  summary: SIPp profile and RTP stream generator
185
205
  test_files:
206
+ - spec/fixtures/dtmf_2833_1.pcap
207
+ - spec/fixtures/scenario.xml
208
+ - spec/sippy_cup/fixtures/test.yml
186
209
  - spec/sippy_cup/media_spec.rb
187
210
  - spec/sippy_cup/runner_spec.rb
188
211
  - spec/sippy_cup/scenario_spec.rb
212
+ - spec/sippy_cup/xml_scenario_spec.rb
189
213
  - spec/spec_helper.rb
214
+ has_rdoc:
@@ -1 +0,0 @@
1
-