Sha256: 189657b9354198017d79479a98c14f6f5eb878c8e82013c7f37573e4382c1682
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
require "spec_helper" include Rmpd describe Connection do before(:each) do @socket = mock_socket @config = mock_config @conn = Connection.new end def set_password(password="foobar") @config.stub!(:password).and_return(password) end it "should connect successfully" do responses = connect_response + ok @socket.should_receive(:readline).and_return(*responses) @conn.connect @conn.ping end it "should authenticate successfully" do responses = connect_and_auth_responses + ok set_password @socket.should_receive(:readline).and_return(*responses) @conn.connect @conn.ping end it "should generate a server version" do pending "Do I care anymore?" version = "0.1.2" responses = connect_response(version) + ok @socket.should_receive(:readline).and_return(*responses) @conn.ping # so we connect, and get the server version @conn.server_version.should == version end it "should handle connection failures gracefully" do @socket.stub!(:connect).and_raise(Errno::ECONNREFUSED.new("test")) lambda do @conn.connect @conn.ping end.should raise_error(Rmpd::MpdError) end it "should restrict access based on server version" do pending "Do I care anymore?" responses = connect_response("0.1.0") @socket.stub!(:readline).and_return(*responses) @conn.instance_eval do def sval(*args) server_version_at_least(*args) end end lambda do @conn.sval(0, 1, 2) end.should raise_error(MpdError) lambda do @conn.sval(0, 1, 0) end.should_not raise_error(MpdError) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rmpd-1.1.16 | spec/models/connection_spec.rb |