test/buildmaster/site/tc_site.rb in BuildMaster-0.9.1 vs test/buildmaster/site/tc_site.rb in BuildMaster-1.0.6

- old
+ new

@@ -1,11 +1,12 @@ -$:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib") +$:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib", 'buildmaster') require 'spec' -require 'buildmaster' -require 'buildmaster/cotta' -require 'buildmaster/cotta/in_memory_system' +require 'site/site' +require 'cotta' +require 'cotta/command_interface' +require 'cotta/in_memory_system' module BuildMaster context 'Site' do setup do @@ -24,25 +25,24 @@ <body><h1>Text</h1> </body> </html> CONTENT ) - content_dir.file('markdown.markdown').save(<<CONTENT + content_dir.file('markdown.markdown').save(<<CONTENT) -------------------- markdown title -------------------- Header =============== CONTENT -) - content_dir.file('textile.textile').save(<<CONTENT + + content_dir.file('textile.textile').save(<<CONTENT) --------------------- textile title --------------------- h1. Header CONTENT -) spec = SiteSpec.new(nil, @cotta) spec.output_dir = 'site/output' spec.content_dir = 'site/content' spec.template =<<TEMPLATE <html xmlns="http://www.w3.org/1999/xhtml" @@ -55,12 +55,12 @@ </html> TEMPLATE site = Site.new(spec) site.build expected_output_file = @root.dir('output').file('index.html') - @root.exists?.should_equal(true) - expected_output_file.exists?.should_equal(true) + @root.exists?.should ==(true) + expected_output_file.exists?.should ==(true) end specify 'ignore the svn and CVS directories' do content_dir = @root.dir('content') @@ -73,10 +73,41 @@ spec.template = <<TEMPLATE <html/> TEMPLATE site = Site.new(spec) site.build - @root.dir('output').list.size.should_equal 0 + @root.dir('output').list.size.should == 0 end + + specify 'set up site based on the template' do + templates_dir = @cotta.dir('templates') + setup_template_choice_one(templates_dir) + setup_template_choice_two(templates_dir) + command_io = mock('command line io') + command_io.should_receive(:puts).exactly(4).times + command_io.should_receive(:gets).once.and_return('1') + @cotta.command_interface = CommandInterface.new(command_io) + spec = SiteSpec.new(nil, @cotta) do |spec| + spec.content_dir = 'site/content' + spec.output_dir = 'output' + spec.template_file = 'site/page_template.html' + end + Site.setup(spec, templates_dir) + spec.template_file.load.should == 'template one' + spec.content_dir.file('logo.gif').load.should == 'logo one' + end + + def setup_template_choice_one(templates_root) + root = templates_root.dir('one') + root.file('template.html').save('template one') + root.dir('content').file('logo.gif').save('logo one') + end + + def setup_template_choice_two(templates_root) + root = templates_root.dir('two') + root.file('template.html').save('template two') + root.dir('content').file('logo.gif').save('logo two') + end + end end \ No newline at end of file