Sha256: eca0b697667e08199ce4c127291fdcbd3ee8c03c13cf940e062e183e7af23f92

Contents?: true

Size: 952 Bytes

Versions: 9

Compression:

Stored size: 952 Bytes

Contents

require_relative 'helper'

class ParserTest < Test::Unit::TestCase

  include AutoResp::Parser

  def test_parse_only_body
    headers, body = parse("test")
    assert_equal nil, headers
    assert_equal "test", body
  end

  def test_parse_only_header
    headers, body = parse("test: good\n\n")
    assert_equal({"test" => "good"}, headers)
    assert body.empty?
  end

  def test_parse_header
    headers, body = parse("test: good\n\ncontent")
    assert_equal({"test"=>"good"}, headers)
    assert_equal "content", body
  end

  def test_first_line_empty
    headers, body = parse("  \ntest: good\n\ncontent")
    assert_equal nil, headers
    assert_equal "  \ntest: good\n\ncontent", body
  end

  def test_empty_line_in_middle
    response = %Q(server: autoresponder\ntest: hello\n  \ntest)
    headers, body = parse(response)
    assert_equal({"server" => "autoresponder", "test" => "hello"}, headers)
    assert_equal "test", body
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
auto_response-0.2.0 test/response_text_parser_test.rb
auto_response-0.1.8 test/response_text_parser_test.rb
auto_response-0.1.6 test/response_text_parser_test.rb
auto_response-0.1.5 test/response_text_parser_test.rb
auto_response-0.1.4 test/response_text_parser_test.rb
auto_response-0.1.3 test/response_text_parser_test.rb
auto_response-0.1.2 test/response_text_parser_test.rb
auto_response-0.1.1 test/response_text_parser_test.rb
auto_response-0.1.0 test/response_text_parser_test.rb