BuildMaster 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +6 -29
- data/lib/buildmaster.rb +0 -2
- data/lib/buildmaster/ant_driver.rb +13 -12
- data/lib/buildmaster/build_number_file.rb +2 -12
- data/lib/buildmaster/buildnumber +1 -1
- data/lib/buildmaster/cotta.rb +4 -0
- data/lib/buildmaster/cotta/command_error.rb +5 -0
- data/lib/buildmaster/cotta/cotta.rb +35 -0
- data/lib/buildmaster/cotta/cotta_dir.rb +73 -0
- data/lib/buildmaster/cotta/cotta_file.rb +99 -0
- data/lib/buildmaster/cotta/file_not_found_error.rb +13 -0
- data/lib/buildmaster/cotta/in_memory_system.rb +160 -0
- data/lib/buildmaster/cotta/physical_system.rb +64 -0
- data/lib/buildmaster/cvs_driver.rb +5 -13
- data/lib/buildmaster/file_processor.rb +34 -33
- data/lib/buildmaster/java_manifest.rb +3 -3
- data/lib/buildmaster/site/site.rb +11 -22
- data/lib/buildmaster/site_spec.rb +15 -13
- data/lib/buildmaster/source_file_handler.rb +1 -1
- data/lib/buildmaster/svn_driver.rb +14 -20
- data/lib/buildmaster/{template_exception.rb → template_error.rb} +1 -1
- data/lib/buildmaster/template_runner.rb +2 -2
- data/lib/buildmaster/templatelets/attribute.rb +1 -1
- data/lib/buildmaster/templatelets/href.rb +1 -1
- data/lib/buildmaster/templatelets/text.rb +1 -1
- data/lib/buildmaster/templatelets/when.rb +1 -1
- data/lib/buildmaster/windows.rb +3 -0
- data/lib/buildmaster/windows/iis_driver.rb +33 -0
- data/lib/buildmaster/windows/sql_server_driver.rb +27 -0
- data/test/buildmaster/cotta/content.txt +3 -0
- data/test/buildmaster/cotta/cotta_specifications.rb +172 -0
- data/test/buildmaster/cotta/physical_system_stub.rb +85 -0
- data/test/buildmaster/cotta/system_file_specifications.rb +131 -0
- data/test/buildmaster/cotta/tc_cotta.rb +33 -0
- data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +23 -0
- data/test/buildmaster/cotta/tc_cotta_dir_physical.rb +17 -0
- data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +20 -0
- data/test/buildmaster/cotta/tc_cotta_file_physical.rb +17 -0
- data/test/buildmaster/cotta/tc_in_memory_system.rb +25 -0
- data/test/buildmaster/cotta/tc_physical_system.rb +26 -0
- data/test/buildmaster/manifest.mf +1 -1
- data/test/buildmaster/site/tc_site.rb +58 -34
- data/test/buildmaster/site/tc_template_builder.rb +32 -31
- data/test/buildmaster/tc_ant_driver.rb +11 -13
- data/test/buildmaster/tc_build_number_file.rb +21 -16
- data/test/buildmaster/tc_cvs_driver.rb +35 -37
- data/test/buildmaster/tc_file_processor.rb +58 -34
- data/test/buildmaster/tc_java_manifest.rb +37 -9
- data/test/buildmaster/tc_site_spec.rb +20 -15
- data/test/buildmaster/tc_source_file_handler.rb +4 -4
- data/test/buildmaster/tc_svn_driver.rb +51 -38
- data/test/buildmaster/tc_template_runner.rb +19 -18
- data/test/buildmaster/tc_tree_to_object.rb +47 -46
- data/test/buildmaster/tc_xtemplate.rb +52 -38
- data/test/buildmaster/templatelets/common_templatelet_test.rb +9 -8
- data/test/buildmaster/templatelets/tc_attribute.rb +26 -23
- data/test/buildmaster/templatelets/tc_each.rb +27 -26
- data/test/buildmaster/templatelets/tc_href.rb +14 -13
- data/test/buildmaster/templatelets/tc_include.rb +11 -4
- data/test/buildmaster/templatelets/tc_link.rb +18 -12
- data/test/buildmaster/templatelets/tc_text.rb +12 -7
- data/test/buildmaster/templatelets/tc_when.rb +11 -5
- data/test/buildmaster/windows/tc_iis_driver.rb +29 -0
- data/test/buildmaster/windows/tc_sql_server_driver.rb +24 -0
- data/test/spec_runner.rb +27 -0
- data/test/ts_buildmaster.rb +2 -19
- metadata +34 -10
- data/lib/buildmaster/release_control.rb +0 -22
- data/lib/buildmaster/shell_command.rb +0 -39
- data/test/buildmaster/tc_release_control.rb +0 -27
- data/test/buildmaster/ts_site.rb +0 -4
- data/test/buildmaster/ts_templatelets.rb +0 -10
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'buildmaster/cotta'
         | 
| 5 | 
            +
            require 'buildmaster/cotta/in_memory_system'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module BuildMaster
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            context 'Cotta' do
         | 
| 10 | 
            +
              setup do
         | 
| 11 | 
            +
                @system = InMemorySystem.new
         | 
| 12 | 
            +
                @cotta = Cotta.new(@system)
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              specify 'shell out command to system' do
         | 
| 16 | 
            +
                @cotta.shell('shell command')
         | 
| 17 | 
            +
                @system.executed_commands.length.should_equal 1
         | 
| 18 | 
            +
                @system.executed_commands[0].should_equal 'shell command'
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              
         | 
| 21 | 
            +
              specify 'instantiate dir from cotta' do
         | 
| 22 | 
            +
                dir = @cotta.dir('dirname')
         | 
| 23 | 
            +
                dir.name.should_equal 'dirname'
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
              
         | 
| 26 | 
            +
              specify 'instantiate file from cotta' do
         | 
| 27 | 
            +
                file = @cotta.file('one/two/three.txt')
         | 
| 28 | 
            +
                file.name.should_equal 'three.txt'
         | 
| 29 | 
            +
                file.parent.name.should_equal 'two'
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            $:.unshift File.join(File.dirname(__FILE__))
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'cotta_specifications'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            require 'spec'
         | 
| 8 | 
            +
            require 'buildmaster/cotta/in_memory_system'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            module BuildMaster
         | 
| 11 | 
            +
            context 'Directory object with cotta for in memory system' do
         | 
| 12 | 
            +
              extend CottaSpecifications
         | 
| 13 | 
            +
              setup do
         | 
| 14 | 
            +
                @system = InMemorySystem.new
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              specify 'dir should not be equal if system different' do
         | 
| 18 | 
            +
                (BuildMaster::CottaDir.new(InMemorySystem.new, Pathname.new('dir')) == @dir).should_equal false
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              register_cotta_dir_specifications  
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            $:.unshift File.join(File.dirname(__FILE__))
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'cotta_specifications'
         | 
| 4 | 
            +
            require 'physical_system_stub'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require 'spec'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module BuildMaster
         | 
| 9 | 
            +
            context 'Directory object with cotta for physical system' do
         | 
| 10 | 
            +
              extend CottaSpecifications
         | 
| 11 | 
            +
              setup do
         | 
| 12 | 
            +
                @system = PhysicalSystemStub.new
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              register_cotta_dir_specifications  
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            $:.unshift File.dirname(__FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'cotta_specifications'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            require 'spec'
         | 
| 8 | 
            +
            require 'buildmaster/cotta/in_memory_system'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            module BuildMaster
         | 
| 11 | 
            +
            context 'Cotta file' do
         | 
| 12 | 
            +
              extend CottaSpecifications
         | 
| 13 | 
            +
              setup do
         | 
| 14 | 
            +
                @system = InMemorySystem.new
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              register_cotta_file_specifications
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            $:.unshift File.dirname(__FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
            require 'cotta_specifications'
         | 
| 5 | 
            +
            require 'physical_system_stub'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module BuildMaster
         | 
| 8 | 
            +
            context 'Cotta file' do
         | 
| 9 | 
            +
              extend CottaSpecifications
         | 
| 10 | 
            +
              setup do
         | 
| 11 | 
            +
                @system = PhysicalSystemStub.new
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              register_cotta_file_specifications
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            $:.unshift File.dirname(__FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'system_file_specifications'
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
            $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            require 'buildmaster/cotta/in_memory_system'
         | 
| 8 | 
            +
            require 'spec'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            module BuildMaster
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            context 'In memory system' do
         | 
| 13 | 
            +
              setup do
         | 
| 14 | 
            +
                @system = InMemorySystem.new
         | 
| 15 | 
            +
                @ios = Array.new
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              teardown do
         | 
| 19 | 
            +
                @ios.each {|io| io.close unless io.closed?}
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              register_system_file_specifications
         | 
| 23 | 
            +
              
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            $:.unshift File.dirname(__FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'system_file_specifications'
         | 
| 4 | 
            +
            require 'physical_system_stub'
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
            $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            require 'buildmaster/cotta/physical_system'
         | 
| 9 | 
            +
            require 'spec'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            module BuildMaster
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            context 'Physical System' do
         | 
| 14 | 
            +
              setup do
         | 
| 15 | 
            +
                @system = PhysicalSystemStub.new
         | 
| 16 | 
            +
                @ios = Array.new
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
              
         | 
| 19 | 
            +
              teardown do
         | 
| 20 | 
            +
                @ios.each {|io| io.close unless io.closed?}
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              register_system_file_specifications
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
            end
         | 
| @@ -1,41 +1,49 @@ | |
| 1 1 | 
             
            $:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib")
         | 
| 2 2 |  | 
| 3 | 
            -
            require ' | 
| 3 | 
            +
            require 'spec'
         | 
| 4 4 | 
             
            require 'buildmaster'
         | 
| 5 | 
            +
            require 'buildmaster/cotta'
         | 
| 6 | 
            +
            require 'buildmaster/cotta/in_memory_system'
         | 
| 5 7 |  | 
| 6 8 | 
             
            module BuildMaster
         | 
| 7 9 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
               | 
| 10 | 
            -
             | 
| 11 | 
            -
                 | 
| 12 | 
            -
                @ | 
| 13 | 
            -
                
         | 
| 14 | 
            -
                if (File.exist? @temp)
         | 
| 15 | 
            -
                    delete_all(@temp)
         | 
| 16 | 
            -
                end
         | 
| 10 | 
            +
            context 'Site' do
         | 
| 11 | 
            +
              setup do
         | 
| 12 | 
            +
                @system = InMemorySystem.new
         | 
| 13 | 
            +
                @cotta = Cotta.new(@system)
         | 
| 14 | 
            +
                @root = @cotta.dir('site')
         | 
| 17 15 | 
             
              end
         | 
| 18 16 |  | 
| 19 | 
            -
               | 
| 20 | 
            -
             | 
| 21 | 
            -
                   | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
                   | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 17 | 
            +
              specify 'should build base on content' do
         | 
| 18 | 
            +
                  content_dir = @root.dir('content')
         | 
| 19 | 
            +
                  content_dir.file('index.html').save(<<CONTENT
         | 
| 20 | 
            +
            <!DOCTYPE html
         | 
| 21 | 
            +
                PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         | 
| 22 | 
            +
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
         | 
| 23 | 
            +
            <html xmlns="http://www.w3.org/1999/xhtml">    
         | 
| 24 | 
            +
                <body><h1>Text</h1>
         | 
| 25 | 
            +
              </body>
         | 
| 26 | 
            +
            </html>
         | 
| 27 | 
            +
            CONTENT
         | 
| 28 | 
            +
            )
         | 
| 29 | 
            +
                  content_dir.file('markdown.markdown').save(<<CONTENT
         | 
| 30 | 
            +
            --------------------
         | 
| 31 | 
            +
            markdown title
         | 
| 32 | 
            +
            --------------------
         | 
| 33 | 
            +
            Header
         | 
| 34 | 
            +
            ===============
         | 
| 35 | 
            +
            CONTENT
         | 
| 36 | 
            +
            )
         | 
| 37 | 
            +
                  content_dir.file('textile.textile').save(<<CONTENT
         | 
| 38 | 
            +
            ---------------------
         | 
| 39 | 
            +
            textile title
         | 
| 40 | 
            +
            ---------------------
         | 
| 41 | 
            +
            h1. Header
         | 
| 42 | 
            +
            CONTENT
         | 
| 43 | 
            +
            )
         | 
| 44 | 
            +
                  spec = SiteSpec.new(nil, @cotta)
         | 
| 45 | 
            +
                    spec.output_dir =  'site/output'
         | 
| 46 | 
            +
                    spec.content_dir =  'site/content'
         | 
| 39 47 | 
             
                    spec.template =<<TEMPLATE
         | 
| 40 48 | 
             
            <html xmlns="http://www.w3.org/1999/xhtml"
         | 
| 41 49 | 
             
                  xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
         | 
| @@ -48,11 +56,27 @@ class SiteTest < Test::Unit::TestCase | |
| 48 56 | 
             
            TEMPLATE
         | 
| 49 57 | 
             
                  site = Site.new(spec)
         | 
| 50 58 | 
             
                  site.build
         | 
| 51 | 
            -
                   | 
| 52 | 
            -
                   | 
| 53 | 
            -
                   | 
| 59 | 
            +
                  expected_output_file = @root.dir('output').file('index.html')
         | 
| 60 | 
            +
                  @root.exists?.should_equal(true)
         | 
| 61 | 
            +
                  expected_output_file.exists?.should_equal(true)
         | 
| 62 | 
            +
                  
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
              
         | 
| 65 | 
            +
              specify 'ignore the svn and CVS directories' do
         | 
| 66 | 
            +
                content_dir = @root.dir('content')
         | 
| 67 | 
            +
                content_dir.dir('.svn').mkdirs
         | 
| 68 | 
            +
                content_dir.dir('_svn').mkdirs
         | 
| 69 | 
            +
                content_dir.dir('CVS').mkdirs
         | 
| 70 | 
            +
                spec = SiteSpec.new(nil, @cotta)
         | 
| 71 | 
            +
                  spec.output_dir = 'site/output'
         | 
| 72 | 
            +
                  spec.content_dir = 'site/content'
         | 
| 73 | 
            +
                  spec.template = <<TEMPLATE
         | 
| 74 | 
            +
            <html/>      
         | 
| 75 | 
            +
            TEMPLATE
         | 
| 76 | 
            +
                site = Site.new(spec)
         | 
| 77 | 
            +
                site.build
         | 
| 78 | 
            +
                @root.dir('output').list.size.should_equal 0
         | 
| 54 79 | 
             
              end
         | 
| 55 | 
            -
             | 
| 56 80 | 
             
            end
         | 
| 57 81 |  | 
| 58 82 | 
             
            end
         | 
| @@ -1,50 +1,51 @@ | |
| 1 1 | 
             
            $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
         | 
| 2 2 |  | 
| 3 | 
            -
            require ' | 
| 3 | 
            +
            require 'spec'
         | 
| 4 4 | 
             
            require 'rexml/xpath'
         | 
| 5 5 | 
             
            require 'buildmaster/site/template_builder'
         | 
| 6 6 | 
             
            require 'buildmaster/tree_to_object'
         | 
| 7 7 | 
             
            require 'yaml'
         | 
| 8 8 |  | 
| 9 9 | 
             
            module BuildMaster
         | 
| 10 | 
            -
             | 
| 11 | 
            -
               | 
| 10 | 
            +
            context 'Template Builder' do
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              specify 'should generate template document' do
         | 
| 12 13 | 
             
                builder = TemplateBuilder.new
         | 
| 13 14 | 
             
                document = builder.generate
         | 
| 14 | 
            -
                 | 
| 15 | 
            +
                REXML::XPath.first(document, '/html/head/title/*').name.should_equal 'include'
         | 
| 15 16 | 
             
                assert_css_path(document, 'buildmaster.css')
         | 
| 16 17 | 
             
              end
         | 
| 17 18 |  | 
| 18 | 
            -
               | 
| 19 | 
            +
              specify 'should update header with title and css' do
         | 
| 19 20 | 
             
                builder = TemplateBuilder.new
         | 
| 20 21 | 
             
                builder.title_header = 'Title Header - '
         | 
| 21 22 | 
             
                builder.css_path = 'mycss.css'
         | 
| 22 23 | 
             
                document = builder.generate
         | 
| 23 24 | 
             
                first_child = REXML::XPath.first(document, '/html/head/title').children[0]
         | 
| 24 | 
            -
                 | 
| 25 | 
            -
                 | 
| 25 | 
            +
                first_child.class.should_equal REXML::Text
         | 
| 26 | 
            +
                first_child.value.should_equal 'Title Header - '
         | 
| 26 27 | 
             
                assert_css_path(document, 'mycss.css')
         | 
| 27 28 | 
             
              end
         | 
| 28 29 |  | 
| 29 | 
            -
               | 
| 30 | 
            +
              specify 'test_should_have_logo_defaults' do
         | 
| 30 31 | 
             
                builder = TemplateBuilder.new
         | 
| 31 | 
            -
                 | 
| 32 | 
            -
                 | 
| 32 | 
            +
                builder.logo.path.should_equal nil
         | 
| 33 | 
            +
                builder.logo.link.should_equal 'index.html'
         | 
| 33 34 | 
             
              end
         | 
| 34 35 |  | 
| 35 | 
            -
               | 
| 36 | 
            +
              specify 'test_should_generate_logo_and_link' do
         | 
| 36 37 | 
             
                builder = TemplateBuilder.new
         | 
| 37 38 | 
             
                builder.logo.path = 'gif/logo.gif'
         | 
| 38 39 | 
             
                builder.logo.link = 'main.html'
         | 
| 39 40 | 
             
                document = builder.generate
         | 
| 40 41 | 
             
                header = assert_first(document, '/html/body/div[@class="header"]')
         | 
| 41 42 | 
             
                anchor_href = assert_first(header, 'a/template:href')
         | 
| 42 | 
            -
                 | 
| 43 | 
            +
                anchor_href.attributes['url'].should_equal 'main.html'
         | 
| 43 44 | 
             
                img_href = assert_first(header, 'a/img/template:href')
         | 
| 44 | 
            -
                 | 
| 45 | 
            +
                img_href.attributes['url'].should_equal 'gif/logo.gif'
         | 
| 45 46 | 
             
              end
         | 
| 46 47 |  | 
| 47 | 
            -
               | 
| 48 | 
            +
              specify 'test_should_build_left_menu' do
         | 
| 48 49 | 
             
                builder = TemplateBuilder.new
         | 
| 49 50 | 
             
                builder.left_bottom_logo.path='http://www.example.com/logo.gif'
         | 
| 50 51 | 
             
                group = builder.menu_group('Software')
         | 
| @@ -55,21 +56,21 @@ class TemplateBuilderTest < Test::Unit::TestCase | |
| 55 56 | 
             
                group.menu_item('Getting Started', 'doc/getting-started')
         | 
| 56 57 | 
             
                document = builder.generate
         | 
| 57 58 | 
             
                groups = REXML::XPath.match(document, '/html/body/div[@class="left"]/div[@class="MenuGroup"]')
         | 
| 58 | 
            -
                 | 
| 59 | 
            +
                groups.size.should_equal 2
         | 
| 59 60 | 
             
                first_group = groups[0]
         | 
| 60 61 | 
             
                header = assert_first(first_group, 'h1')
         | 
| 61 | 
            -
                 | 
| 62 | 
            +
                header.text.should_equal 'Software'
         | 
| 62 63 | 
             
                items = REXML::XPath.match(first_group, 'ul/li')
         | 
| 63 | 
            -
                 | 
| 64 | 
            +
                items.size.should_equal 3
         | 
| 64 65 | 
             
                first_item = items[0]
         | 
| 65 66 | 
             
                anchor = assert_first(first_item, 'template:link')
         | 
| 66 | 
            -
                 | 
| 67 | 
            -
                 | 
| 67 | 
            +
                anchor.attributes['href'].should_equal 'download.html'
         | 
| 68 | 
            +
                anchor.text.should_equal 'Download'
         | 
| 68 69 | 
             
                more = items[2]
         | 
| 69 | 
            -
                 | 
| 70 | 
            +
                more.attributes['class'].should_equal 'More'
         | 
| 70 71 | 
             
              end
         | 
| 71 72 |  | 
| 72 | 
            -
               | 
| 73 | 
            +
              specify 'should_have_releases_info' do
         | 
| 73 74 | 
             
                builder = TemplateBuilder.new
         | 
| 74 75 | 
             
                releases = builder.releases
         | 
| 75 76 | 
             
                releases.stable_version = '0.6'
         | 
| @@ -78,17 +79,17 @@ class TemplateBuilderTest < Test::Unit::TestCase | |
| 78 79 | 
             
                releases.download_link = 'download.html'
         | 
| 79 80 | 
             
                releases.versioning_link = 'versioning.html'
         | 
| 80 81 | 
             
                document = builder.generate
         | 
| 81 | 
            -
                 | 
| 82 | 
            +
                REXML::XPath.first(document, '/html/body/template:when/div[@class="right"]/div/h1').text.should_equal 'Latest Versions'
         | 
| 82 83 | 
             
              end
         | 
| 83 84 |  | 
| 84 | 
            -
               | 
| 85 | 
            +
              specify 'should_have_no_release_info_if_not_assigned' do
         | 
| 85 86 | 
             
                builder = TemplateBuilder.new
         | 
| 86 87 | 
             
                builder.releases.download_link = nil
         | 
| 87 88 | 
             
                document = builder.generate
         | 
| 88 | 
            -
                 | 
| 89 | 
            +
                REXML::XPath.match(document, '/html/body/template:when/div/*').size.should_equal 0
         | 
| 89 90 | 
             
              end
         | 
| 90 91 |  | 
| 91 | 
            -
               | 
| 92 | 
            +
              specify 'should_read_from_yaml' do
         | 
| 92 93 | 
             
                content = <<CONTENT
         | 
| 93 94 | 
             
            title_header: BuilderMaster -
         | 
| 94 95 | 
             
            logo:
         | 
| @@ -115,21 +116,21 @@ menu_groups: | |
| 115 116 | 
             
              more: doc/index.html
         | 
| 116 117 | 
             
            CONTENT
         | 
| 117 118 | 
             
                builder = TreeToObject.from_yaml(content, TemplateBuilder.new)
         | 
| 118 | 
            -
                 | 
| 119 | 
            -
                 | 
| 120 | 
            -
                 | 
| 119 | 
            +
                builder.title_header.should_equal 'BuilderMaster -'
         | 
| 120 | 
            +
                builder.logo.path.should_equal 'logo.gif'
         | 
| 121 | 
            +
                builder.logo.link.should_equal 'index.html'
         | 
| 121 122 | 
             
              end
         | 
| 122 123 |  | 
| 123 124 | 
             
              private
         | 
| 124 125 | 
             
              def assert_css_path(document, expected)
         | 
| 125 126 | 
             
                href = REXML::XPath.first(document, '/html/head/link/*')
         | 
| 126 | 
            -
                 | 
| 127 | 
            -
             | 
| 127 | 
            +
                href.name.should_equal 'href'
         | 
| 128 | 
            +
                 href.attributes['url'].should_equal expected
         | 
| 128 129 | 
             
              end  
         | 
| 129 130 |  | 
| 130 131 | 
             
              def assert_first(xml_model, xpath)
         | 
| 131 132 | 
             
                first = REXML::XPath.first(xml_model, xpath)
         | 
| 132 | 
            -
                 | 
| 133 | 
            +
                first.should_not_equal nil
         | 
| 133 134 | 
             
                return first
         | 
| 134 135 | 
             
              end
         | 
| 135 136 | 
             
            end
         | 
| @@ -1,34 +1,32 @@ | |
| 1 1 | 
             
            $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
         | 
| 2 2 |  | 
| 3 | 
            -
            require ' | 
| 3 | 
            +
            require 'spec'
         | 
| 4 4 | 
             
            require 'buildmaster'
         | 
| 5 | 
            +
            require 'buildmaster/cotta'
         | 
| 5 6 |  | 
| 6 7 | 
             
            module BuildMaster
         | 
| 7 8 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
               | 
| 10 | 
            -
             | 
| 11 | 
            -
                 | 
| 12 | 
            -
                build_file = File.join(File.dirname(__FILE__), "build.xml")
         | 
| 9 | 
            +
            context 'AntTest' do
         | 
| 10 | 
            +
              setup do
         | 
| 11 | 
            +
                cotta = Cotta.new()
         | 
| 12 | 
            +
                build_file = cotta.file(__FILE__).parent.file('build.xml')
         | 
| 13 13 | 
             
                @ant = AntDriver.from_file(build_file)
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| 16 | 
            -
               | 
| 17 | 
            -
              
         | 
| 18 | 
            -
              def test_run
         | 
| 16 | 
            +
              specify 'run' do
         | 
| 19 17 | 
             
                @ant.project_help
         | 
| 20 18 | 
             
              end
         | 
| 21 19 |  | 
| 22 | 
            -
               | 
| 20 | 
            +
              specify 'pass' do
         | 
| 23 21 | 
             
                @ant.target('passing')
         | 
| 24 22 | 
             
              end
         | 
| 25 23 |  | 
| 26 | 
            -
               | 
| 24 | 
            +
              specify 'dynamic_method' do
         | 
| 27 25 | 
             
                @ant.passing
         | 
| 28 26 | 
             
              end
         | 
| 29 27 |  | 
| 30 | 
            -
               | 
| 31 | 
            -
                 | 
| 28 | 
            +
              specify 'fail' do
         | 
| 29 | 
            +
                lambda {@ant.target('failing')}.should_raise CommandError
         | 
| 32 30 | 
             
              end
         | 
| 33 31 | 
             
            end
         | 
| 34 32 |  |