Sha256: e4435057f42eacf6d1ef8e3983298b3c09ba2ecd6bbc59810e9cfcdc114ae121

Contents?: true

Size: 1.63 KB

Versions: 12

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'
require 'whois/answer/parser/base'

class AnswerParserBaseTest < Test::Unit::TestCase

  def setup
    @klass  = Whois::Answer::Parser::Base
    @part   = Whois::Answer::Part.new("This is the response.", "whois.foo.com")
  end


  def test_initialize
    parser = @klass.new(@part)
    assert_instance_of @klass, parser
  end

  def test_initialize_should_require_part
    assert_raise(ArgumentError) { @klass.new }
  end


  def test_content
    parser = @klass.new(@part)
    assert_equal @part.response, parser.content
  end

  def test_content_for_scanner
    parser = @klass.new(Whois::Answer::Part.new("This is\r\nthe response.", "whois.foo.com"))
    assert_equal "This is\nthe response.", parser.send(:content_for_scanner)
    assert_equal "This is\nthe response.", parser.instance_variable_get(:"@content_for_scanner")
  end


  def test_property_supported?
    klass = Class.new(@klass) do
    end
    assert !klass.new(@part).property_supported?(:disclaimer)
    assert  klass.new(@part).respond_to?(:disclaimer)

    klass = Class.new(@klass) do
      register_property(:disclaimer, :supported) {}
    end
    assert  klass.new(@part).property_supported?(:disclaimer)
    assert  klass.new(@part).respond_to?(:disclaimer)
  end


  def test_self_property_registry
    assert_instance_of Hash, @klass.property_registry
  end

  def test_self_property_registry_with_klass
    assert_instance_of Hash, @klass.property_registry(Whois::Answer::Parser::WhoisNicIt)
  end

  def test_self_property_registry_with_klass_should_initialize_to_empty_hash
    parser = Class.new
    assert_equal Hash.new, @klass.property_registry(parser)
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
whois-1.0.12 test/answer/parser/base_test.rb
whois-1.0.11 test/answer/parser/base_test.rb
whois-1.0.10 test/answer/parser/base_test.rb
whois-1.0.9 test/answer/parser/base_test.rb
whois-1.0.8 test/answer/parser/base_test.rb
whois-1.0.7 test/answer/parser/base_test.rb
whois-1.0.6 test/answer/parser/base_test.rb
whois-1.0.5 test/answer/parser/base_test.rb
whois-1.0.4 test/answer/parser/base_test.rb
whois-1.0.3 test/answer/parser/base_test.rb
whois-1.0.2 test/answer/parser/base_test.rb
whois-1.0.1 test/answer/parser/base_test.rb