Sha256: f0ec6f6dfdc0894f2ceaed67e4384af251acb9d03ea00370ebcec22ca3f78998

Contents?: true

Size: 1.22 KB

Versions: 15

Compression:

Stored size: 1.22 KB

Contents

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

require 'minitest/autorun'
require 'set'
require 'webgen/source'
require 'webgen/path'

class Webgen::Source::MySource

  def initialize(website, paths); @paths = paths; end
  def paths; Set.new(@paths); end

end

class TestSource < Minitest::Test

  def setup
    @website = Object.new
    @src = Webgen::Source.new(@website)
  end

  def test_register
    @src.register('Webgen::Destination::MySource')
    assert(@src.registered?('my_source'))

    @src.register('MySource')
    assert(@src.registered?('my_source'))

    @src.register('MySource', :name => 'test')
    assert(@src.registered?('test'))

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

  def test_paths
    @src.register('Stacked')
    @src.register('MySource')

    path1 = Webgen::Path.new('/path1.file')
    path2 = Webgen::Path.new('/path2.data')
    path3 = Webgen::Path.new('/path3.file')

    @src.passive_sources << ['/', 'my_source', [path2]]
    @website.define_singleton_method(:config) do
      {'sources' => [['/', 'my_source', [path1]], ['/hallo/', 'my_source', [path3]]],
        'sources.ignore_paths' => ['/**/*.data']}
    end

    assert_equal([path1, path3.mount_at('/hallo/')], @src.paths)
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
webgen-1.7.3 test/webgen/test_source.rb
webgen-1.7.2 test/webgen/test_source.rb
webgen-1.7.1 test/webgen/test_source.rb
webgen-1.7.0 test/webgen/test_source.rb
webgen-1.6.0 test/webgen/test_source.rb
webgen-1.5.2 test/webgen/test_source.rb
webgen-1.5.1 test/webgen/test_source.rb
webgen-1.5.0 test/webgen/test_source.rb
webgen-1.4.1 test/webgen/test_source.rb
webgen-1.4.0 test/webgen/test_source.rb
webgen-1.3.0 test/webgen/test_source.rb
webgen-1.2.1 test/webgen/test_source.rb
webgen-1.2.0 test/webgen/test_source.rb
webgen-1.1.0 test/webgen/test_source.rb
webgen-1.0.0 test/webgen/test_source.rb