test/buildmaster/tc_site_spec.rb in BuildMaster-0.7.0 vs test/buildmaster/tc_site_spec.rb in BuildMaster-0.8.0

- old
+ new

@@ -4,63 +4,47 @@ require 'buildmaster' module BuildMaster class SiteSpecTest < Test::Unit::TestCase + def test_should_get_relative_path - spec = SiteSpec.new + spec = SiteSpec.new() spec.content_dir = '/one/two/content' assert_equal('images/logo.gif', spec.relative_to_root('/one/two/content/images/logo.gif').to_s) end def test_should_support_windows_path - spec = SiteSpec.new + spec = SiteSpec.new() spec.content_dir = "C:\\Work\\project\\content" assert_equal('images/logo.gif', spec.relative_to_root('C:\\Work\\project\\content\\images\\logo.gif').to_s) end - def test_should_evaluate - spec = SampleSiteSpec.new - spec.content_dir = '/one/two/content' - result = spec.evaluate('expression', '/one/two/content/dir/file.txt') - assert_equal('dir/file.txt', result) - end - - def test_should_check_for_property - spec = SiteSpec.new - spec.content_dir = "/one" - spec.add_property('release', '0.6') - assert_equal('0.6', spec.evaluate('release', '/one')) - end - - def test_should_throw_error_with_proper_message_for_expression_problem - spec = SiteSpec.new - spec.content_dir = "/one" - begin - spec.evaluate('expression', '/one/two') - fail('exception should have been thrown') - rescue RuntimeError => boom - assert_equal("Neither property nor method found with name 'expression'", boom.message) + def test_initialize_with_block + spec = SiteSpec.new(__FILE__) do |sitespec| + sitespec.content_dir = 'content' + sitespec.output_dir = 'output' + sitespec.page_layout = <<CONTENT +title_header: BuildMaster - +css_path: css.css +logo: + path: logo.gif + link: index.html +menu_groups: +- title: first menu group + menu_items: + - title: item one for g1 + link: item_one.html + - title: item two for g2 + link: item_two.html +- title: second menu group +CONTENT end + root = File.dirname(__FILE__) + assert_equal(File.join(root, 'content'), spec.content_dir) + assert_equal(File.join(root, 'output'), spec.output_dir) + assert_equal(true, spec.load_template_source.to_s.include?('first menu group')) end - def test_relative_to_root_expression - spec = SiteSpec.new - spec.content_dir = '/one' - actual = spec.evaluate('relative_to_root', '/one/two') - assert_equal(Pathname.new('two'), actual) - end - -end - -class SampleSiteSpec < SiteSpec - private - def expression(path) - return path - end - - def expression2 - return 'expected' - end end end \ No newline at end of file