Sha256: 9b0ad807603170af46462cd6369780d4f5e77698473284b25e4941a9fc3d6aac

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require File.dirname(__FILE__) + "/../lib/rmpd"


def mock_socket
  socket = mock(Socket)
  socket.stub!(:puts)
  socket.stub!(:closed?).and_return(false)
  socket.stub!(:connect)
  socket.stub!(:eof?).and_return(false)
  Socket.stub!(:pack_sockaddr_in).and_return("pack_sockaddr_in")
  Socket.stub!(:new).and_return(socket)
  socket
end

def mock_config(opts={})
  opts = {
    :hostname => Rmpd::Config::DEFAULT_HOSTNAME,
    :port => Rmpd::Config::DEFAULT_PORT,
    :password => Rmpd::Config::DEFAULT_PASSWORD,
  }.merge(opts)
  config = mock(Rmpd::Config)
  config.stub!(:hostname).and_return(opts[:hostname])
  config.stub!(:password).and_return(opts[:password])
  config.stub!(:port).and_return(opts[:port])
  Rmpd::Config.stub!(:new).and_return(config)
  config
end

def connect_response(version="0.12.0")
  ok("MPD #{version}")
end

def connect_and_auth_responses
  connect_response + ok
end

def ok(txt="")
  txt ? ["OK #{txt}\n"] : ["OK\n"]
end

def ack(x=1, y=2, cmd="foo_command", msg="No one's home dopey!")
  ["ACK [#{x}@#{y}] {#{cmd}} #{msg}"]
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rmpd-1.0.1 spec/spec_helper.rb
rmpd-1.0.0 spec/spec_helper.rb