spec/nsisam_spec.rb in nsisam-0.3.4 vs spec/nsisam_spec.rb in nsisam-0.4.0

- old
+ new

@@ -1,22 +1,24 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe NSISam do before :all do - @nsisam = NSISam::Client.new 'http://test:test@localhost:8888' + @nsisam = NSISam::Client.new user: 'test', password: 'test', + host: 'localhost', port: '8888' @keys = Array.new @fake_sam = NSISam::FakeServerManager.new.start_server end after :all do @fake_sam.stop_server end context "cannot connect to server" do it "throws error if couldn't connect to the server" do - sam = NSISam::Client.new 'http://test:test@localhost:4000' + sam = NSISam::Client.new user: 'test', password: 'test', + host: 'localhost', port: '4000' expect { sam.store('anything') }.to raise_error(NSISam::Errors::Client::ConnectionRefusedError) end end context "storing" do @@ -76,6 +78,32 @@ it "raises error when key not found" do expect { @nsisam.update("dont exist ruby is fast", "foo") }.to raise_error(NSISam::Errors::Client::KeyNotFoundError) end end + context "get configuration" do + before do + NSISam::Client.configure do + user "why" + password "chunky" + host "localhost" + port "8888" + end + end + + it "by configure" do + sam = NSISam::Client.new + sam.instance_variable_get(:@user).should == "why" + sam.instance_variable_get(:@password).should == "chunky" + sam.instance_variable_get(:@host).should == "localhost" + sam.instance_variable_get(:@port).should == "8888" + end + + it "by initialize parameters" do + sam = NSISam::Client.new(user: 'luckystiff', password: 'bacon', host: 'why.com', port: '9999') + sam.instance_variable_get(:@user).should == "luckystiff" + sam.instance_variable_get(:@password).should == "bacon" + sam.instance_variable_get(:@host).should == "why.com" + sam.instance_variable_get(:@port).should == "9999" + end + end end