Sha256: 78a947ceeeedab23c16ea32da235966ed1704020ba360f390d6ea31f00cf08a3

Contents?: true

Size: 953 Bytes

Versions: 65

Compression:

Stored size: 953 Bytes

Contents

require 'em_test_helper'

class TestStomp < Test::Unit::TestCase
  CONTENT_LENGTH_REGEX = /^content-length: (\d+)$/

  def bytesize(str)
    str = str.to_s
    size = str.bytesize if str.respond_to?(:bytesize) # bytesize added in 1.9
    size || str.size
  end

  def test_content_length_in_bytes
    connection = Object.new
    connection.instance_eval do 
      extend EM::P::Stomp

      def last_sent_content_length
        @sent && Integer(@sent[CONTENT_LENGTH_REGEX, 1])
      end

      def send_data(string)
        @sent = string
      end
    end

    queue = "queue"
    failure_message = "header content-length is not the byte size of last sent body"

    body = "test"
    connection.send queue, body
    assert_equal bytesize(body), connection.last_sent_content_length, failure_message

    body = "test\u221A"
    connection.send queue, body
    assert_equal bytesize(body), connection.last_sent_content_length, failure_message
  end
end

Version data entries

65 entries across 64 versions & 5 rubygems

Version Path
sensu-em-2.7.0-java tests/test_stomp.rb
arcabouco-0.2.13 vendor/bundle/gems/eventmachine-1.2.0.1/tests/test_stomp.rb
arcabouco-0.2.13 vendor/bundle/gems/eventmachine-1.2.1/tests/test_stomp.rb
eventmachine-1.2.1-java tests/test_stomp.rb
eventmachine-1.2.1-x64-mingw32 tests/test_stomp.rb
eventmachine-1.2.1-x86-mingw32 tests/test_stomp.rb
eventmachine-1.2.1 tests/test_stomp.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.2.0.1/tests/test_stomp.rb
sensu-em-2.6.0-java tests/test_stomp.rb
eventmachine-1.2.0.1-java tests/test_stomp.rb
eventmachine-1.2.0.1-x86-mingw32 tests/test_stomp.rb
eventmachine-1.2.0.1-x64-mingw32 tests/test_stomp.rb
eventmachine-1.2.0.1 tests/test_stomp.rb
eventmachine-1.2.0 tests/test_stomp.rb
eventmachine-1.2.0-x86-mingw32 tests/test_stomp.rb
eventmachine-1.2.0-x64-mingw32 tests/test_stomp.rb
eventmachine-1.2.0.dev.2 tests/test_stomp.rb
eventmachine-1.2.0.dev.2-x86-mingw32 tests/test_stomp.rb
eventmachine-1.2.0.dev.2-x64-mingw32 tests/test_stomp.rb
eventmachine-1.0.9.1 tests/test_stomp.rb