spec/config_spec.rb in electric_eye-0.0.3 vs spec/config_spec.rb in electric_eye-0.0.5
- old
+ new
@@ -87,19 +87,31 @@
include FakeFS::SpecHelpers
before do
@configEye = ConfigEye.new
end
-
- it "adds camera to array" do
- @configEye.add_camera("Reception", "http://user:pass@my.camera.org/live2.sdp")
- expect(@configEye.config.cameras.length).to equal(1)
+
+ context "when both name & url provided" do
+ it "adds camera to array" do
+ @configEye.add_camera("Reception", "http://user:pass@my.camera.org/live2.sdp")
+ expect(@configEye.config.cameras.length).to equal(1)
+ end
+
+ it "calls save" do
+ expect(@configEye).to receive(:save).once
+ @configEye.add_camera("Reception", "http://user:pass@my.camera.org/live2.sdp")
+ end
end
- it "calls save" do
- expect(@configEye).to receive(:save).once
- @configEye.add_camera("Reception", "http://user:pass@my.camera.org/live2.sdp")
+ context "when only name provided" do
+ it "returns an error" do
+ end
+
+ it "doesn't call save" do
+ expect(@configEye).to receive(:save).never
+ @configEye.add_camera("Reception", nil)
+ end
end
end
describe "remove camera" do
include FakeFS::SpecHelpers
@@ -185,6 +197,33 @@
expect(@configEye).to receive(:save).once
@configEye.set_path('/data/recordings')
end
end
end
+
+describe "set_threshold" do
+ include FakeFS::SpecHelpers
+
+ before do
+ @configEye = ConfigEye.new
+ end
+
+ context "when no threshold has been set" do
+ it "returns the default of 2 objects" do
+ expect(@configEye.config.threshold).to equal(2)
+ end
+ end
+
+ context "when calling with -d 3" do
+ it "returns 3" do
+ @configEye.set_threshold(3)
+ expect(@configEye.config.threshold).to equal(3)
+ end
+
+ it "calls save" do
+ expect(@configEye).to receive(:save).once
+ @configEye.set_threshold(3)
+ end
+ end
+end
+