Sha256: 6dca32442743011f76b2bb491125a990fc301152a733f8ed88881f05fc58668d

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

# -*- encoding: utf-8 -*-

require 'minitest/autorun'
require 'webgen/destination'

class Webgen::Destination::MyDestination

  def initialize(website); end

end

class TestDestination < Minitest::Test

  def setup
    @website = MiniTest::Mock.new
    @dest = Webgen::Destination.new(@website)
  end

  def test_register
    @dest.register('Webgen::Destination::MyDestination')
    assert(@dest.registered?('my_destination'))

    @dest.register('MyDestination')
    assert(@dest.registered?('my_destination'))

    @dest.register('MyDestination', :name => 'test')
    assert(@dest.registered?('test'))

    assert_raises(ArgumentError) { @dest.register('doit') { "nothing" } }
  end

  def test_instance
    @dest.register('MyDestination')

    @website.expect(:config, {'destination' => 'unknown'})
    assert_raises(Webgen::Error) { @dest.instance_eval { instance } }
    @website.verify

    @website.expect(:config, {'destination' => 'my_destination'})
    assert_kind_of(Webgen::Destination::MyDestination, @dest.instance_eval { instance })
    @website.verify

    @website.expect(:config, {'destination' => 'unknown'})
    @dest.instance_eval { instance } # nothing should be raised
    @website.verify
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
webgen-1.4.0 test/webgen/test_destination.rb
webgen-1.3.0 test/webgen/test_destination.rb
webgen-1.2.1 test/webgen/test_destination.rb
webgen-1.2.0 test/webgen/test_destination.rb
webgen-1.1.0 test/webgen/test_destination.rb
webgen-1.0.0 test/webgen/test_destination.rb