Sha256: 0411ec0a220742f581b0c7d8a3e1ce29b502292e78d48df03d1e722de01ca008

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

require 'assert'
require 'sanford-protocol/test_helpers'

require 'sanford-protocol/response'

module Sanford::Protocol::TestHelpers

  class UnitTests < Assert::Context
    desc "Sanford::Protocol::TestHelpers"
    subject { Sanford::Protocol::TestHelpers }

    should have_imeths :fake_socket_with_request, :fake_socket_with_msg_body
    should have_imeths :fake_socket_with_encoded_msg_body, :fake_socket_with
    should have_imeths :read_response_from_fake_socket
    should have_imeths :read_written_response_from_fake_socket

    should "be able to read responses given a fake socket" do
      setup_some_response_data
      fs = FakeSocket.new(@msg)
      response = subject.read_response_from_fake_socket(fs)

      assert_kind_of Sanford::Protocol::Response, response
      assert_equal @data, response.to_hash
    end

    should "be able to read responses written to a fake socket" do
      setup_some_response_data
      fs = FakeSocket.new; fs.send(@msg, 0)
      response = subject.read_written_response_from_fake_socket(fs)

      assert_kind_of Sanford::Protocol::Response, response
      assert_equal @data, response.to_hash
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sanford-protocol-0.12.0 test/unit/test_helpers_tests.rb
sanford-protocol-0.11.0 test/unit/test_helpers_tests.rb
sanford-protocol-0.10.0 test/unit/test_helpers_tests.rb
sanford-protocol-0.9.0 test/unit/test_helpers_tests.rb
sanford-protocol-0.8.0 test/unit/test_helpers_tests.rb
sanford-protocol-0.7.0 test/unit/test_helpers_tests.rb