foscam-ruby 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 +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/foscam-ruby.gemspec +34 -0
- data/lib/foscam-ruby.rb +8 -0
- data/lib/foscam/client.rb +425 -0
- data/lib/foscam/version.rb +3 -0
- data/spec/fixtures/vcr/foscam_camera_control_brightness.yml +42 -0
- data/spec/fixtures/vcr/foscam_camera_control_contrast.yml +42 -0
- data/spec/fixtures/vcr/foscam_camera_control_mode.yml +42 -0
- data/spec/fixtures/vcr/foscam_camera_control_orientation.yml +42 -0
- data/spec/fixtures/vcr/foscam_camera_control_resolution.yml +42 -0
- data/spec/fixtures/vcr/foscam_comm_write.yml +42 -0
- data/spec/fixtures/vcr/foscam_decoder_control.yml +42 -0
- data/spec/fixtures/vcr/foscam_get_camera_params.yml +52 -0
- data/spec/fixtures/vcr/foscam_get_forbidden.yml +84 -0
- data/spec/fixtures/vcr/foscam_get_misc.yml +66 -0
- data/spec/fixtures/vcr/foscam_get_params.yml +428 -0
- data/spec/fixtures/vcr/foscam_get_status.yml +68 -0
- data/spec/fixtures/vcr/foscam_reboot.yml +42 -0
- data/spec/fixtures/vcr/foscam_restore_factory.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_alarm.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_alias.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_datetime.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_ddns.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_decoder.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_forbidden.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_ftp.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_mail.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_misc.yml +105 -0
- data/spec/fixtures/vcr/foscam_set_network.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_pppoe.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_upnp.yml +42 -0
- data/spec/fixtures/vcr/foscam_set_user2.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_user3.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_user4.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_user5.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_user6.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_user7.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_user8.yml +40 -0
- data/spec/fixtures/vcr/foscam_set_wifi.yml +40 -0
- data/spec/fixtures/vcr/foscam_snapshot.yml +236 -0
- data/spec/fixtures/vcr/foscam_upgrade_firmware.yml +40 -0
- data/spec/fixtures/vcr/foscam_upgrade_htmls.yml +40 -0
- data/spec/foscam/client_spec.rb +1269 -0
- data/spec/spec_helper.rb +24 -0
- metadata +301 -0
@@ -0,0 +1,236 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://my_username:my_password@192.168.0.117/snapshot.cgi
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
authorization:
|
11
|
+
- Basic Y3dhZGRpbmc6ZnY1MHhFZ0d3Ug==
|
12
|
+
accept-encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
server:
|
24
|
+
- Netwave IP Camera
|
25
|
+
date:
|
26
|
+
- Tue, 13 Nov 2012 05:01:50 GMT
|
27
|
+
content-type:
|
28
|
+
- image/jpeg
|
29
|
+
content-length:
|
30
|
+
- '8784'
|
31
|
+
content-disposition:
|
32
|
+
- filename="snapshot_000DC5D4DC51_20121113000150.jpg"
|
33
|
+
connection:
|
34
|
+
- close
|
35
|
+
body:
|
36
|
+
encoding: ASCII-8BIT
|
37
|
+
string: !binary |-
|
38
|
+
/9j/4AATSkZJRgABAgIAAAAAAAAAAAD/wAARCADwAUADASEAAhEBAxEB/9sA
|
39
|
+
hAAHBQUGBQQHBgYGCAcHCAsSDAsKCgsWEBENEhsXHBwaFxoZHiErJB4fKCAZ
|
40
|
+
GiUzJSgsLTAwMB0kNDg0LjgrLzAuAQcICAsJCxYMDBYuHhoeLi4uLi4uLi4u
|
41
|
+
Li4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi7/xAGi
|
42
|
+
AAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAAB
|
43
|
+
fQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBka
|
44
|
+
JSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6
|
45
|
+
g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS
|
46
|
+
09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAA
|
47
|
+
AAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2Fx
|
48
|
+
EyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RF
|
49
|
+
RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeY
|
50
|
+
mZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo
|
51
|
+
6ery8/T19vf4+fr/2gAMAw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OaklFuOUg
|
222
|
+
4FakFwxQDbz60zVMtQ3IU/OhqV7xifkUYoLuXbO8PA6GtyNxKgoZhVXUayAA
|
223
|
+
isvULIzIQvXtTWoU30OaZGjYhgVINbekXOXC55oNd0yzq1tDdxFi6I44rzfW
|
224
|
+
2NnE+37ynFJqxGqjcpWc7y225xzThycUhalpRxV+NflHFAyVVqTOBTA4V+eK
|
225
|
+
ibrWZziAU9F9uaBnTaLoUDtDdFBujfd06nHH61j/ABQn/wBK0qzX7sUTyt6b
|
226
|
+
mIA/RTUvV2DocCB8y/4VpWB/4mUIJxk4qkKxesGhOkxIzn7Qs7KVxwE2DnP1
|
227
|
+
GK2gZjYMsCxYQAM7N3PtUWBoxUtbzUr9LaHEkrttAUdPc17ppenR6ZpMFhAM
|
228
|
+
LCgXOOpxya0gdFJaXJFt2R8nBJ9aPs1uh3SzLn0zWljV6FabUrSIERjPuazJ
|
229
|
+
9QDZ2k0aEuVyi10TkmqNxIXpEblJmOe9RM2AcmgkdYxRmTzSAW7H0rR3HFA1
|
230
|
+
sOQ85rQhmwAc0FLQsLOGOCasI6qOTk0FqwJPsbPPWtrTdQDDDGmJrmVjYyHT
|
231
|
+
d1qGZkMJDdaSOeN7nL6lEUlD44NVrO4Mc4waZ0p6mjcWfzfankLIOcGq3iHw
|
232
|
+
xBPbG4hbcrDJXFKxMmm7HKfZUgQxhQAKp7QjkE4pEk0fJrQj4UelALQnUjHW
|
233
|
+
kZgPemFzAP/Z
|
234
|
+
http_version: '1.1'
|
235
|
+
recorded_at: Tue, 13 Nov 2012 05:01:50 GMT
|
236
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://my_username:my_password@192.168.0.117/upgrade_firmware.cgi
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
authorization:
|
11
|
+
- Basic Y3dhZGRpbmc6ZnY1MHhFZ0d3Ug==
|
12
|
+
content-length:
|
13
|
+
- '0'
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
server:
|
24
|
+
- Netwave IP Camera
|
25
|
+
date:
|
26
|
+
- Tue, 13 Nov 2012 05:02:51 GMT
|
27
|
+
content-type:
|
28
|
+
- text/plain
|
29
|
+
content-length:
|
30
|
+
- '26'
|
31
|
+
cache-control:
|
32
|
+
- no-cache
|
33
|
+
connection:
|
34
|
+
- close
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ! 'error: illegal http frame.'
|
38
|
+
http_version: '1.1'
|
39
|
+
recorded_at: Tue, 13 Nov 2012 05:02:51 GMT
|
40
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://my_username:my_password@192.168.0.117/upgrade_htmls.cgi
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
authorization:
|
11
|
+
- Basic Y3dhZGRpbmc6ZnY1MHhFZ0d3Ug==
|
12
|
+
content-length:
|
13
|
+
- '0'
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
server:
|
24
|
+
- Netwave IP Camera
|
25
|
+
date:
|
26
|
+
- Tue, 13 Nov 2012 05:02:51 GMT
|
27
|
+
content-type:
|
28
|
+
- text/plain
|
29
|
+
content-length:
|
30
|
+
- '26'
|
31
|
+
cache-control:
|
32
|
+
- no-cache
|
33
|
+
connection:
|
34
|
+
- close
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ! 'error: illegal http frame.'
|
38
|
+
http_version: '1.1'
|
39
|
+
recorded_at: Tue, 13 Nov 2012 05:02:51 GMT
|
40
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,1269 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Foscam::Client do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@service = Foscam::Client.new
|
7
|
+
@connection = Faraday.new( url: FOSCAM_URL)
|
8
|
+
@connection.basic_auth(FOSCAM_USERNAME, FOSCAM_PASSWORD)
|
9
|
+
@service.connection = @connection
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#snapshot" do
|
13
|
+
context "response is successful" do
|
14
|
+
around(:each) do |spec|
|
15
|
+
# @service.connection = @connection
|
16
|
+
::VCR.use_cassette("foscam_snapshot") do
|
17
|
+
spec.run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
it "returns an Image" do
|
21
|
+
image = @service.snapshot
|
22
|
+
image.should be_a_kind_of(MiniMagick::Image)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context "response is unsuccessful" do
|
26
|
+
before(:each) do
|
27
|
+
response = ::Faraday::Response.new
|
28
|
+
response.stub!(:success?).and_return(false)
|
29
|
+
@connection.stub(:get).with('snapshot.cgi').and_return(response)
|
30
|
+
@service.connection = @connection
|
31
|
+
end
|
32
|
+
it "returns nil" do
|
33
|
+
image = @service.snapshot
|
34
|
+
image.should be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#get_status" do
|
40
|
+
context "response is successful" do
|
41
|
+
around(:each) do |spec|
|
42
|
+
# @service.connection = @connection
|
43
|
+
::VCR.use_cassette("foscam_get_status") do
|
44
|
+
spec.run
|
45
|
+
end
|
46
|
+
end
|
47
|
+
it "returns a hash of variables" do
|
48
|
+
response = @service.get_status
|
49
|
+
[:id, :sys_ver, :app_ver, :alias, :now, :tz, :alarm_status, :ddns_status, :ddns_host, :oray_type, :upnp_status, :p2p_status, :p2p_local_port, :msn_status].each do |key|
|
50
|
+
response.should have_key(key)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sets the ddns status string" do
|
55
|
+
response = @service.get_status
|
56
|
+
response[:ddns_status].should be_a_kind_of(String)
|
57
|
+
::Foscam::DDNS_STATUS.values.should include(response[:ddns_status])
|
58
|
+
end
|
59
|
+
|
60
|
+
it "sets the upnp status string" do
|
61
|
+
response = @service.get_status
|
62
|
+
response[:upnp_status].should be_a_kind_of(String)
|
63
|
+
::Foscam::UPNP_STATUS.values.should include(response[:upnp_status])
|
64
|
+
end
|
65
|
+
|
66
|
+
it "sets the alarm status string" do
|
67
|
+
response = @service.get_status
|
68
|
+
response[:alarm_status].should be_a_kind_of(String)
|
69
|
+
::Foscam::ALARM_STATUS.values.should include(response[:alarm_status])
|
70
|
+
end
|
71
|
+
it "sets the time" do
|
72
|
+
response = @service.get_status
|
73
|
+
response[:now].should be_a_kind_of(DateTime)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "response is unsuccessful" do
|
78
|
+
before(:each) do
|
79
|
+
response = ::Faraday::Response.new
|
80
|
+
response.stub!(:success?).and_return(false)
|
81
|
+
@connection.stub(:get).with('get_status.cgi').and_return(response)
|
82
|
+
@service.connection = @connection
|
83
|
+
end
|
84
|
+
it "returns a hash of variables" do
|
85
|
+
response = @service.get_status
|
86
|
+
response.should == {}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "#get_camera_params" do
|
92
|
+
context "response is successful" do
|
93
|
+
around(:each) do |spec|
|
94
|
+
# @service.connection = @connection
|
95
|
+
::VCR.use_cassette("foscam_get_camera_params") do
|
96
|
+
spec.run
|
97
|
+
end
|
98
|
+
end
|
99
|
+
it "returns a hash of variables" do
|
100
|
+
response = @service.get_camera_params
|
101
|
+
[:resolution, :brightness, :contrast, :mode, :flip, :fps].each do |key|
|
102
|
+
response.should have_key(key)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "sets the mode as a string" do
|
107
|
+
response = @service.get_camera_params
|
108
|
+
response[:mode].should be_a_kind_of(String)
|
109
|
+
::Foscam::CAMERA_PARAMS_MODE.values.should include(response[:mode])
|
110
|
+
end
|
111
|
+
|
112
|
+
it "sets the orientation as a string" do
|
113
|
+
response = @service.get_camera_params
|
114
|
+
response[:flip].should be_a_kind_of(String)
|
115
|
+
::Foscam::CAMERA_PARAMS_ORIENTATION.values.should include(response[:flip])
|
116
|
+
end
|
117
|
+
|
118
|
+
it "sets the resolution as a string" do
|
119
|
+
response = @service.get_camera_params
|
120
|
+
response[:resolution].should be_a_kind_of(String)
|
121
|
+
::Foscam::CAMERA_PARAMS_RESOLUTION.values.should include(response[:resolution])
|
122
|
+
end
|
123
|
+
|
124
|
+
it "sets the brightness as a number" do
|
125
|
+
response = @service.get_camera_params
|
126
|
+
response[:brightness].should be_a_kind_of(Integer)
|
127
|
+
end
|
128
|
+
it "sets the contrast as a number" do
|
129
|
+
response = @service.get_camera_params
|
130
|
+
response[:contrast].should be_a_kind_of(Integer)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "response is unsuccessful" do
|
135
|
+
before(:each) do
|
136
|
+
response = ::Faraday::Response.new
|
137
|
+
response.stub!(:success?).and_return(false)
|
138
|
+
@connection.stub(:get).with('get_camera_params.cgi').and_return(response)
|
139
|
+
@service.connection = @connection
|
140
|
+
end
|
141
|
+
it "returns a hash of variables" do
|
142
|
+
response = @service.get_camera_params
|
143
|
+
response.should == {}
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#decoder_control" do
|
149
|
+
context "response is successful" do
|
150
|
+
around(:each) do |spec|
|
151
|
+
# @service.connection = @connection
|
152
|
+
::VCR.use_cassette("foscam_decoder_control") do
|
153
|
+
spec.run
|
154
|
+
end
|
155
|
+
end
|
156
|
+
it "returns a hash of variables" do
|
157
|
+
action = :stop_up
|
158
|
+
response = @service.decoder_control(action)
|
159
|
+
response.should be_true
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context "response is unsuccessful" do
|
164
|
+
before(:each) do
|
165
|
+
response = ::Faraday::Response.new
|
166
|
+
response.stub!(:success?).and_return(false)
|
167
|
+
@connection.stub(:get).with('decoder_control.cgi?command=1').and_return(response)
|
168
|
+
@service.connection = @connection
|
169
|
+
end
|
170
|
+
it "returns a hash of variables" do
|
171
|
+
response = @service.decoder_control(:stop_up)
|
172
|
+
response.should be_false
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#camera_control" do
|
178
|
+
describe "camera resolution" do
|
179
|
+
context "with valid parameters" do
|
180
|
+
around(:each) do |spec|
|
181
|
+
::VCR.use_cassette("foscam_camera_control_resolution") do
|
182
|
+
spec.run
|
183
|
+
end
|
184
|
+
end
|
185
|
+
it "returns true when set using a string" do
|
186
|
+
response = @service.camera_control(resolution: "QVGA")
|
187
|
+
response.should be_true
|
188
|
+
end
|
189
|
+
it "returns true when set using a number" do
|
190
|
+
response = @service.camera_control(resolution: 8)
|
191
|
+
response.should be_true
|
192
|
+
end
|
193
|
+
end
|
194
|
+
context "with invalid parameters" do
|
195
|
+
it "raises an exception with invalid number" do
|
196
|
+
expect {@service.camera_control(resolution: 0)}.to raise_error
|
197
|
+
end
|
198
|
+
|
199
|
+
it "raises an exception with invalid string" do
|
200
|
+
expect {@service.camera_control(resolution: "XVGA")}.to raise_error
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "camera brightness" do
|
206
|
+
context "with valid parameters" do
|
207
|
+
around(:each) do |spec|
|
208
|
+
::VCR.use_cassette("foscam_camera_control_brightness") do
|
209
|
+
spec.run
|
210
|
+
end
|
211
|
+
end
|
212
|
+
it "returns true" do
|
213
|
+
response = @service.camera_control( brightness: 160)
|
214
|
+
response.should be_true
|
215
|
+
end
|
216
|
+
end
|
217
|
+
context "with invalid parameters" do
|
218
|
+
it "raises an exception when < 0" do
|
219
|
+
expect {@service.camera_control( brightness: -1)}.to raise_error
|
220
|
+
end
|
221
|
+
|
222
|
+
it "raises an exception when > 255" do
|
223
|
+
expect {@service.camera_control( brightness: 256)}.to raise_error
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "camera contrast" do
|
229
|
+
context "with valid parameters" do
|
230
|
+
around(:each) do |spec|
|
231
|
+
::VCR.use_cassette("foscam_camera_control_contrast") do
|
232
|
+
spec.run
|
233
|
+
end
|
234
|
+
end
|
235
|
+
it "returns true" do
|
236
|
+
response = @service.camera_control(contrast: 4)
|
237
|
+
response.should be_true
|
238
|
+
end
|
239
|
+
end
|
240
|
+
context "with invalid parameters" do
|
241
|
+
it "raises an exception when < 0" do
|
242
|
+
expect {@service.camera_control( contrast: -1)}.to raise_error
|
243
|
+
end
|
244
|
+
|
245
|
+
it "raises an exception when > 6" do
|
246
|
+
expect {@service.camera_control( contrast: 7)}.to raise_error
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe "camera mode" do
|
252
|
+
context "with valid parameters" do
|
253
|
+
around(:each) do |spec|
|
254
|
+
::VCR.use_cassette("foscam_camera_control_mode") do
|
255
|
+
spec.run
|
256
|
+
end
|
257
|
+
end
|
258
|
+
it "returns true" do
|
259
|
+
response = @service.camera_control( mode: :outdoor)
|
260
|
+
response.should be_true
|
261
|
+
end
|
262
|
+
end
|
263
|
+
context "with invalid parameters" do
|
264
|
+
it "raises an exception when < 0" do
|
265
|
+
expect {@service.camera_control( mode: -1)}.to raise_error
|
266
|
+
end
|
267
|
+
|
268
|
+
it "raises an exception when > 2" do
|
269
|
+
expect {@service.camera_control( mode: 3)}.to raise_error
|
270
|
+
end
|
271
|
+
it "raises an exception with an invalid string" do
|
272
|
+
expect {@service.camera_control( mode: "10Hz")}.to raise_error
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "camera orientation" do
|
278
|
+
context "with valid parameters" do
|
279
|
+
around(:each) do |spec|
|
280
|
+
::VCR.use_cassette("foscam_camera_control_orientation") do
|
281
|
+
spec.run
|
282
|
+
end
|
283
|
+
end
|
284
|
+
it "returns true" do
|
285
|
+
response = @service.camera_control(flip: "mirror")
|
286
|
+
response.should be_true
|
287
|
+
end
|
288
|
+
end
|
289
|
+
context "with invalid parameters" do
|
290
|
+
it "raises an exception when < 0" do
|
291
|
+
expect {@service.camera_control(flip: -1)}.to raise_error
|
292
|
+
end
|
293
|
+
|
294
|
+
it "raises an exception when > 3" do
|
295
|
+
expect {@service.camera_control(flip: 4)}.to raise_error
|
296
|
+
end
|
297
|
+
it "raises an exception with an invalid string" do
|
298
|
+
expect {@service.camera_control( mode: "diagonal")}.to raise_error
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
context "response is unsuccessful" do
|
304
|
+
before(:each) do
|
305
|
+
response = ::Faraday::Response.new
|
306
|
+
response.stub!(:success?).and_return(false)
|
307
|
+
@connection.stub(:get).with('camera_control.cgi?param=1&value=160').and_return(response)
|
308
|
+
@service.connection = @connection
|
309
|
+
end
|
310
|
+
it "returns a hash of variables" do
|
311
|
+
response = @service.camera_control(brightness: 160)
|
312
|
+
response.should be_false
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
describe "#reboot" do
|
320
|
+
context "response is successful" do
|
321
|
+
around(:each) do |spec|
|
322
|
+
# @service.connection = @connection
|
323
|
+
::VCR.use_cassette("foscam_reboot") do
|
324
|
+
spec.run
|
325
|
+
end
|
326
|
+
end
|
327
|
+
it "returns a hash of variables" do
|
328
|
+
response = @service.reboot
|
329
|
+
response.should be_true
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
context "response is unsuccessful" do
|
334
|
+
before(:each) do
|
335
|
+
response = ::Faraday::Response.new
|
336
|
+
response.stub!(:success?).and_return(false)
|
337
|
+
@connection.stub(:get).with('reboot.cgi').and_return(response)
|
338
|
+
@service.connection = @connection
|
339
|
+
end
|
340
|
+
it "returns a hash of variables" do
|
341
|
+
response = @service.reboot
|
342
|
+
response.should be_false
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
describe "#restore_factory" do
|
348
|
+
|
349
|
+
context "response is successful" do
|
350
|
+
around(:each) do |spec|
|
351
|
+
# @service.connection = @connection
|
352
|
+
::VCR.use_cassette("foscam_restore_factory") do
|
353
|
+
spec.run
|
354
|
+
end
|
355
|
+
end
|
356
|
+
it "returns a hash of variables" do
|
357
|
+
response = @service.restore_factory
|
358
|
+
response.should be_true
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
context "response is unsuccessful" do
|
363
|
+
before(:each) do
|
364
|
+
response = ::Faraday::Response.new
|
365
|
+
response.stub!(:success?).and_return(false)
|
366
|
+
@connection.stub(:get).with('restore_factory.cgi').and_return(response)
|
367
|
+
@service.connection = @connection
|
368
|
+
end
|
369
|
+
it "returns a hash of variables" do
|
370
|
+
response = @service.restore_factory
|
371
|
+
response.should be_false
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
describe "#get_params" do
|
377
|
+
context "response is successful" do
|
378
|
+
around(:each) do |spec|
|
379
|
+
# @service.connection = @connection
|
380
|
+
::VCR.use_cassette("foscam_get_params") do
|
381
|
+
spec.run
|
382
|
+
end
|
383
|
+
end
|
384
|
+
it "returns a hash of variables" do
|
385
|
+
response = @service.get_params
|
386
|
+
[ :id, :sys_ver, :app_ver, :alias,
|
387
|
+
:now, :tz, :daylight_saving_time, :ntp_enable, :ntp_svr,
|
388
|
+
:user1_name, :user1_pwd, :user1_pri,
|
389
|
+
:user2_name, :user2_pwd, :user2_pri,
|
390
|
+
:user3_name, :user3_pwd, :user3_pri,
|
391
|
+
:user4_name, :user4_pwd, :user4_pri,
|
392
|
+
:user5_name, :user5_pwd, :user5_pri,
|
393
|
+
:user6_name, :user6_pwd, :user6_pri,
|
394
|
+
:user7_name, :user7_pwd, :user7_pri,
|
395
|
+
:user8_name, :user8_pwd, :user8_pri,
|
396
|
+
:dev2_alias, :dev2_host, :dev2_port, :dev2_user, :dev2_pwd,
|
397
|
+
:dev3_alias, :dev3_host, :dev3_port, :dev3_user, :dev3_pwd,
|
398
|
+
:dev4_alias, :dev4_host, :dev4_port, :dev4_user, :dev4_pwd,
|
399
|
+
:dev5_alias, :dev5_host, :dev5_port, :dev5_user, :dev5_pwd,
|
400
|
+
:dev6_alias, :dev6_host, :dev6_port, :dev6_user, :dev6_pwd,
|
401
|
+
:dev7_alias, :dev7_host, :dev7_port, :dev7_user, :dev7_pwd,
|
402
|
+
:dev8_alias, :dev8_host, :dev8_port, :dev8_user, :dev8_pwd,
|
403
|
+
:dev9_alias, :dev9_host, :dev9_port, :dev9_user, :dev9_pwd,
|
404
|
+
:ip, :mask, :gateway, :dns, :port,
|
405
|
+
:wifi_enable, :wifi_ssid, :wifi_encrypt, :wifi_defkey,
|
406
|
+
:wifi_key1, :wifi_key2, :wifi_key3, :wifi_key4, :wifi_authtype, :wifi_keyformat,
|
407
|
+
:wifi_key1_bits, :wifi_key2_bits, :wifi_key3_bits, :wifi_key4_bits, :wifi_mode, :wifi_wpa_psk,
|
408
|
+
:pppoe_enable, :pppoe_user, :pppoe_pwd, :upnp_enable,
|
409
|
+
:ddns_service, :ddns_user, :ddns_pwd, :ddns_host, :ddns_proxy_svr, :ddns_proxy_port,
|
410
|
+
:mail_svr, :mail_port, :mail_tls, :mail_user, :mail_pwd, :mail_sender,
|
411
|
+
:mail_receiver1, :mail_receiver2, :mail_receiver3, :mail_receiver4, :mail_inet_ip,
|
412
|
+
:ftp_svr, :ftp_port, :ftp_user, :ftp_pwd, :ftp_dir, :ftp_mode, :ftp_upload_interval, :ftp_filename, :ftp_numberoffiles, :ftp_schedule_enable,
|
413
|
+
:ftp_schedule_sun_0, :ftp_schedule_sun_1, :ftp_schedule_sun_2,
|
414
|
+
:ftp_schedule_mon_0, :ftp_schedule_mon_1, :ftp_schedule_mon_2,
|
415
|
+
:ftp_schedule_tue_0, :ftp_schedule_tue_1, :ftp_schedule_tue_2,
|
416
|
+
:ftp_schedule_wed_0, :ftp_schedule_wed_1, :ftp_schedule_wed_2,
|
417
|
+
:ftp_schedule_thu_0, :ftp_schedule_thu_1, :ftp_schedule_thu_2,
|
418
|
+
:ftp_schedule_fri_0, :ftp_schedule_fri_1, :ftp_schedule_fri_2,
|
419
|
+
:ftp_schedule_sat_0, :ftp_schedule_sat_1, :ftp_schedule_sat_2,
|
420
|
+
:alarm_motion_armed, :alarm_motion_sensitivity, :alarm_motion_compensation,
|
421
|
+
:alarm_input_armed, :alarm_ioin_level, :alarm_iolinkage, :alarm_preset, :alarm_ioout_level, :alarm_mail, :alarm_upload_interval, :alarm_http, :alarm_msn, :alarm_http_url, :alarm_schedule_enable,
|
422
|
+
:alarm_schedule_sun_0, :alarm_schedule_sun_1, :alarm_schedule_sun_2,
|
423
|
+
:alarm_schedule_mon_0, :alarm_schedule_mon_1, :alarm_schedule_mon_2,
|
424
|
+
:alarm_schedule_tue_0, :alarm_schedule_tue_1, :alarm_schedule_tue_2,
|
425
|
+
:alarm_schedule_wed_0, :alarm_schedule_wed_1, :alarm_schedule_wed_2,
|
426
|
+
:alarm_schedule_thu_0, :alarm_schedule_thu_1, :alarm_schedule_thu_2,
|
427
|
+
:alarm_schedule_fri_0, :alarm_schedule_fri_1, :alarm_schedule_fri_2,
|
428
|
+
:alarm_schedule_sat_0, :alarm_schedule_sat_1, :alarm_schedule_sat_2,
|
429
|
+
:decoder_baud, :msn_user, :msn_pwd,
|
430
|
+
:msn_friend1, :msn_friend2, :msn_friend3, :msn_friend4, :msn_friend5, :msn_friend6, :msn_friend7, :msn_friend8, :msn_friend9, :msn_friend10
|
431
|
+
].each do |key|
|
432
|
+
response.should have_key(key)
|
433
|
+
end
|
434
|
+
end
|
435
|
+
it "sets now as datetime" do
|
436
|
+
response = @service.get_params
|
437
|
+
response[:now].should be_a_kind_of(DateTime)
|
438
|
+
end
|
439
|
+
it "sets the daylight_savings_time as a number" do
|
440
|
+
response = @service.get_params
|
441
|
+
response[:daylight_savings_time].should be_a_kind_of(Integer)
|
442
|
+
end
|
443
|
+
it "sets ntp_enable as a Boolean" do
|
444
|
+
response = @service.get_params
|
445
|
+
response[:ntp_enable].should be_a_kind_of(Boolean)
|
446
|
+
end
|
447
|
+
|
448
|
+
it "sets user privilages as a USER_PRIVILAGE" do
|
449
|
+
response = @service.get_params
|
450
|
+
[:user1_pri, :user2_pri, :user3_pri, :user4_pri, :user5_pri, :user6_pri, :user7_pri, :user8_pri].each do |key|
|
451
|
+
response[key].should be_a_kind_of(Symbol)
|
452
|
+
::Foscam::USER_PERMISSIONS.values.should include(response[key])
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
it "sets the ports as a number" do
|
457
|
+
response = @service.get_params
|
458
|
+
[:ddns_proxy_port, :ftp_port, :mail_port, :port, :dev2_port, :dev3_port, :dev4_port, :dev5_port, :dev6_port, :dev7_port, :dev8_port, :dev9_port].each do |key|
|
459
|
+
response[key].should be_a_kind_of(Integer)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
it "sets wifi_enable as a boolean" do
|
464
|
+
response = @service.get_params
|
465
|
+
response[:wifi_enable].should be_a_kind_of(Boolean)
|
466
|
+
end
|
467
|
+
|
468
|
+
it "sets pppoe_enable as a boolean" do
|
469
|
+
response = @service.get_params
|
470
|
+
response[:pppoe_enable].should be_a_kind_of(Boolean)
|
471
|
+
end
|
472
|
+
it "sets upnp_enable as a boolean" do
|
473
|
+
response = @service.get_params
|
474
|
+
response[:upnp_enable].should be_a_kind_of(Boolean)
|
475
|
+
end
|
476
|
+
|
477
|
+
it "sets alarm_schedule_enable as a boolean" do
|
478
|
+
response = @service.get_params
|
479
|
+
response[:alarm_schedule_enable].should be_a_kind_of(Boolean)
|
480
|
+
end
|
481
|
+
|
482
|
+
it "sets ftp_schedule_enable as a boolean" do
|
483
|
+
response = @service.get_params
|
484
|
+
response[:ftp_schedule_enable].should be_a_kind_of(Boolean)
|
485
|
+
end
|
486
|
+
|
487
|
+
it "sets the ftp_schedule as an integer" do
|
488
|
+
response = @service.get_params
|
489
|
+
[
|
490
|
+
:ftp_schedule_sun_0, :ftp_schedule_sun_1, :ftp_schedule_sun_2,
|
491
|
+
:ftp_schedule_mon_0, :ftp_schedule_mon_1, :ftp_schedule_mon_2,
|
492
|
+
:ftp_schedule_tue_0, :ftp_schedule_tue_1, :ftp_schedule_tue_2,
|
493
|
+
:ftp_schedule_wed_0, :ftp_schedule_wed_1, :ftp_schedule_wed_2,
|
494
|
+
:ftp_schedule_thu_0, :ftp_schedule_thu_1, :ftp_schedule_thu_2,
|
495
|
+
:ftp_schedule_fri_0, :ftp_schedule_fri_1, :ftp_schedule_fri_2,
|
496
|
+
:ftp_schedule_sat_0, :ftp_schedule_sat_1, :ftp_schedule_sat_2
|
497
|
+
].each do |key|
|
498
|
+
response[key].should be_a_kind_of(Integer)
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
it "sets the alarm_schedule as an integer" do
|
503
|
+
response = @service.get_params
|
504
|
+
[
|
505
|
+
:alarm_schedule_sun_0, :alarm_schedule_sun_1, :alarm_schedule_sun_2,
|
506
|
+
:alarm_schedule_mon_0, :alarm_schedule_mon_1, :alarm_schedule_mon_2,
|
507
|
+
:alarm_schedule_tue_0, :alarm_schedule_tue_1, :alarm_schedule_tue_2,
|
508
|
+
:alarm_schedule_wed_0, :alarm_schedule_wed_1, :alarm_schedule_wed_2,
|
509
|
+
:alarm_schedule_thu_0, :alarm_schedule_thu_1, :alarm_schedule_thu_2,
|
510
|
+
:alarm_schedule_fri_0, :alarm_schedule_fri_1, :alarm_schedule_fri_2,
|
511
|
+
:alarm_schedule_sat_0, :alarm_schedule_sat_1, :alarm_schedule_sat_2
|
512
|
+
].each do |key|
|
513
|
+
response[key].should be_a_kind_of(Integer)
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
context "response is unsuccessful" do
|
519
|
+
before(:each) do
|
520
|
+
response = ::Faraday::Response.new
|
521
|
+
response.stub!(:success?).and_return(false)
|
522
|
+
@connection.stub(:get).with('get_params.cgi').and_return(response)
|
523
|
+
@service.connection = @connection
|
524
|
+
end
|
525
|
+
it "returns a hash of variables" do
|
526
|
+
response = @service.get_params
|
527
|
+
response.should == {}
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
# describe "#upgrade_firmware" do
|
533
|
+
# around(:each) do |spec|
|
534
|
+
# ::VCR.use_cassette("foscam_upgrade_firmware") do
|
535
|
+
# spec.run
|
536
|
+
# end
|
537
|
+
# end
|
538
|
+
# it "" do
|
539
|
+
# @service.upgrade_firmware
|
540
|
+
# end
|
541
|
+
|
542
|
+
# end
|
543
|
+
|
544
|
+
# describe "#upgrade_htmls" do
|
545
|
+
# around(:each) do |spec|
|
546
|
+
# VCR.use_cassette("foscam_upgrade_htmls") do
|
547
|
+
# spec.run
|
548
|
+
# end
|
549
|
+
# end
|
550
|
+
# it "" do
|
551
|
+
# @service.upgrade_htmls
|
552
|
+
# end
|
553
|
+
|
554
|
+
# end
|
555
|
+
|
556
|
+
describe "#set_alias" do
|
557
|
+
context "with valid parameters" do
|
558
|
+
around(:each) do |spec|
|
559
|
+
# @service.connection = @connection
|
560
|
+
::VCR.use_cassette("foscam_set_alias") do
|
561
|
+
spec.run
|
562
|
+
end
|
563
|
+
end
|
564
|
+
it "returns a hash of variables" do
|
565
|
+
name = "R2D2"
|
566
|
+
response = @service.set_alias(name)
|
567
|
+
response.should be_true
|
568
|
+
end
|
569
|
+
end
|
570
|
+
context "with invalid parameters" do
|
571
|
+
it "raises an exception when more than 20 characters long 0" do
|
572
|
+
expect {@service.set_alias("123456789012345678901")}.to raise_error
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
context "response is unsuccessful" do
|
577
|
+
before(:each) do
|
578
|
+
response = ::Faraday::Response.new
|
579
|
+
response.stub!(:success?).and_return(false)
|
580
|
+
@connection.stub(:get).with('set_alias.cgi?alias=R2D2').and_return(response)
|
581
|
+
@service.connection = @connection
|
582
|
+
end
|
583
|
+
it "returns a hash of variables" do
|
584
|
+
name = "R2D2"
|
585
|
+
response = @service.set_alias(name)
|
586
|
+
response.should be_false
|
587
|
+
end
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
describe "#set_datetime" do
|
592
|
+
context "with valid parameters" do
|
593
|
+
around(:each) do |spec|
|
594
|
+
# @service.connection = @connection
|
595
|
+
::VCR.use_cassette("foscam_set_datetime") do
|
596
|
+
spec.run
|
597
|
+
end
|
598
|
+
end
|
599
|
+
it "returns a hash of variables" do
|
600
|
+
params = {tz:18000, ntp_enable:1, ntp_svr:"0.ca.pool.ntp.org"}
|
601
|
+
response = @service.set_datetime(params)
|
602
|
+
response.should be_true
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
606
|
+
context "with invalid parameters" do
|
607
|
+
it "raises an exception when ntp_server more than 64 characters long" do
|
608
|
+
expect {@service.set_datetime(ntp_svr:"012345678901234567890123456789012345678901234567890123456789012345")}.to raise_error
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
context "response is unsuccessful" do
|
613
|
+
before(:each) do
|
614
|
+
response = ::Faraday::Response.new
|
615
|
+
response.stub!(:success?).and_return(false)
|
616
|
+
@connection.stub(:get).with('set_datetime.cgi?').and_return(response)
|
617
|
+
@service.connection = @connection
|
618
|
+
end
|
619
|
+
it "returns a hash of variables" do
|
620
|
+
response = @service.set_datetime({})
|
621
|
+
response.should be_false
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
end
|
626
|
+
|
627
|
+
describe "#set_users" do
|
628
|
+
context "with valid parameters" do
|
629
|
+
it "sets user 2 name, password, and privilages" do
|
630
|
+
::VCR.use_cassette("foscam_set_user2") do
|
631
|
+
params = {user2: "user2", pwd2: "pass2", pri2:0}
|
632
|
+
response = @service.set_users(params)
|
633
|
+
response.should be_true
|
634
|
+
end
|
635
|
+
end
|
636
|
+
|
637
|
+
it "sets user 3 name, password, and privilages" do
|
638
|
+
::VCR.use_cassette("foscam_set_user3") do
|
639
|
+
params = {user3: "user3", pwd3: "pass3", pri3:0}
|
640
|
+
response = @service.set_users(params)
|
641
|
+
response.should be_true
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
it "sets user 4 name, password, and privilages" do
|
646
|
+
::VCR.use_cassette("foscam_set_user4") do
|
647
|
+
params = {user4: "user4", pwd4: "pass4", pri4:0}
|
648
|
+
response = @service.set_users(params)
|
649
|
+
response.should be_true
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
it "sets user 5 name, password, and privilages" do
|
654
|
+
::VCR.use_cassette("foscam_set_user5") do
|
655
|
+
params = {user5: "user5", pwd4: "pass5", pri5:0}
|
656
|
+
response = @service.set_users(params)
|
657
|
+
response.should be_true
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
it "sets user 6 name, password, and privilages" do
|
662
|
+
::VCR.use_cassette("foscam_set_user6") do
|
663
|
+
params = {user6: "user6", pwd6: "pass6", pri6:0}
|
664
|
+
response = @service.set_users(params)
|
665
|
+
response.should be_true
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
it "sets user 7 name, password, and privilages" do
|
670
|
+
::VCR.use_cassette("foscam_set_user7") do
|
671
|
+
params = {user7: "user7", pwd7: "pass7", pri7:0}
|
672
|
+
response = @service.set_users(params)
|
673
|
+
response.should be_true
|
674
|
+
end
|
675
|
+
end
|
676
|
+
|
677
|
+
it "sets user 8 name, password, and privilages" do
|
678
|
+
::VCR.use_cassette("foscam_set_user8") do
|
679
|
+
params = {user8: "user8", pwd7: "pass8", pri8:0}
|
680
|
+
response = @service.set_users(params)
|
681
|
+
response.should be_true
|
682
|
+
end
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
686
|
+
context "with invalid parameters" do
|
687
|
+
it "raises an exception when username or password is more than 12 characters long" do
|
688
|
+
[:user1, :pwd1, :user2, :pwd2, :user3, :pwd3, :user4, :pwd4, :user5, :pwd5, :user6, :pwd6, :user7, :pwd7, :user8, :pwd8].each do |key|
|
689
|
+
expect {@service.set_users(key => "0123456789123")}.to raise_error
|
690
|
+
end
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
context "response is unsuccessful" do
|
695
|
+
before(:each) do
|
696
|
+
response = ::Faraday::Response.new
|
697
|
+
response.stub!(:success?).and_return(false)
|
698
|
+
@connection.stub(:get).with('set_users.cgi?').and_return(response)
|
699
|
+
@service.connection = @connection
|
700
|
+
end
|
701
|
+
it "returns a hash of variables" do
|
702
|
+
response = @service.set_users({})
|
703
|
+
response.should be_false
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
end
|
708
|
+
|
709
|
+
# describe "#set_devices" do
|
710
|
+
# around(:each) do |spec|
|
711
|
+
# VCR.use_cassette("foscam_set_devices") do
|
712
|
+
# spec.run
|
713
|
+
# end
|
714
|
+
# end
|
715
|
+
# it "" do
|
716
|
+
# @service.set_devices(params)
|
717
|
+
# end
|
718
|
+
|
719
|
+
# end
|
720
|
+
|
721
|
+
describe "#set_network" do
|
722
|
+
context "with valid parameters" do
|
723
|
+
around(:each) do |spec|
|
724
|
+
# @service.connection = @connection
|
725
|
+
::VCR.use_cassette("foscam_set_network") do
|
726
|
+
spec.run
|
727
|
+
end
|
728
|
+
end
|
729
|
+
it "returns a hash of variables" do
|
730
|
+
params = {ip: "192.168.0.100", mask: "0.0.0.0", gateway: "0.0.0.0", dns: "8.8.8.8", port: "8080"}
|
731
|
+
response = @service.set_network(params)
|
732
|
+
response.should be_true
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
context "response is unsuccessful" do
|
737
|
+
before(:each) do
|
738
|
+
response = ::Faraday::Response.new
|
739
|
+
response.stub!(:success?).and_return(false)
|
740
|
+
@connection.stub(:get).with('set_network.cgi?').and_return(response)
|
741
|
+
@service.connection = @connection
|
742
|
+
end
|
743
|
+
it "returns a hash of variables" do
|
744
|
+
params = {}
|
745
|
+
response = @service.set_network(params)
|
746
|
+
response.should be_false
|
747
|
+
end
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
describe "#set_wifi" do
|
752
|
+
context "with valid parameters" do
|
753
|
+
around(:each) do |spec|
|
754
|
+
# @service.connection = @connection
|
755
|
+
::VCR.use_cassette("foscam_set_wifi") do
|
756
|
+
spec.run
|
757
|
+
end
|
758
|
+
end
|
759
|
+
it "returns a hash of variables" do
|
760
|
+
params = {ssid: "my_wireless_ssid", enable: 1, encrypt: 1, wpa_psk: "my_wireless_password"}
|
761
|
+
response = @service.set_wifi(params)
|
762
|
+
response.should be_true
|
763
|
+
end
|
764
|
+
end
|
765
|
+
|
766
|
+
context "response is unsuccessful" do
|
767
|
+
before(:each) do
|
768
|
+
response = ::Faraday::Response.new
|
769
|
+
response.stub!(:success?).and_return(false)
|
770
|
+
@connection.stub(:get).with('set_wifi.cgi?').and_return(response)
|
771
|
+
@service.connection = @connection
|
772
|
+
end
|
773
|
+
it "returns a hash of variables" do
|
774
|
+
params = {}
|
775
|
+
response = @service.set_wifi(params)
|
776
|
+
response.should be_false
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
|
781
|
+
end
|
782
|
+
|
783
|
+
describe "#set_pppoe" do
|
784
|
+
context "with valid parameters" do
|
785
|
+
around(:each) do |spec|
|
786
|
+
# @service.connection = @connection
|
787
|
+
::VCR.use_cassette("foscam_set_pppoe") do
|
788
|
+
spec.run
|
789
|
+
end
|
790
|
+
end
|
791
|
+
it "returns a hash of variables" do
|
792
|
+
params = {enable: 1, user: "root", pwd: "pass"}
|
793
|
+
response = @service.set_pppoe(params)
|
794
|
+
response.should be_true
|
795
|
+
end
|
796
|
+
end
|
797
|
+
context "with invalid parameters" do
|
798
|
+
it "raises an exception when username is more than 40 characters long" do
|
799
|
+
expect {@service.set_pppoe(user: "01234567890123456789012345678901234567891")}.to raise_error
|
800
|
+
end
|
801
|
+
it "raises an exception when password is more than 20 characters long" do
|
802
|
+
expect {@service.set_pppoe(pwd: "012345678901234567890")}.to raise_error
|
803
|
+
end
|
804
|
+
end
|
805
|
+
context "response is unsuccessful" do
|
806
|
+
before(:each) do
|
807
|
+
response = ::Faraday::Response.new
|
808
|
+
response.stub!(:success?).and_return(false)
|
809
|
+
@connection.stub(:get).with('set_pppoe.cgi?').and_return(response)
|
810
|
+
@service.connection = @connection
|
811
|
+
end
|
812
|
+
it "returns a hash of variables" do
|
813
|
+
params = {}
|
814
|
+
response = @service.set_pppoe(params)
|
815
|
+
response.should be_false
|
816
|
+
end
|
817
|
+
end
|
818
|
+
end
|
819
|
+
|
820
|
+
describe "#set_upnp" do
|
821
|
+
context "with valid parameters" do
|
822
|
+
around(:each) do |spec|
|
823
|
+
# @service.connection = @connection
|
824
|
+
::VCR.use_cassette("foscam_set_upnp") do
|
825
|
+
spec.run
|
826
|
+
end
|
827
|
+
end
|
828
|
+
it "returns a hash of variables" do
|
829
|
+
response = @service.set_upnp(1)
|
830
|
+
response.should be_true
|
831
|
+
end
|
832
|
+
end
|
833
|
+
|
834
|
+
context "response is unsuccessful" do
|
835
|
+
before(:each) do
|
836
|
+
response = ::Faraday::Response.new
|
837
|
+
response.stub!(:success?).and_return(false)
|
838
|
+
@connection.stub(:get).with('set_upnp.cgi?enable=1').and_return(response)
|
839
|
+
@service.connection = @connection
|
840
|
+
end
|
841
|
+
it "returns a hash of variables" do
|
842
|
+
response = @service.set_upnp(1)
|
843
|
+
response.should be_false
|
844
|
+
end
|
845
|
+
end
|
846
|
+
|
847
|
+
end
|
848
|
+
|
849
|
+
describe "#set_ddns" do
|
850
|
+
context "with valid parameters" do
|
851
|
+
around(:each) do |spec|
|
852
|
+
# @service.connection = @connection
|
853
|
+
::VCR.use_cassette("foscam_set_ddns") do
|
854
|
+
spec.run
|
855
|
+
end
|
856
|
+
end
|
857
|
+
it "returns a hash of variables" do
|
858
|
+
params = {service: 3, user: "root", pwd: "password", host: "hostname.dyndns.com"}
|
859
|
+
response = @service.set_ddns(params)
|
860
|
+
response.should be_true
|
861
|
+
end
|
862
|
+
end
|
863
|
+
context "with invalid parameters" do
|
864
|
+
it "raises an exception when username is more than 20 characters long" do
|
865
|
+
expect {@service.set_ddns(user: "012345678901234567890")}.to raise_error
|
866
|
+
end
|
867
|
+
it "raises an exception when password is more than 20 characters long" do
|
868
|
+
expect {@service.set_ddns(pwd: "012345678901234567890")}.to raise_error
|
869
|
+
end
|
870
|
+
it "raises an exception when proxy_svr is more than 20 characters long" do
|
871
|
+
expect {@service.set_ddns(proxy_svr: "012345678901234567890")}.to raise_error
|
872
|
+
end
|
873
|
+
it "raises an exception when host is more than 40 characters long" do
|
874
|
+
expect {@service.set_ddns(host: "01234567890123456789012345678901234567890")}.to raise_error
|
875
|
+
end
|
876
|
+
end
|
877
|
+
context "response is unsuccessful" do
|
878
|
+
before(:each) do
|
879
|
+
response = ::Faraday::Response.new
|
880
|
+
response.stub!(:success?).and_return(false)
|
881
|
+
@connection.stub(:get).with('set_ddns.cgi?').and_return(response)
|
882
|
+
@service.connection = @connection
|
883
|
+
end
|
884
|
+
it "returns a hash of variables" do
|
885
|
+
response = @service.set_ddns({})
|
886
|
+
response.should be_false
|
887
|
+
end
|
888
|
+
end
|
889
|
+
end
|
890
|
+
|
891
|
+
describe "#set_ftp" do
|
892
|
+
|
893
|
+
context "with valid parameters" do
|
894
|
+
around(:each) do |spec|
|
895
|
+
# @service.connection = @connection
|
896
|
+
::VCR.use_cassette("foscam_set_ftp") do
|
897
|
+
spec.run
|
898
|
+
end
|
899
|
+
end
|
900
|
+
it "returns a hash of variables" do
|
901
|
+
params = {svr:"192.168.0.116", port:21, user:"my_username", pwd:"my_password", dir:"R2D2", upload_interval: 3600}
|
902
|
+
response = @service.set_ftp(params)
|
903
|
+
response.should be_true
|
904
|
+
end
|
905
|
+
end
|
906
|
+
|
907
|
+
context "response is unsuccessful" do
|
908
|
+
before(:each) do
|
909
|
+
response = ::Faraday::Response.new
|
910
|
+
response.stub!(:success?).and_return(false)
|
911
|
+
@connection.stub(:get).with('set_ftp.cgi?').and_return(response)
|
912
|
+
@service.connection = @connection
|
913
|
+
end
|
914
|
+
it "returns a hash of variables" do
|
915
|
+
response = @service.set_ftp({})
|
916
|
+
response.should be_false
|
917
|
+
end
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
describe "#set_mail" do
|
922
|
+
|
923
|
+
context "with valid parameters" do
|
924
|
+
around(:each) do |spec|
|
925
|
+
# @service.connection = @connection
|
926
|
+
::VCR.use_cassette("foscam_set_mail") do
|
927
|
+
spec.run
|
928
|
+
end
|
929
|
+
end
|
930
|
+
it "returns a hash of variables" do
|
931
|
+
params = {svr:"smtp.gmail.com", port: 465, user: "username@gmail.com", pwd:"password", sender: "sender@gmail.com", receiver1: "receiver@gmail.com"}
|
932
|
+
response = @service.set_mail(params)
|
933
|
+
response.should be_true
|
934
|
+
end
|
935
|
+
end
|
936
|
+
context "with invalid parameters" do
|
937
|
+
it "raises an exception when username is more than 20 characters long" do
|
938
|
+
expect {@service.set_mail(user: "012345678901234567890")}.to raise_error
|
939
|
+
end
|
940
|
+
it "raises an exception when password is more than 20 characters long" do
|
941
|
+
expect {@service.set_mail(pwd: "012345678901234567890")}.to raise_error
|
942
|
+
end
|
943
|
+
end
|
944
|
+
context "response is unsuccessful" do
|
945
|
+
before(:each) do
|
946
|
+
response = ::Faraday::Response.new
|
947
|
+
response.stub!(:success?).and_return(false)
|
948
|
+
@connection.stub(:get).with('set_mail.cgi?').and_return(response)
|
949
|
+
@service.connection = @connection
|
950
|
+
end
|
951
|
+
it "returns a hash of variables" do
|
952
|
+
response = @service.set_mail({})
|
953
|
+
response.should be_false
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
957
|
+
end
|
958
|
+
|
959
|
+
describe "#set_alarm" do
|
960
|
+
|
961
|
+
context "with valid parameters" do
|
962
|
+
around(:each) do |spec|
|
963
|
+
# @service.connection = @connection
|
964
|
+
::VCR.use_cassette("foscam_set_alarm") do
|
965
|
+
spec.run
|
966
|
+
end
|
967
|
+
end
|
968
|
+
it "returns a hash of variables" do
|
969
|
+
params = {motion_armed: 0, motion_sensitivity:3, input_armed: 0, iolinkage: 0, mail:0, upload_interval:0}
|
970
|
+
response = @service.set_alarm(params)
|
971
|
+
response.should be_true
|
972
|
+
end
|
973
|
+
end
|
974
|
+
|
975
|
+
context "response is unsuccessful" do
|
976
|
+
before(:each) do
|
977
|
+
response = ::Faraday::Response.new
|
978
|
+
response.stub!(:success?).and_return(false)
|
979
|
+
@connection.stub(:get).with('set_alarm.cgi?').and_return(response)
|
980
|
+
@service.connection = @connection
|
981
|
+
end
|
982
|
+
it "returns a hash of variables" do
|
983
|
+
response = @service.set_alarm({})
|
984
|
+
response.should be_false
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
end
|
989
|
+
|
990
|
+
describe "#comm_write" do
|
991
|
+
|
992
|
+
context "with valid parameters" do
|
993
|
+
around(:each) do |spec|
|
994
|
+
# @service.connection = @connection
|
995
|
+
::VCR.use_cassette("foscam_comm_write") do
|
996
|
+
spec.run
|
997
|
+
end
|
998
|
+
end
|
999
|
+
it "returns a hash of variables" do
|
1000
|
+
params = {port:0, baud: 15, bytes: "dsfds", data:"url_code"}
|
1001
|
+
response = @service.comm_write(params)
|
1002
|
+
response.should be_true
|
1003
|
+
end
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
context "response is unsuccessful" do
|
1007
|
+
before(:each) do
|
1008
|
+
response = ::Faraday::Response.new
|
1009
|
+
response.stub!(:success?).and_return(false)
|
1010
|
+
@connection.stub(:get).with('comm_write.cgi?').and_return(response)
|
1011
|
+
@service.connection = @connection
|
1012
|
+
end
|
1013
|
+
it "returns a hash of variables" do
|
1014
|
+
response = @service.comm_write({})
|
1015
|
+
response.should be_false
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
describe "#set_forbidden" do
|
1022
|
+
context "with valid parameters" do
|
1023
|
+
around(:each) do |spec|
|
1024
|
+
# @service.connection = @connection
|
1025
|
+
::VCR.use_cassette("foscam_set_forbidden") do
|
1026
|
+
spec.run
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
it "returns a hash of variables" do
|
1030
|
+
params = {
|
1031
|
+
schedule_sun_0: 95, schedule_sun_1: 45, schedule_sun_2: 20,
|
1032
|
+
schedule_mon_0: 95, schedule_mon_1: 45, schedule_mon_2: 20,
|
1033
|
+
schedule_tue_0: 95, schedule_tue_1: 45, schedule_tue_2: 20,
|
1034
|
+
schedule_wed_0: 95, schedule_wed_1: 45, schedule_wed_2: 20,
|
1035
|
+
schedule_thu_0: 95, schedule_thu_1: 45, schedule_thu_2: 20,
|
1036
|
+
schedule_fri_0: 95, schedule_fri_1: 45, schedule_fri_2: 20,
|
1037
|
+
schedule_sat_0: 95, schedule_sat_1: 45, schedule_sat_2: 20
|
1038
|
+
}
|
1039
|
+
response = @service.set_forbidden(params)
|
1040
|
+
response.should be_true
|
1041
|
+
end
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
context "response is unsuccessful" do
|
1045
|
+
before(:each) do
|
1046
|
+
response = ::Faraday::Response.new
|
1047
|
+
response.stub!(:success?).and_return(false)
|
1048
|
+
@connection.stub(:get).with('set_forbidden.cgi?').and_return(response)
|
1049
|
+
@service.connection = @connection
|
1050
|
+
end
|
1051
|
+
it "returns a hash of variables" do
|
1052
|
+
response = @service.set_forbidden({})
|
1053
|
+
response.should be_false
|
1054
|
+
end
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
describe "#get_forbidden" do
|
1059
|
+
context "response is successful" do
|
1060
|
+
around(:each) do |spec|
|
1061
|
+
# @service.connection = @connection
|
1062
|
+
::VCR.use_cassette("foscam_get_forbidden") do
|
1063
|
+
spec.run
|
1064
|
+
end
|
1065
|
+
end
|
1066
|
+
it "returns a hash of variables" do
|
1067
|
+
response = @service.get_forbidden
|
1068
|
+
[ :schedule_sun_0, :schedule_sun_1, :schedule_sun_2,
|
1069
|
+
:schedule_mon_0, :schedule_mon_1, :schedule_mon_2,
|
1070
|
+
:schedule_tue_0, :schedule_tue_1, :schedule_tue_2,
|
1071
|
+
:schedule_wed_0, :schedule_wed_1, :schedule_wed_2,
|
1072
|
+
:schedule_thu_0, :schedule_thu_1, :schedule_thu_2,
|
1073
|
+
:schedule_fri_0, :schedule_fri_1, :schedule_fri_2,
|
1074
|
+
:schedule_sat_0, :schedule_sat_1, :schedule_sat_2
|
1075
|
+
].each do |key|
|
1076
|
+
response.should have_key(key)
|
1077
|
+
end
|
1078
|
+
end
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
context "response is unsuccessful" do
|
1082
|
+
before(:each) do
|
1083
|
+
response = ::Faraday::Response.new
|
1084
|
+
response.stub!(:success?).and_return(false)
|
1085
|
+
@connection.stub(:get).with('get_forbidden.cgi').and_return(response)
|
1086
|
+
@service.connection = @connection
|
1087
|
+
end
|
1088
|
+
it "returns a hash of variables" do
|
1089
|
+
response = @service.get_forbidden
|
1090
|
+
response.should == {}
|
1091
|
+
end
|
1092
|
+
end
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
describe "#set_misc" do
|
1096
|
+
context "with valid parameters" do
|
1097
|
+
around(:each) do |spec|
|
1098
|
+
# @service.connection = @connection
|
1099
|
+
::VCR.use_cassette("foscam_set_misc") do
|
1100
|
+
spec.run
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
it "returns a hash of variables" do
|
1104
|
+
@params = {
|
1105
|
+
:led_mode => :mode1,
|
1106
|
+
:ptz_center_onstart => false,
|
1107
|
+
:ptz_auto_patrol_interval => 5,
|
1108
|
+
:ptz_auto_patrol_type => :vertical,
|
1109
|
+
:ptz_patrol_h_rounds => 1,
|
1110
|
+
:ptz_patrol_v_rounds => 1,
|
1111
|
+
:ptz_patrol_rate => 20,
|
1112
|
+
:ptz_patrol_up_rate => 10,
|
1113
|
+
:ptz_patrol_down_rate => 10,
|
1114
|
+
:ptz_patrol_left_rate => 10,
|
1115
|
+
:ptz_patrol_right_rate => 10,
|
1116
|
+
:ptz_disable_preset => false,
|
1117
|
+
:ptz_preset_onstart => true
|
1118
|
+
}
|
1119
|
+
response = @service.set_misc(@params)
|
1120
|
+
response.should be_true
|
1121
|
+
response = @service.get_misc
|
1122
|
+
@params.each do |key, value|
|
1123
|
+
response[key].should == value
|
1124
|
+
end
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
context "with invalid parameters" do
|
1129
|
+
it "raises an exception when patrol rates are > 100" do
|
1130
|
+
[:ptz_patrol_rate, :ptz_patrol_up_rate, :ptz_patrol_down_rate, :ptz_patrol_left_rate, :ptz_patrol_right_rate].each do |key|
|
1131
|
+
expect {@service.set_misc(key => 101)}.to raise_error
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
it "raises an exception when patrol rates and rounds are < 0" do
|
1135
|
+
[:ptz_auto_patrol_interval, :ptz_patrol_h_rounds, :ptz_patrol_v_rounds, :ptz_patrol_rate, :ptz_patrol_up_rate, :ptz_patrol_down_rate, :ptz_patrol_left_rate, :ptz_patrol_right_rate].each do |key|
|
1136
|
+
expect {@service.set_misc(key => -1)}.to raise_error
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
it "raises an exception when password is more than 20 characters long" do
|
1141
|
+
expect {@service.set_misc(pwd: "012345678901234567890")}.to raise_error
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
it "raises an exception if there is no match for the led_mode" do
|
1145
|
+
expect {@service.set_misc(led_mode: :mode5)}.to raise_error
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
it "raises an exception if there is no match for the ptz_auto_patrol_type" do
|
1149
|
+
expect {@service.set_misc(ptz_auto_patrol_type: :vert)}.to raise_error
|
1150
|
+
end
|
1151
|
+
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
context "response is unsuccessful" do
|
1155
|
+
before(:each) do
|
1156
|
+
response = ::Faraday::Response.new
|
1157
|
+
response.stub!(:success?).and_return(false)
|
1158
|
+
@connection.stub(:get).with('set_misc.cgi?').and_return(response)
|
1159
|
+
@service.connection = @connection
|
1160
|
+
end
|
1161
|
+
it "returns a hash of variables" do
|
1162
|
+
response = @service.set_misc({})
|
1163
|
+
response.should be_false
|
1164
|
+
end
|
1165
|
+
end
|
1166
|
+
end
|
1167
|
+
|
1168
|
+
describe "#get_misc" do
|
1169
|
+
context "response is successful" do
|
1170
|
+
around(:each) do |spec|
|
1171
|
+
# @service.connection = @connection
|
1172
|
+
::VCR.use_cassette("foscam_get_misc") do
|
1173
|
+
spec.run
|
1174
|
+
end
|
1175
|
+
end
|
1176
|
+
it "returns a hash of variables" do
|
1177
|
+
response = @service.get_misc
|
1178
|
+
[:led_mode, :ptz_center_onstart, :ptz_auto_patrol_interval, :ptz_auto_patrol_type, :ptz_patrol_h_rounds, :ptz_patrol_v_rounds, :ptz_patrol_rate, :ptz_patrol_up_rate, :ptz_patrol_down_rate, :ptz_patrol_left_rate, :ptz_patrol_right_rate, :ptz_disable_preset, :ptz_preset_onstart].each do |key|
|
1179
|
+
response.should have_key(key)
|
1180
|
+
end
|
1181
|
+
end
|
1182
|
+
|
1183
|
+
it "sets onstart fields as a boolean" do
|
1184
|
+
response = @service.get_misc
|
1185
|
+
[:ptz_disable_preset, :ptz_preset_onstart, :ptz_center_onstart].each do |key|
|
1186
|
+
response[key].should be_a_kind_of(Boolean)
|
1187
|
+
end
|
1188
|
+
end
|
1189
|
+
|
1190
|
+
it "sets the patrol round, rates, and intervals as an integer" do
|
1191
|
+
response = @service.get_misc
|
1192
|
+
[
|
1193
|
+
:ptz_auto_patrol_interval, :ptz_patrol_h_rounds, :ptz_patrol_v_rounds, :ptz_patrol_rate,
|
1194
|
+
:ptz_patrol_up_rate, :ptz_patrol_down_rate, :ptz_patrol_left_rate, :ptz_patrol_right_rate
|
1195
|
+
].each do |key|
|
1196
|
+
response[key].should be_a_kind_of(Integer)
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
it "sets the led_mode as a symbol" do
|
1201
|
+
response = @service.get_misc
|
1202
|
+
response[:led_mode].should be_a_kind_of(Symbol)
|
1203
|
+
::Foscam::LED_MODE.values.should include(response[:led_mode])
|
1204
|
+
end
|
1205
|
+
|
1206
|
+
it "sets the ptz_auto_patrol_type as a symbol" do
|
1207
|
+
response = @service.get_misc
|
1208
|
+
response[:ptz_auto_patrol_type].should be_a_kind_of(Symbol)
|
1209
|
+
::Foscam::PTZ_AUTO_PATROL_TYPE.values.should include(response[:ptz_auto_patrol_type])
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
context "response is unsuccessful" do
|
1215
|
+
before(:each) do
|
1216
|
+
response = ::Faraday::Response.new
|
1217
|
+
response.stub!(:success?).and_return(false)
|
1218
|
+
@connection.stub(:get).with('get_misc.cgi').and_return(response)
|
1219
|
+
@service.connection = @connection
|
1220
|
+
end
|
1221
|
+
it "returns a hash of variables" do
|
1222
|
+
response = @service.get_misc
|
1223
|
+
response.should == {}
|
1224
|
+
end
|
1225
|
+
end
|
1226
|
+
end
|
1227
|
+
|
1228
|
+
describe "#set_decoder" do
|
1229
|
+
context "with valid parameters" do
|
1230
|
+
around(:each) do |spec|
|
1231
|
+
# @service.connection = @connection
|
1232
|
+
::VCR.use_cassette("foscam_set_decoder") do
|
1233
|
+
spec.run
|
1234
|
+
end
|
1235
|
+
end
|
1236
|
+
it "sets the baud with an integer" do
|
1237
|
+
baud = 9
|
1238
|
+
response = @service.set_decoder(baud)
|
1239
|
+
response.should be_true
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
it "sets the baud with a symbol" do
|
1243
|
+
baud = :B1200
|
1244
|
+
response = @service.set_decoder(baud)
|
1245
|
+
response.should be_true
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
it "sets the baud with a string" do
|
1249
|
+
baud = "B1200"
|
1250
|
+
response = @service.set_decoder(baud)
|
1251
|
+
response.should be_true
|
1252
|
+
end
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
context "response is unsuccessful" do
|
1256
|
+
before(:each) do
|
1257
|
+
response = ::Faraday::Response.new
|
1258
|
+
response.stub!(:success?).and_return(false)
|
1259
|
+
@connection.stub(:get).with('set_decoder.cgi?baud=9').and_return(response)
|
1260
|
+
@service.connection = @connection
|
1261
|
+
end
|
1262
|
+
it "returns a hash of variables" do
|
1263
|
+
response = @service.set_decoder(9)
|
1264
|
+
response.should be_false
|
1265
|
+
end
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
end
|