Sha256: 36e3f2c6b93056fac2473d65ab5c1cf70cb58aa73bd397c9d48425326cd867ff

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

require_relative "../../test_helper"

module Unit
  module Connection
    class TestSetup < MiniTest::Test

      class Connection < SimpleConnection
        include MonetDB::Connection::Messages
      end

      describe MonetDB::Connection::Messages do
        before do
          @connection = Connection.new
        end

        describe "#msg_chr" do
          describe "when passing an empty string" do
            it "returns an empty string" do
              assert_equal "", @connection.send(:msg_chr, "")
            end
          end

          describe "when passing a non-empty string" do
            it "returns the first character" do
              assert_equal " ", @connection.send(:msg_chr, "   ")
              assert_equal "%", @connection.send(:msg_chr, "%foobar")
            end
          end
        end

        describe "#msg?" do
          it "verifies whether the passed string matches the passed message character" do
            assert_equal true , @connection.send(:msg?, "!syntax error", MonetDB::Connection::MSG_ERROR)
            assert_equal false, @connection.send(:msg?, "!syntax error", MonetDB::Connection::MSG_PROMPT)

            assert_equal true , @connection.send(:msg?, "", MonetDB::Connection::MSG_PROMPT)
            assert_equal false, @connection.send(:msg?, "", MonetDB::Connection::MSG_ERROR)

            @connection.expects(:msg_chr).with("foo").twice.returns("!")
            assert_equal true , @connection.send(:msg?, "foo", MonetDB::Connection::MSG_ERROR)
            assert_equal false, @connection.send(:msg?, "foo", MonetDB::Connection::MSG_PROMPT)
          end
        end
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
monetdb-0.2.10 test/unit/connection/test_messages.rb
monetdb-0.2.9 test/unit/connection/test_messages.rb
monetdb-0.2.8 test/unit/connection/test_messages.rb
monetdb-0.2.7 test/unit/connection/test_messages.rb
monetdb-0.2.6 test/unit/connection/test_messages.rb
monetdb-0.2.5 test/unit/connection/test_messages.rb
monetdb-0.2.4 test/unit/connection/test_messages.rb
monetdb-0.2.3 test/unit/connection/test_messages.rb
monetdb-0.2.2 test/unit/connection/test_messages.rb
monetdb-0.2.1 test/unit/connection/test_messages.rb
monetdb-0.2.0 test/unit/connection/test_messages.rb