BuildMaster 0.9.1 → 1.0.6

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.
Files changed (174) hide show
  1. data/bin/svnfix.rb +3 -0
  2. data/lib/buildmaster/ci/server.rb +55 -0
  3. data/lib/buildmaster/common.rb +3 -0
  4. data/lib/buildmaster/common/properties.rb +28 -0
  5. data/lib/buildmaster/{tree_to_object.rb → common/tree_to_object.rb} +0 -0
  6. data/lib/buildmaster/cotta.rb +1 -1
  7. data/lib/buildmaster/cotta/command_error.rb +6 -1
  8. data/lib/buildmaster/cotta/command_interface.rb +44 -0
  9. data/lib/buildmaster/cotta/command_runner.rb +39 -0
  10. data/lib/buildmaster/cotta/cotta.rb +40 -3
  11. data/lib/buildmaster/cotta/cotta_dir.rb +28 -7
  12. data/lib/buildmaster/cotta/cotta_file.rb +14 -2
  13. data/lib/buildmaster/cotta/cotta_pathname.rb +9 -0
  14. data/lib/buildmaster/cotta/in_memory_system.rb +20 -9
  15. data/lib/buildmaster/cotta/physical_system.rb +4 -8
  16. data/lib/buildmaster/project.rb +10 -0
  17. data/lib/buildmaster/{ant_driver.rb → project/ant_driver.rb} +0 -0
  18. data/lib/buildmaster/project/build.rb +3 -0
  19. data/lib/buildmaster/{build_number_file.rb → project/build_number_file.rb} +4 -0
  20. data/lib/buildmaster/project/ci.rb +3 -0
  21. data/lib/buildmaster/{cvs_driver.rb → project/cvs_driver.rb} +0 -0
  22. data/lib/buildmaster/project/ftp_driver.rb +64 -0
  23. data/lib/buildmaster/{java_manifest.rb → project/java_manifest.rb} +0 -0
  24. data/lib/buildmaster/project/pscp_driver.rb +17 -0
  25. data/lib/buildmaster/project/release.rb +67 -0
  26. data/lib/buildmaster/project/ruby_forge_project.rb +26 -0
  27. data/lib/buildmaster/{run_ant.rb → project/run_ant.rb} +0 -0
  28. data/lib/buildmaster/project/server_manager.rb +64 -0
  29. data/lib/buildmaster/project/svn_admin_driver.rb +20 -0
  30. data/lib/buildmaster/project/svn_driver.rb +94 -0
  31. data/lib/buildmaster/project/svn_helper.rb +113 -0
  32. data/lib/buildmaster/project/svn_status_info.rb +54 -0
  33. data/lib/buildmaster/{try.rb → project/try.rb} +0 -0
  34. data/lib/buildmaster/project/version_number_file.rb +45 -0
  35. data/lib/buildmaster/{windows → project/windows}/iis_driver.rb +4 -4
  36. data/lib/buildmaster/{windows → project/windows}/sql_server_driver.rb +0 -0
  37. data/lib/buildmaster/site.rb +5 -0
  38. data/lib/buildmaster/site/about_handler.rb +43 -0
  39. data/lib/buildmaster/site/content_engine_repository.rb +83 -0
  40. data/lib/buildmaster/site/element_processor_by_name.rb +18 -0
  41. data/lib/buildmaster/site/file_processor.rb +59 -0
  42. data/lib/buildmaster/site/site.rb +29 -6
  43. data/lib/buildmaster/site/site_server.rb +56 -0
  44. data/lib/buildmaster/{site_spec.rb → site/site_spec.rb} +63 -38
  45. data/lib/buildmaster/{site_tester.rb → site/site_tester.rb} +0 -0
  46. data/lib/buildmaster/site/source_content.rb +12 -0
  47. data/lib/buildmaster/{source_file_handler.rb → site/source_file_handler.rb} +13 -27
  48. data/lib/buildmaster/site/template_builder.rb +4 -0
  49. data/lib/buildmaster/site/template_error.rb +18 -0
  50. data/lib/buildmaster/{template_runner.rb → site/template_runner.rb} +6 -16
  51. data/lib/buildmaster/{templatelets.rb → site/templatelets.rb} +3 -1
  52. data/lib/buildmaster/site/templatelets/attribute.rb +21 -0
  53. data/lib/buildmaster/site/templatelets/code.rb +82 -0
  54. data/lib/buildmaster/{templatelets → site/templatelets}/each.rb +7 -5
  55. data/lib/buildmaster/{templatelets → site/templatelets}/href.rb +1 -1
  56. data/lib/buildmaster/{templatelets → site/templatelets}/include.rb +0 -0
  57. data/lib/buildmaster/{templatelets → site/templatelets}/link.rb +2 -3
  58. data/lib/buildmaster/{templatelets → site/templatelets}/text.rb +1 -1
  59. data/lib/buildmaster/{templatelets → site/templatelets}/when.rb +4 -7
  60. data/lib/buildmaster/site/templates/buildmaster/content/border_bottom.gif +0 -0
  61. data/lib/buildmaster/site/templates/buildmaster/content/buildmaster.css +370 -0
  62. data/lib/buildmaster/site/templates/buildmaster/content/logo.gif +0 -0
  63. data/lib/buildmaster/site/templates/buildmaster/content/news-rss2.xml +4 -0
  64. data/lib/buildmaster/site/templates/buildmaster/content/print.css +65 -0
  65. data/lib/buildmaster/site/templates/buildmaster/content/ruby.css +14 -0
  66. data/lib/buildmaster/site/templates/buildmaster/template.html +121 -0
  67. data/lib/buildmaster/site/templates/cotta/content/border_bottom.gif +0 -0
  68. data/lib/buildmaster/site/templates/cotta/content/cotta.css +363 -0
  69. data/lib/buildmaster/site/templates/cotta/content/cotta.gif +0 -0
  70. data/lib/buildmaster/site/templates/cotta/content/news-rss2.xml +2 -0
  71. data/lib/buildmaster/site/templates/cotta/template.html +106 -0
  72. data/lib/buildmaster/site/xtemplate.rb +26 -0
  73. data/lib/buildmaster/version +1 -0
  74. data/test/buildmaster/common/tc_properties.rb +24 -0
  75. data/test/buildmaster/{tc_tree_to_object.rb → common/tc_tree_to_object.rb} +18 -18
  76. data/test/buildmaster/cotta/cotta_specifications.rb +88 -64
  77. data/test/buildmaster/cotta/physical_system_stub.rb +3 -3
  78. data/test/buildmaster/cotta/system_file_specifications.rb +38 -47
  79. data/test/buildmaster/cotta/tc_command_interface.rb +46 -0
  80. data/test/buildmaster/cotta/tc_command_runner.rb +28 -0
  81. data/test/buildmaster/cotta/tc_cotta.rb +35 -9
  82. data/test/buildmaster/cotta/tc_cotta_dir_in_memory.rb +10 -5
  83. data/test/buildmaster/cotta/tc_cotta_file_in_memory.rb +3 -3
  84. data/test/buildmaster/cotta/tc_in_memory_system.rb +7 -2
  85. data/test/buildmaster/cotta/tc_pathname.rb +22 -0
  86. data/test/buildmaster/cotta/tc_physical_system.rb +12 -2
  87. data/test/buildmaster/{build.xml → project/build.xml} +0 -0
  88. data/test/buildmaster/{manifest.mf → project/manifest.mf} +0 -0
  89. data/test/buildmaster/{tc_ant_driver.rb → project/tc_ant_driver.rb} +3 -3
  90. data/test/buildmaster/{tc_build_number_file.rb → project/tc_build_number_file.rb} +7 -7
  91. data/test/buildmaster/{tc_cvs_driver.rb → project/tc_cvs_driver.rb} +14 -14
  92. data/test/buildmaster/{tc_java_manifest.rb → project/tc_java_manifest.rb} +7 -7
  93. data/test/buildmaster/project/tc_release.rb +61 -0
  94. data/test/buildmaster/project/tc_server_manager.rb +70 -0
  95. data/test/buildmaster/project/tc_svn_driver.rb +104 -0
  96. data/test/buildmaster/project/tc_svn_status_info.rb +37 -0
  97. data/test/buildmaster/project/tc_version_number_file.rb +46 -0
  98. data/test/buildmaster/{windows → project/windows}/tc_iis_driver.rb +5 -4
  99. data/test/buildmaster/{windows → project/windows}/tc_sql_server_driver.rb +4 -4
  100. data/test/buildmaster/site/content/tc_content_engine_repository.rb +63 -0
  101. data/test/buildmaster/site/tc_element_processor_by_name.rb +29 -0
  102. data/test/buildmaster/site/tc_file_processor.rb +141 -0
  103. data/test/buildmaster/site/tc_site.rb +42 -11
  104. data/test/buildmaster/site/tc_site_server.rb +43 -0
  105. data/test/buildmaster/{tc_site_spec.rb → site/tc_site_spec.rb} +9 -9
  106. data/test/buildmaster/{tc_source_file_handler.rb → site/tc_source_file_handler.rb} +10 -9
  107. data/test/buildmaster/site/tc_template_builder.rb +23 -23
  108. data/test/buildmaster/site/tc_template_error.rb +15 -0
  109. data/test/buildmaster/{tc_template_runner.rb → site/tc_template_runner.rb} +22 -17
  110. data/test/buildmaster/site/tc_templatelets.rb +37 -0
  111. data/test/buildmaster/{tc_xtemplate.rb → site/tc_xtemplate.rb} +14 -15
  112. data/test/buildmaster/{template.xhtml → site/template.xhtml} +0 -0
  113. data/test/buildmaster/{templatelets → site/templatelets}/common_templatelet_test.rb +11 -7
  114. data/test/buildmaster/{templatelets → site/templatelets}/tc_attribute.rb +14 -10
  115. data/test/buildmaster/site/templatelets/tc_code.rb +132 -0
  116. data/test/buildmaster/{templatelets → site/templatelets}/tc_each.rb +25 -12
  117. data/test/buildmaster/{templatelets → site/templatelets}/tc_href.rb +6 -8
  118. data/test/buildmaster/{templatelets → site/templatelets}/tc_include.rb +3 -12
  119. data/test/buildmaster/{templatelets → site/templatelets}/tc_link.rb +11 -18
  120. data/test/buildmaster/{templatelets → site/templatelets}/tc_text.rb +2 -9
  121. data/test/buildmaster/{templatelets → site/templatelets}/tc_when.rb +8 -15
  122. data/test/manual/bms.rb +10 -0
  123. data/test/tmp/svn_test/repository/README.txt +5 -0
  124. data/test/tmp/svn_test/repository/conf/authz +21 -0
  125. data/test/tmp/svn_test/repository/conf/passwd +8 -0
  126. data/test/tmp/svn_test/repository/conf/svnserve.conf +30 -0
  127. data/test/tmp/svn_test/repository/db/current +1 -0
  128. data/test/tmp/svn_test/repository/db/format +1 -0
  129. data/test/tmp/svn_test/repository/db/fs-type +1 -0
  130. data/test/tmp/svn_test/repository/db/revprops/0 +5 -0
  131. data/test/tmp/svn_test/repository/db/revprops/1 +13 -0
  132. data/test/tmp/svn_test/repository/db/revprops/2 +13 -0
  133. data/test/tmp/svn_test/repository/db/revprops/3 +13 -0
  134. data/test/tmp/svn_test/repository/db/revprops/4 +13 -0
  135. data/test/tmp/svn_test/repository/db/revs/0 +11 -0
  136. data/test/tmp/svn_test/repository/db/revs/1 +25 -0
  137. data/test/tmp/svn_test/repository/db/revs/2 +29 -0
  138. data/test/tmp/svn_test/repository/db/revs/3 +33 -0
  139. data/test/tmp/svn_test/repository/db/revs/4 +0 -0
  140. data/test/tmp/svn_test/repository/db/uuid +1 -0
  141. data/test/tmp/svn_test/repository/db/write-lock +0 -0
  142. data/test/tmp/svn_test/repository/format +1 -0
  143. data/test/tmp/svn_test/repository/hooks/post-commit.tmpl +51 -0
  144. data/test/tmp/svn_test/repository/hooks/post-lock.tmpl +44 -0
  145. data/test/tmp/svn_test/repository/hooks/post-revprop-change.tmpl +56 -0
  146. data/test/tmp/svn_test/repository/hooks/post-unlock.tmpl +42 -0
  147. data/test/tmp/svn_test/repository/hooks/pre-commit.tmpl +70 -0
  148. data/test/tmp/svn_test/repository/hooks/pre-lock.tmpl +64 -0
  149. data/test/tmp/svn_test/repository/hooks/pre-revprop-change.tmpl +66 -0
  150. data/test/tmp/svn_test/repository/hooks/pre-unlock.tmpl +60 -0
  151. data/test/tmp/svn_test/repository/hooks/start-commit.tmpl +54 -0
  152. data/test/tmp/svn_test/repository/locks/db-logs.lock +3 -0
  153. data/test/tmp/svn_test/repository/locks/db.lock +3 -0
  154. data/test/tmp/svn_test/second/test.txt +1 -0
  155. data/test/tmp/svn_test/workdir/test.txt +1 -0
  156. data/test/ts_buildmaster.rb +0 -1
  157. metadata +168 -69
  158. data/lib/buildmaster.rb +0 -10
  159. data/lib/buildmaster/build_file.rb +0 -11
  160. data/lib/buildmaster/buildnumber +0 -1
  161. data/lib/buildmaster/file_processor.rb +0 -138
  162. data/lib/buildmaster/site_server.rb +0 -33
  163. data/lib/buildmaster/source_content.rb +0 -11
  164. data/lib/buildmaster/svn_driver.rb +0 -78
  165. data/lib/buildmaster/template_error.rb +0 -8
  166. data/lib/buildmaster/templatelets/attribute.rb +0 -16
  167. data/lib/buildmaster/xtemplate.rb +0 -27
  168. data/lib/mock.rb +0 -3
  169. data/lib/mock/mock_base.rb +0 -24
  170. data/test/buildmaster/tc_file_processor.rb +0 -125
  171. data/test/buildmaster/tc_svn_driver.rb +0 -81
  172. data/test/tmp/output/index.html +0 -8
  173. data/test/tmp/output/markdown.html +0 -8
  174. data/test/tmp/output/textile.html +0 -8
@@ -8,8 +8,9 @@ module BuildMaster
8
8
  context 'IIS Driver' do
9
9
 
10
10
  setup do
11
- @system = InMemorySystem.new
12
- @driver = IisDriver.new(Cotta.new(@system))
11
+ @system = mock('system mock')
12
+ cotta = Cotta.new(@system)
13
+ @driver = IisDriver.new(cotta)
13
14
  end
14
15
 
15
16
  specify 'should work on real system - requires IIS installed and not running' do
@@ -20,9 +21,9 @@ context 'IIS Driver' do
20
21
  end
21
22
 
22
23
  specify 'should initiate start command' do
24
+ #@system.should_receive(:shell).with 'C:\WINDOWS\system32\iisreset.exe /start'
25
+ @system.should_receive(:shell).with('sc start W3SVC')
23
26
  @driver.start
24
- #@system.executed_commands[0].should_equal 'C:\WINDOWS\system32\iisreset.exe /start'
25
- @system.executed_commands[0].should_equal 'sc start W3SVC'
26
27
  end
27
28
 
28
29
  end
@@ -1,9 +1,9 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
2
2
 
3
3
  require 'spec'
4
- require 'buildmaster/windows/sql_server_driver'
5
- require 'buildmaster/cotta'
6
- require 'buildmaster/cotta/in_memory_system'
4
+ require 'windows/sql_server_driver'
5
+ require 'cotta'
6
+ require 'cotta/in_memory_system'
7
7
 
8
8
  module BuildMaster
9
9
 
@@ -0,0 +1,63 @@
1
+ require 'spec'
2
+ require 'rexml/document'
3
+ require 'rexml/xpath'
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'buildmaster')
6
+
7
+ require 'site/content_engine_repository'
8
+ require 'cotta'
9
+ require 'cotta/in_memory_system'
10
+
11
+ module BuildMaster
12
+ context 'content engine repository' do
13
+ setup do
14
+ @cotta = Cotta.new(InMemorySystem.new)
15
+ end
16
+
17
+ specify 'can get content engine based on the source file' do
18
+ repository = ContentEngineRepository.new
19
+ source = @cotta.file('content.textile')
20
+ source.save(<<CONTENT)
21
+ ---
22
+ Title
23
+ ---
24
+ h1. header
25
+ CONTENT
26
+ textile_engine = repository.for_source(source)
27
+ html_content = textile_engine.convert_to_html(source.load)
28
+ document = REXML::Document.new(html_content)
29
+ REXML::XPath.first(document, '/html/body/h1').get_text.should == 'header'
30
+ end
31
+
32
+ specify 'can get content engine based on the target file' do
33
+ repository = ContentEngineRepository.new
34
+ source = @cotta.file('content.markdown')
35
+ source.save(<<CONTENT)
36
+ ---
37
+ Title
38
+ ---
39
+ header
40
+ ====================
41
+ CONTENT
42
+ actual, markdown_engine = repository.for_candidate(source.parent, 'content')
43
+ actual.path.should == source.path
44
+ document = REXML::Document.new(markdown_engine.convert_to_html(source.load))
45
+ REXML::XPath.first(document, '/html/body/h1').get_text.should == 'header'
46
+ end
47
+
48
+ specify 'default format for txt file to textile' do
49
+ repository = ContentEngineRepository.new
50
+ source = @cotta.file('content.txt')
51
+ source.save(<<CONTENT)
52
+ ---
53
+ Title
54
+ ---
55
+ h1. header
56
+ CONTENT
57
+ textile_engine = repository.for_source(source)
58
+ html_content = textile_engine.convert_to_html(source.load)
59
+ document = REXML::Document.new(html_content)
60
+ REXML::XPath.first(document, '/html/body/h1').get_text.should == 'header'
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,29 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib", 'buildmaster')
2
+
3
+ require 'spec'
4
+ require 'rexml/element'
5
+ require 'site/element_processor_by_name'
6
+ require 'site/source_content'
7
+
8
+ module BuildMaster
9
+ context 'element processor by element name' do
10
+ specify 'should raise exception if not configured for template' do
11
+ processor = ElementProcessorByName.new(Hash.new)
12
+ target = REXML::Element.new
13
+ element = REXML::Element.new('name')
14
+ Proc.new {processor.process(target, element, SourceContent.new(nil, nil, nil))}.should_raise TemplateError
15
+ end
16
+
17
+ specify 'should process' do
18
+ target = REXML::Element.new
19
+ element = REXML::Element.new('name')
20
+ source = SourceContent.new(nil, nil, nil)
21
+ templatelet_mock = mock('templatelet for name')
22
+ templatelet_mock.should_receive(:process).with(target, element, source).once
23
+ hash = Hash.new
24
+ hash['name'] = templatelet_mock
25
+ ElementProcessorByName.new(hash).process(target, element, source)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,141 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib", 'buildmaster')
2
+
3
+ require 'spec'
4
+ require 'rexml/document'
5
+ require 'pathname'
6
+ require 'site/file_processor'
7
+ require 'site/xtemplate'
8
+ require 'cotta'
9
+ require 'cotta/in_memory_system'
10
+
11
+
12
+ module BuildMaster
13
+
14
+ context 'File Processor' do
15
+ setup do
16
+ @cotta = Cotta.new(InMemorySystem.new)
17
+ @cotta.file('content').save(<<CONTENT
18
+ line one
19
+ line two
20
+ line three
21
+ CONTENT
22
+ )
23
+ end
24
+
25
+ teardown do
26
+ @cotta = nil
27
+ end
28
+
29
+ specify 'should know content and target' do
30
+ content = <<CONTENT
31
+ <html xmlns="http://www.w3.org/1999/xhtml"
32
+ xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
33
+ </html>
34
+ CONTENT
35
+ template = XTemplate.new(REXML::Document.new(content), {})
36
+ site_spec = SiteSpec.new('file.txt', @cotta)
37
+ site_spec.content_dir = 'content'
38
+ site_spec.output_dir = 'output'
39
+ processor = FileProcessor.new(template, @cotta.file('content/index.html'), site_spec)
40
+ processor.content_file.path.should ==(Pathname.new('content/index.html'))
41
+ processor.is_html?.should ==(true)
42
+ end
43
+
44
+ specify 'should copy the content if no content engine found' do
45
+ content = <<CONTENT
46
+ <html xmlns="http://www.w3.org/1999/xhtml"
47
+ xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
48
+ </html>
49
+ CONTENT
50
+ template = XTemplate.new(REXML::Document.new(content), {})
51
+ site_spec = SiteSpec.new(nil, @cotta)
52
+ current_dir = @cotta.dir('root')
53
+ site_spec.content_dir = 'root/content'
54
+ site_spec.output_dir = 'root/output'
55
+ source = current_dir.dir('content').file('index.gif')
56
+ source.save('content for a gif')
57
+ processor = FileProcessor.new(template, source, site_spec)
58
+ processor.content_file.path.should == source.path
59
+ processor.is_html?.should == false
60
+ processor.write_to_target
61
+ processor.target_file.load.should == source.load
62
+ end
63
+
64
+ def output_dir
65
+ return @cotta.dir('tmp')
66
+ end
67
+
68
+ def relative_to_root(path)
69
+ return Pathname.new('tmp')
70
+ end
71
+
72
+ specify 'should have support for markdown content' do
73
+ template_content = <<CONTENT
74
+ <html xmlns="http://www.w3.org/1999/xhtml"
75
+ xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
76
+ <head><title><template:include elements="/html/head/title/text()"/></title></head>
77
+ <body>
78
+ <template:include elements="/html/body/*"/>
79
+ </body>
80
+ </html>
81
+ CONTENT
82
+ hash = {'include' => Include.new(self)}
83
+ template = XTemplate.new(REXML::Document.new(template_content), ElementProcessorByName.new(hash))
84
+
85
+ sitespec = SiteSpec.new('root', Cotta.new(InMemorySystem.new())) do |spec|
86
+ spec.content_dir = 'content_dir'
87
+ spec.output_dir = 'output_dir'
88
+ end
89
+
90
+ source = @cotta.file('content_path.markdown')
91
+ processor = FileProcessor.new(template, source, sitespec)
92
+ source.save(<<CONTENT)
93
+ --------------------------------------------
94
+ Title Here
95
+ --------------------------------------------
96
+ Header
97
+ =====================
98
+ CONTENT
99
+ processor.write_to_target
100
+ document = REXML::Document.new(processor.target_file.load)
101
+ REXML::XPath.first(document, '/html/head/title').get_text.should == 'Title Here'
102
+ REXML::XPath.first(document, '/html/body/h1').get_text.should == 'Header'
103
+ end
104
+
105
+ specify 'should run template engine against resulting content' do
106
+ template_content = <<CONTENT
107
+ <html xmlns="http://www.w3.org/1999/xhtml"
108
+ xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0">
109
+ <head><title><template:include elements="/html/head/title/text()"/></title></head>
110
+ <body>
111
+ <template:include elements="/html/body/*"/>
112
+ </body>
113
+ </html>
114
+ CONTENT
115
+ hash = {'include' => Include.new(self)}
116
+ template = XTemplate.new(REXML::Document.new(template_content), ElementProcessorByName.new(hash))
117
+
118
+ sitespec = SiteSpec.new('root', Cotta.new(InMemorySystem.new())) do |spec|
119
+ spec.content_dir = 'content_dir'
120
+ spec.output_dir = 'output_dir'
121
+ spec.properties['property'] = 'property value'
122
+ end
123
+
124
+ source = @cotta.file('content_path.markdown')
125
+ processor = FileProcessor.new(template, source, sitespec)
126
+ source.save(<<CONTENT)
127
+ --------------------------------------------
128
+ Title Here
129
+ --------------------------------------------
130
+ <div>
131
+ <template:text property="property"/>
132
+ </div>
133
+ CONTENT
134
+ processor.write_to_target
135
+ document = REXML::Document.new(processor.target_file.load)
136
+ REXML::XPath.first(document, '/html/head/title').text.should == 'Title Here'
137
+ REXML::XPath.first(document, '/html/body/div').text.strip.should == 'property value'
138
+ end
139
+
140
+ end
141
+ end
@@ -1,9 +1,10 @@
1
- $:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib")
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "..", '..', "lib", 'buildmaster')
2
2
 
3
3
  require 'spec'
4
- require 'buildmaster'
5
- require 'buildmaster/cotta'
6
- require 'buildmaster/cotta/in_memory_system'
4
+ require 'site/site'
5
+ require 'cotta'
6
+ require 'cotta/command_interface'
7
+ require 'cotta/in_memory_system'
7
8
 
8
9
  module BuildMaster
9
10
 
@@ -26,21 +27,20 @@ context 'Site' do
26
27
  </html>
27
28
  CONTENT
28
29
  )
29
- content_dir.file('markdown.markdown').save(<<CONTENT
30
+ content_dir.file('markdown.markdown').save(<<CONTENT)
30
31
  --------------------
31
32
  markdown title
32
33
  --------------------
33
34
  Header
34
35
  ===============
35
36
  CONTENT
36
- )
37
- content_dir.file('textile.textile').save(<<CONTENT
37
+
38
+ content_dir.file('textile.textile').save(<<CONTENT)
38
39
  ---------------------
39
40
  textile title
40
41
  ---------------------
41
42
  h1. Header
42
43
  CONTENT
43
- )
44
44
  spec = SiteSpec.new(nil, @cotta)
45
45
  spec.output_dir = 'site/output'
46
46
  spec.content_dir = 'site/content'
@@ -57,8 +57,8 @@ TEMPLATE
57
57
  site = Site.new(spec)
58
58
  site.build
59
59
  expected_output_file = @root.dir('output').file('index.html')
60
- @root.exists?.should_equal(true)
61
- expected_output_file.exists?.should_equal(true)
60
+ @root.exists?.should ==(true)
61
+ expected_output_file.exists?.should ==(true)
62
62
 
63
63
  end
64
64
 
@@ -75,8 +75,39 @@ TEMPLATE
75
75
  TEMPLATE
76
76
  site = Site.new(spec)
77
77
  site.build
78
- @root.dir('output').list.size.should_equal 0
78
+ @root.dir('output').list.size.should == 0
79
+ end
80
+
81
+ specify 'set up site based on the template' do
82
+ templates_dir = @cotta.dir('templates')
83
+ setup_template_choice_one(templates_dir)
84
+ setup_template_choice_two(templates_dir)
85
+ command_io = mock('command line io')
86
+ command_io.should_receive(:puts).exactly(4).times
87
+ command_io.should_receive(:gets).once.and_return('1')
88
+ @cotta.command_interface = CommandInterface.new(command_io)
89
+ spec = SiteSpec.new(nil, @cotta) do |spec|
90
+ spec.content_dir = 'site/content'
91
+ spec.output_dir = 'output'
92
+ spec.template_file = 'site/page_template.html'
93
+ end
94
+ Site.setup(spec, templates_dir)
95
+ spec.template_file.load.should == 'template one'
96
+ spec.content_dir.file('logo.gif').load.should == 'logo one'
97
+ end
98
+
99
+ def setup_template_choice_one(templates_root)
100
+ root = templates_root.dir('one')
101
+ root.file('template.html').save('template one')
102
+ root.dir('content').file('logo.gif').save('logo one')
103
+ end
104
+
105
+ def setup_template_choice_two(templates_root)
106
+ root = templates_root.dir('two')
107
+ root.file('template.html').save('template two')
108
+ root.dir('content').file('logo.gif').save('logo two')
79
109
  end
110
+
80
111
  end
81
112
 
82
113
  end
@@ -0,0 +1,43 @@
1
+ require 'spec'
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
4
+
5
+ require 'site/site_spec'
6
+ require 'site/site'
7
+ require 'site/site_server'
8
+ require 'cotta'
9
+ require 'cotta/in_memory_system'
10
+ require 'project/server_manager'
11
+
12
+ module BuildMaster
13
+ context 'site server' do
14
+ specify 'supports server type' do
15
+ require 'net/http'
16
+ cotta = Cotta.new(InMemorySystem.new)
17
+ root = cotta.dir('/root')
18
+ root.file('content/index.txt').save(<<INDEX)
19
+ ---
20
+ Title
21
+ ---
22
+ h1. Header
23
+ INDEX
24
+ template_file = root.file('template.html')
25
+ site_spec = SiteSpec.new(template_file.path, template_file.cotta) do |spec|
26
+ spec.content_dir = 'content'
27
+ spec.output_dir = 'output'
28
+ spec.template_file = template_file.name
29
+ end
30
+ site_spec.template_file.save(<<TEMPLATE)
31
+ <html>template content</html>
32
+ TEMPLATE
33
+ server = SiteServer.new(site_spec, 8882)
34
+ puts 'checking server status'
35
+ puts "running #{server.running?}"
36
+ manager = ServerManager.new(server)
37
+ manager.start
38
+ manager.stop
39
+ server.running?.should == false
40
+ end
41
+ end
42
+ end
43
+
@@ -1,9 +1,9 @@
1
- $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib", 'buildmaster')
2
2
 
3
3
  require 'spec'
4
- require 'buildmaster'
5
- require 'buildmaster/cotta'
6
- require 'buildmaster/cotta/in_memory_system'
4
+ require 'cotta'
5
+ require 'cotta/in_memory_system'
6
+ require 'site/site_spec'
7
7
 
8
8
  module BuildMaster
9
9
 
@@ -15,13 +15,13 @@ context 'Site Specification' do
15
15
  specify 'get relative path' do
16
16
  spec = SiteSpec.new(nil, @cotta)
17
17
  spec.content_dir = '/one/two/content'
18
- spec.relative_to_root(@cotta.file('/one/two/content/images/logo.gif')).to_s.should_equal('images/logo.gif')
18
+ spec.relative_to_root(@cotta.file('/one/two/content/images/logo.gif')).to_s.should ==('images/logo.gif')
19
19
  end
20
20
 
21
21
  specify 'supports windows path' do
22
22
  spec = SiteSpec.new(nil, @cotta)
23
23
  spec.content_dir = 'C:\Work\project\content'
24
- spec.relative_to_root(@cotta.file('C:\Work\project\content\images\logo.gif')).to_s.should_equal('images/logo.gif')
24
+ spec.relative_to_root(@cotta.file('C:\Work\project\content\images\logo.gif')).to_s.should ==('images/logo.gif')
25
25
  end
26
26
 
27
27
  specify 'initialization with block' do
@@ -45,9 +45,9 @@ menu_groups:
45
45
  CONTENT
46
46
  end
47
47
  root = @cotta.dir(__FILE__).parent
48
- spec.content_dir.should_equal(root.dir('content'))
49
- spec.output_dir.should_equal(root.dir('output'))
50
- spec.load_template_source.to_s.include?('first menu group').should_equal true
48
+ spec.content_dir.should ==(root.dir('content'))
49
+ spec.output_dir.should ==(root.dir('output'))
50
+ spec.load_template_source.to_s.include?('first menu group').should == true
51
51
  end
52
52
 
53
53
  end