Sha256: 5df86d9df20aa4a84104cdc2e7b8242f851de6132bcbcc6f8d87a81b796ab6b6

Contents?: true

Size: 1.26 KB

Versions: 15

Compression:

Stored size: 1.26 KB

Contents

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

require 'fileutils'
require 'tmpdir'
require 'minitest/autorun'
require 'webgen/website'

class TestWebsite < Minitest::Test

  def test_initialize
    i = 0
    ws = Webgen::Website.new('dir') do |website, before|
      if i == 0
        assert_equal(true, before)
      else
        assert_equal(false, before)
      end
      i += 1
    end
    assert(ws.blackboard)
    assert(ws.cache)
    assert(ws.config)
    assert(ws.tree)
    assert_equal('dir', ws.directory)
  end

  def test_read_config_file
    Dir.mktmpdir do |dir|
      File.open(File.join(dir, 'webgen.config'), 'w+') {|f| f.write('- unknown')}
      assert_raises(Webgen::Configuration::Error) { Webgen::Website.new(dir) }

      File.open(File.join(dir, 'webgen.config'), 'w+') {|f| f.write("# ruby\nwebsitesdf'] =")}
      assert_raises(Webgen::Error) { Webgen::Website.new(dir) }

      File.open(File.join(dir, 'webgen.config'), 'w+') {|f| f.write('website.lang: de')}
      ws = Webgen::Website.new(dir)
      assert_equal('de', ws.config['website.lang'])

      File.open(File.join(dir, 'webgen.config'), 'w+') {|f| f.write("# -*- ruby -*-\nwebsite.config['website.lang'] = 'de'")}
      ws = Webgen::Website.new(dir)
      assert_equal('de', ws.config['website.lang'])
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

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