Sha256: 85744f98a8a098763c1db77c3b56ed18c2ea8eb379f51ef2e1a60efa21b0a118

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

require "spec_helper"

module Rmpd
  describe Commands, "Generators" do

    before(:each) do
      @config = mock_config
      @socket = mock_socket
      @conn = Connection.new
    end

    describe "when version is ok" do

      before(:each) do
        version = "0.1.1"
        responses = connect_response(version) + ok
        @socket.should_receive(:readline).and_return(*responses)
      end

      describe "simple_command" do
        it "should allow based on server version" do
          Commands::simple_command(:test, :min_version => [0, 1, 1])
          lambda do
            @conn.test
          end.should_not raise_error(MpdError)
        end
      end

      describe "complex_command" do
        it "should allow based on server version" do
          Rmpd::Commands::complex_command(:test, :min_version => [0, 1, 1])
          lambda do
            @conn.test
          end.should_not raise_error(MpdError)
        end
      end
    end

    describe "when version is NOT ok" do

      before(:each) do
        version = "0.1.1"
        responses = connect_response(version)
        @socket.should_receive(:readline).and_return(*responses)
      end

      describe "simple_command" do
        it "should disallow based on server version" do
          Rmpd::Commands::simple_command(:test, :min_version => [0, 1, 2])
          lambda do
            @conn.test
          end.should raise_error(MpdError, /^Requires server version/)
        end
      end

      describe "complex_command" do
        it "should disallow based on server version" do
          Rmpd::Commands::complex_command(:test, :min_version => [0, 1, 2])
          lambda do
            @conn.test
          end.should raise_error(MpdError, /^Requires server version/)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rmpd-1.0.5 spec/models/generators_spec.rb
rmpd-1.0.4 spec/models/generators_spec.rb
rmpd-1.0.3 spec/models/generators_spec.rb
rmpd-1.0.2 spec/models/generators_spec.rb
rmpd-1.0.1 spec/models/generators_spec.rb
rmpd-1.0.0 spec/models/generators_spec.rb