Sha256: 32a4e75e76a0a6cee48c8086735ebacf5f59e35ec3be4a1b138abdf147f42bd5

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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_supported?
    klass = Class.new(@klass) do
      register_method(:disclaimer) {}
    end
    assert  klass.new(@part).supported?(:disclaimer)
    assert  klass.new(@part).respond_to?(:disclaimer)

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

  def test_supported_should_return_false_unless_registrable_method
    parser = @klass.new(@part)
    assert !parser.supported?(:content)
    assert  parser.respond_to?(:content)
  end


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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whois-0.8.1 test/answer/parser/base_test.rb