Sha256: 8fbf2b6db1bc38159df37cb92fda5f43290d9d104c9125ef375deff6aeb393fc

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 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

8 entries across 8 versions & 1 rubygems

Version Path
webgen-1.7.2 test/webgen/test_destination.rb
webgen-1.7.1 test/webgen/test_destination.rb
webgen-1.7.0 test/webgen/test_destination.rb
webgen-1.6.0 test/webgen/test_destination.rb
webgen-1.5.2 test/webgen/test_destination.rb
webgen-1.5.1 test/webgen/test_destination.rb
webgen-1.5.0 test/webgen/test_destination.rb
webgen-1.4.1 test/webgen/test_destination.rb