awestruct 0.5.4.rc3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +24 -20
  3. data/LICENSE.txt +4 -4
  4. data/README.md +5 -5
  5. data/awestruct.gemspec +14 -11
  6. data/lib/awestruct/astruct_mixin.rb +0 -1
  7. data/lib/awestruct/cli/auto.rb +38 -11
  8. data/lib/awestruct/cli/invoker.rb +55 -39
  9. data/lib/awestruct/cli/options.rb +32 -22
  10. data/lib/awestruct/compass/default_configuration.rb +108 -0
  11. data/lib/awestruct/config.rb +11 -10
  12. data/lib/awestruct/config/default-site.yml +1 -0
  13. data/lib/awestruct/context.rb +0 -1
  14. data/lib/awestruct/dependencies.rb +7 -9
  15. data/lib/awestruct/deploy/base_deploy.rb +6 -0
  16. data/lib/awestruct/deploy/github_pages_deploy.rb +1 -0
  17. data/lib/awestruct/deploy/rsync_deploy.rb +11 -7
  18. data/lib/awestruct/deployers.rb +0 -1
  19. data/lib/awestruct/engine.rb +41 -37
  20. data/lib/awestruct/extensions/cachebuster.rb +2 -2
  21. data/lib/awestruct/extensions/google_analytics.rb +57 -17
  22. data/lib/awestruct/extensions/minify.rb +4 -5
  23. data/lib/awestruct/extensions/obfuscate.rb +13 -3
  24. data/lib/awestruct/extensions/partial.rb +8 -1
  25. data/lib/awestruct/extensions/pipeline.rb +11 -6
  26. data/lib/awestruct/extensions/remotePartial.rb +1 -1
  27. data/lib/awestruct/extensions/sitemap.rb +5 -1
  28. data/lib/awestruct/frameworks/base_Gemfile +10 -7
  29. data/lib/awestruct/frameworks/base_Rakefile +5 -1
  30. data/lib/awestruct/handler_chain.rb +0 -1
  31. data/lib/awestruct/handler_chains.rb +5 -1
  32. data/lib/awestruct/handlers/asciidoctor_handler.rb +9 -22
  33. data/lib/awestruct/handlers/base_tilt_handler.rb +13 -8
  34. data/lib/awestruct/handlers/css_tilt_handler.rb +2 -1
  35. data/lib/awestruct/handlers/front_matter_handler.rb +1 -0
  36. data/lib/awestruct/handlers/interpolation_handler.rb +1 -1
  37. data/lib/awestruct/handlers/javascript_handler.rb +1 -2
  38. data/lib/awestruct/handlers/layout_handler.rb +3 -4
  39. data/lib/awestruct/handlers/no_op_handler.rb +0 -1
  40. data/lib/awestruct/handlers/page_delegating_handler.rb +0 -1
  41. data/lib/awestruct/handlers/template/asciidoc.rb +51 -47
  42. data/lib/awestruct/handlers/tilt_handler.rb +13 -6
  43. data/lib/awestruct/handlers/yaml_handler.rb +0 -1
  44. data/lib/awestruct/layouts.rb +1 -3
  45. data/lib/awestruct/logger.rb +10 -3
  46. data/lib/awestruct/page.rb +0 -1
  47. data/lib/awestruct/page_loader.rb +0 -2
  48. data/lib/awestruct/pipeline.rb +1 -1
  49. data/lib/awestruct/site.rb +0 -1
  50. data/lib/awestruct/util/exception_helper.rb +18 -6
  51. data/lib/awestruct/version.rb +1 -1
  52. data/man/awestruct.adoc +1 -1
  53. data/spec/{astruct_spec.rb → awestruct/astruct_spec.rb} +0 -0
  54. data/spec/{invoker_spec.rb → awestruct/cli/invoker_spec.rb} +6 -6
  55. data/spec/{options_spec.rb → awestruct/cli/options_spec.rb} +0 -0
  56. data/spec/awestruct/deploy/base_deploy_spec.rb +30 -0
  57. data/spec/{deploy_spec.rb → awestruct/deploy/deploy_spec.rb} +14 -11
  58. data/spec/{github_pages_deploy_spec.rb → awestruct/deploy/github_pages_deploy_spec.rb} +8 -7
  59. data/spec/{rsync_deploy_spec.rb → awestruct/deploy/rsync_deploy_spec.rb} +0 -0
  60. data/spec/{asciidoc_handler_spec.rb → awestruct/handlers/asciidoc_handler_spec.rb} +2 -3
  61. data/spec/{coffeescript_handler_spec.rb → awestruct/handlers/coffeescript_handler_spec.rb} +0 -0
  62. data/spec/{erb_handler_spec.rb → awestruct/handlers/erb_handler_spec.rb} +0 -0
  63. data/spec/{file_handler_spec.rb → awestruct/handlers/file_handler_spec.rb} +7 -7
  64. data/spec/{front_matter_handler_spec.rb → awestruct/handlers/front_matter_handler_spec.rb} +1 -1
  65. data/spec/{haml_handler_spec.rb → awestruct/handlers/haml_handler_spec.rb} +0 -0
  66. data/spec/{interpolation_handler_spec.rb → awestruct/handlers/interpolation_handler_spec.rb} +1 -1
  67. data/spec/{javascript_handler_spec.rb → awestruct/handlers/javascript_handler_spec.rb} +0 -0
  68. data/spec/{layout_handler_spec.rb → awestruct/handlers/layout_handler_spec.rb} +1 -1
  69. data/spec/{less_handler_spec.rb → awestruct/handlers/less_handler_spec.rb} +0 -0
  70. data/spec/{markdown_handler_spec.rb → awestruct/handlers/markdown_handler_spec.rb} +0 -0
  71. data/spec/{mustache_handler_spec.rb → awestruct/handlers/mustache_handler_spec.rb} +1 -0
  72. data/spec/{orgmode_handler_spec.rb → awestruct/handlers/orgmode_handler_spec.rb} +0 -0
  73. data/spec/{page_delegating_handler_spec.rb → awestruct/handlers/page_delegating_handler_spec.rb} +1 -1
  74. data/spec/{redirect_handler_spec.rb → awestruct/handlers/redirect_handler_spec.rb} +0 -0
  75. data/spec/{restructuredtext_handler_spec.rb → awestruct/handlers/restructuredtext_handler_spec.rb} +0 -0
  76. data/spec/{sass_handler_spec.rb → awestruct/handlers/sass_handler_spec.rb} +0 -0
  77. data/spec/{scss_handler_spec.rb → awestruct/handlers/scss_handler_spec.rb} +0 -0
  78. data/spec/{slim_handler_spec.rb → awestruct/handlers/slim_handler_spec.rb} +0 -0
  79. data/spec/{textile_handler_spec.rb → awestruct/handlers/textile_handler_spec.rb} +1 -0
  80. data/spec/{tilt_handler_spec.rb → awestruct/handlers/tilt_handler_spec.rb} +6 -8
  81. data/spec/{yaml_handler_spec.rb → awestruct/handlers/yaml_handler_spec.rb} +1 -1
  82. data/spec/config_spec.rb +3 -3
  83. data/spec/engine_spec.rb +30 -43
  84. data/spec/layouts_spec.rb +1 -1
  85. data/spec/minify_spec.rb +10 -10
  86. data/spec/page_loader_spec.rb +1 -1
  87. data/spec/page_loader_spec_for_layouts.rb +1 -1
  88. data/spec/page_spec.rb +1 -1
  89. data/spec/posts_archive_spec.rb +7 -7
  90. data/spec/server_spec.rb +1 -1
  91. data/spec/spec_helper.rb +2 -13
  92. data/spec/support/awestruct_setup.rb +30 -0
  93. data/spec/support/emmet_matchers.rb +4 -0
  94. data/spec/support/nokogiri_matchers.rb +4 -0
  95. data/spec/support/shared_handler_example.rb +1 -1
  96. data/spec/support/test-config/_config/site.yml +1 -0
  97. data/spec/{test-data → support/test-data}/.awestruct_ignore +0 -0
  98. data/spec/{test-data → support/test-data}/engine/_config/arbitrary.yml +0 -0
  99. data/spec/{test-data/gzip/no.html.gz → support/test-data/engine/_config/compass.rb} +0 -0
  100. data/spec/{test-data → support/test-data}/engine/_config/other.yml +0 -0
  101. data/spec/{test-data → support/test-data}/engine/_config/site.yml +3 -0
  102. data/spec/{test-data → support/test-data}/front-matter-empty.txt +0 -0
  103. data/spec/{test-data → support/test-data}/front-matter-file-no-content.txt +0 -0
  104. data/spec/{test-data → support/test-data}/front-matter-file-no-front.txt +0 -0
  105. data/spec/{test-data → support/test-data}/front-matter-file-utf8.txt +0 -0
  106. data/spec/{test-data → support/test-data}/front-matter-file.txt +0 -0
  107. data/spec/{test-data → support/test-data}/front-matter-looking.txt +0 -0
  108. data/spec/{test-data → support/test-data}/front-matter-middle.txt +0 -0
  109. data/spec/{test-data/gzip/no.txt → support/test-data/gzip/no.html.gz} +0 -0
  110. data/spec/{test-data/handlers/textile-empty-page.textile → support/test-data/gzip/no.txt} +0 -0
  111. data/spec/{test-data → support/test-data}/gzip/subdir/yes.css +0 -0
  112. data/spec/{test-data → support/test-data}/gzip/yes.html +0 -0
  113. data/spec/{test-data → support/test-data}/gzip/yes.js +0 -0
  114. data/spec/{test-data → support/test-data}/handlers/asciidoc-page.ad +0 -0
  115. data/spec/{test-data → support/test-data}/handlers/asciidoc-page.adoc +0 -0
  116. data/spec/{test-data → support/test-data}/handlers/asciidoc-page.asciidoc +0 -0
  117. data/spec/{test-data → support/test-data}/handlers/asciidoc_with_attributes.ad +0 -0
  118. data/spec/{test-data → support/test-data}/handlers/asciidoc_with_interpolation.ad +0 -0
  119. data/spec/{test-data → support/test-data}/handlers/asciidoc_without_interpolation.ad +0 -0
  120. data/spec/{test-data → support/test-data}/handlers/asciidoctor_with_front_matter.ad +0 -0
  121. data/spec/{test-data → support/test-data}/handlers/asciidoctor_with_headers.ad +0 -0
  122. data/spec/{test-data → support/test-data}/handlers/coffeescript-page.coffee +0 -0
  123. data/spec/{test-data → support/test-data}/handlers/empty-layout.haml +0 -0
  124. data/spec/{test-data → support/test-data}/handlers/erb-page.html.erb +0 -0
  125. data/spec/{test-data → support/test-data}/handlers/erb-page.xml.erb +0 -0
  126. data/spec/{test-data → support/test-data}/handlers/erb-utf-page.html.erb +0 -0
  127. data/spec/{test-data → support/test-data}/handlers/haml-error.html.haml +0 -0
  128. data/spec/{test-data → support/test-data}/handlers/haml-layout-two.html.haml +0 -0
  129. data/spec/{test-data → support/test-data}/handlers/haml-layout.html.haml +0 -0
  130. data/spec/{test-data → support/test-data}/handlers/haml-page.atom.haml +0 -0
  131. data/spec/{test-data → support/test-data}/handlers/haml-page.html.haml +0 -0
  132. data/spec/{test-data → support/test-data}/handlers/haml-page.xml.haml +0 -0
  133. data/spec/{test-data → support/test-data}/handlers/haml-with-markdown-page.html.haml +0 -0
  134. data/spec/{test-data → support/test-data}/handlers/haml-with-textile-page.html.haml +0 -0
  135. data/spec/{test-data → support/test-data}/handlers/haml-with-utf.html.haml +0 -0
  136. data/spec/{test-data → support/test-data}/handlers/haml-with-variables.html.haml +0 -0
  137. data/spec/{test-data → support/test-data}/handlers/hello.bogus +0 -0
  138. data/spec/{test-data → support/test-data}/handlers/inner-page.html.haml +0 -0
  139. data/spec/{test-data → support/test-data}/handlers/javascript-page.js +0 -0
  140. data/spec/{test-data → support/test-data}/handlers/less-page-include.less +0 -0
  141. data/spec/{test-data → support/test-data}/handlers/less-page-with-import.less +0 -0
  142. data/spec/{test-data → support/test-data}/handlers/less-page.less +0 -0
  143. data/spec/{test-data → support/test-data}/handlers/markdown-page.markdown +0 -0
  144. data/spec/{test-data → support/test-data}/handlers/markdown-page.md +0 -0
  145. data/spec/{test-data → support/test-data}/handlers/markdown-page.mkd +0 -0
  146. data/spec/{test-data → support/test-data}/handlers/mustache-page.html.mustache +0 -0
  147. data/spec/{test-data → support/test-data}/handlers/mustache-page.xml.mustache +0 -0
  148. data/spec/{test-data → support/test-data}/handlers/orgmode-page.org +0 -0
  149. data/spec/{test-data → support/test-data}/handlers/outer-layout.html.haml +0 -0
  150. data/spec/{test-data → support/test-data}/handlers/outside_relative/git_keep +0 -0
  151. data/spec/{test-data → support/test-data}/handlers/redirect-page.redirect +0 -0
  152. data/spec/{test-data → support/test-data}/handlers/restructuredtext-page.rst +0 -0
  153. data/spec/{test-data → support/test-data}/handlers/sass-page-include.sass +0 -0
  154. data/spec/{test-data → support/test-data}/handlers/sass-page.sass +0 -0
  155. data/spec/{test-data → support/test-data}/handlers/scss-page-include.scss +0 -0
  156. data/spec/{test-data → support/test-data}/handlers/scss-page.scss +0 -0
  157. data/spec/{test-data → support/test-data}/handlers/simple-redirect-page.redirect +0 -0
  158. data/spec/{test-data → support/test-data}/handlers/slim-page.atom.slim +0 -0
  159. data/spec/{test-data → support/test-data}/handlers/slim-page.html.slim +0 -0
  160. data/spec/{test-data → support/test-data}/handlers/slim-page.xml.slim +0 -0
  161. data/spec/{test-data → support/test-data}/handlers/slim-with-markdown-page.html.slim +0 -0
  162. data/spec/{test-data → support/test-data}/handlers/slim-with-utf.html.slim +0 -0
  163. data/spec/{test-data → support/test-data}/handlers/slim-with-variables.html.slim +0 -0
  164. data/spec/support/test-data/handlers/textile-empty-page.textile +0 -0
  165. data/spec/{test-data → support/test-data}/handlers/textile-page.textile +0 -0
  166. data/spec/{test-data → support/test-data}/images/logo.png +0 -0
  167. data/spec/{test-data → support/test-data}/index.html +0 -0
  168. data/spec/{test-data → support/test-data}/javascript/bootstrap-dropdown.js +0 -0
  169. data/spec/{test-data → support/test-data}/out-of-site/page-three.html.haml +0 -0
  170. data/spec/support/test-data/page-loader/.awestruct_ignore +2 -0
  171. data/spec/{test-data → support/test-data}/page-loader/_layouts/layout-one.md +0 -0
  172. data/spec/{test-data → support/test-data}/page-loader/_layouts/layout-two.html.haml +0 -0
  173. data/spec/{test-data → support/test-data}/page-loader/page-draft.md +0 -0
  174. data/spec/{test-data → support/test-data}/page-loader/page-one.md +0 -0
  175. data/spec/{test-data → support/test-data}/page-loader/page-two.html.haml +0 -0
  176. data/spec/{test-data → support/test-data}/simple-data.yaml +0 -0
  177. data/spec/{test-data → support/test-data}/simple-file.txt +0 -0
  178. data/spec/{test-data → support/test-data}/stylesheets/screen.css +0 -0
  179. data/spec/{test-data → support/test-data}/subdir/index.html +0 -0
  180. metadata +251 -232
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'awestruct/deploy/base_deploy'
3
+
4
+ describe Awestruct::Deploy::Base do
5
+ before :each do
6
+ @site_config = double
7
+ @site_config.stub(:output_dir).and_return '_site'
8
+
9
+ @deploy_config = double
10
+ @deploy_config.stub(:[]).with('branch').and_return('the-branch')
11
+ @deploy_config.stub(:[]).with('repository').and_return('the-repo')
12
+ @deploy_config.stub(:[]).with('gzip').and_return('false')
13
+ @deploy_config.stub(:[]).with('gzip_level')
14
+ @deploy_config.stub(:[]).with('scm').and_return('git')
15
+ @deploy_config.stub(:[]).with('source_dir').and_return('.')
16
+ @deploy_config.stub(:[]).with('uncommitted').and_return('false')
17
+ Awestruct::ExceptionHelper.class_variable_set :@@failed, false
18
+ end
19
+
20
+ it "should not run if the build failed" do
21
+ log = StringIO.new
22
+ $LOG = Logger.new(log)
23
+ $LOG.level = Logger::DEBUG
24
+ Awestruct::ExceptionHelper.mark_failed
25
+
26
+ deployer = Awestruct::Deploy::Base.new(@site_config, @deploy_config)
27
+ deployer.run
28
+ expect(log.string).to include('Not running deploy due to build failure')
29
+ end
30
+ end
@@ -2,6 +2,9 @@ require 'spec_helper'
2
2
  require 'awestruct/cli/deploy'
3
3
 
4
4
  describe Awestruct::CLI::Deploy do
5
+ before :each do
6
+ Awestruct::ExceptionHelper.class_variable_set :@@failed, false
7
+ end
5
8
 
6
9
  it "should use a given deploy[:type]" do
7
10
  deployer = Awestruct::CLI::Deploy.new({}, {'type' => :foo})
@@ -39,10 +42,10 @@ describe Awestruct::CLI::Deploy do
39
42
  end
40
43
 
41
44
  it "should gzip if deploy['gzip'] is true" do
42
- site_config = mock
45
+ site_config = double
43
46
  site_config.stub(:output_dir).and_return '_site'
44
47
 
45
- deploy_config = mock
48
+ deploy_config = double
46
49
  deploy_config.stub(:[]).with('gzip').and_return true
47
50
  deploy_config.stub(:[]).with('gzip_level')
48
51
  deploy_config.stub(:[]).with('source_dir').and_return '.'
@@ -56,14 +59,14 @@ describe Awestruct::CLI::Deploy do
56
59
 
57
60
  it "should only gzip html, css and js files" do
58
61
  site_tmp_dir = Dir.mktmpdir("site_dir")
59
- site_src_dir = File.join(File.dirname(__FILE__), 'test-data/gzip')
62
+ site_src_dir = test_data_dir 'gzip'
60
63
  FileUtils.cp_r(site_src_dir, site_tmp_dir)
61
64
  site_dir = "#{site_tmp_dir}/gzip"
62
65
 
63
- site_config = mock
66
+ site_config = double
64
67
  site_config.stub(:output_dir).and_return "#{site_dir}"
65
68
 
66
- deploy_config = mock
69
+ deploy_config = double
67
70
  deploy_config.stub(:[]).with('gzip').and_return true
68
71
  deploy_config.stub(:[]).with('gzip_level')
69
72
  deploy_config.stub(:[]).with('source_dir').and_return '.'
@@ -81,14 +84,14 @@ describe Awestruct::CLI::Deploy do
81
84
 
82
85
  it "should gzip only once" do
83
86
  site_tmp_dir = Dir.mktmpdir("site_dir")
84
- site_src_dir = File.join(File.dirname(__FILE__), 'test-data/gzip')
87
+ site_src_dir = test_data_dir 'gzip'
85
88
  FileUtils.cp_r(site_src_dir, site_tmp_dir)
86
89
  site_dir = "#{site_tmp_dir}/gzip"
87
90
 
88
- site_config = mock
91
+ site_config = double
89
92
  site_config.stub(:output_dir).and_return "#{site_dir}"
90
93
 
91
- deploy_config = mock
94
+ deploy_config = double
92
95
  deploy_config.stub(:[]).with('gzip').and_return true
93
96
  deploy_config.stub(:[]).with('gzip_level')
94
97
  deploy_config.stub(:[]).with('source_dir').and_return '.'
@@ -108,14 +111,14 @@ describe Awestruct::CLI::Deploy do
108
111
 
109
112
  it "should gzip with the compression level" do
110
113
  site_tmp_dir = Dir.mktmpdir("site_dir")
111
- site_src_dir = File.join(File.dirname(__FILE__), 'test-data/gzip')
114
+ site_src_dir = test_data_dir 'gzip'
112
115
  FileUtils.cp_r(site_src_dir, site_tmp_dir)
113
116
  site_dir = "#{site_tmp_dir}/gzip"
114
117
 
115
- site_config = mock
118
+ site_config = double
116
119
  site_config.stub(:output_dir).and_return "#{site_dir}"
117
120
 
118
- deploy_config = mock
121
+ deploy_config = double
119
122
  deploy_config.stub(:[]).with('gzip').and_return true
120
123
  deploy_config.stub(:[]).with('gzip_level').and_return 6
121
124
  deploy_config.stub(:[]).with('source_dir').and_return '.'
@@ -4,10 +4,10 @@ require 'awestruct/deploy/github_pages_deploy'
4
4
  describe Awestruct::Deploy::GitHubPagesDeploy do
5
5
 
6
6
  before :each do
7
- site_config = mock
7
+ site_config = double
8
8
  site_config.stub(:output_dir).and_return '_site'
9
9
 
10
- @deploy_config = mock
10
+ @deploy_config = double
11
11
  @deploy_config.stub(:[]).with('branch').and_return('the-branch')
12
12
  @deploy_config.stub(:[]).with('repository').and_return('the-repo')
13
13
  @deploy_config.stub(:[]).with('gzip').and_return('false')
@@ -17,17 +17,18 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
17
17
  @deploy_config.stub(:[]).with('uncommitted').and_return('false')
18
18
  @deployer = Awestruct::Deploy::GitHubPagesDeploy.new( site_config, @deploy_config )
19
19
 
20
- @git = mock
20
+ @git = double
21
21
  @git.stub_chain(:status, :changed, :empty?).and_return true
22
22
  ::Git.stub(:open).with('.').and_return @git
23
+ Awestruct::ExceptionHelper.class_variable_set :@@failed, false
23
24
  end
24
-
25
+
25
26
  it "should be auto-registered" do
26
27
  Awestruct::Deployers.instance[ :github_pages ].should == Awestruct::Deploy::GitHubPagesDeploy
27
28
  end
28
29
 
29
30
  it "should warn and noop if no changes have been committed" do
30
- git_scm = mock()
31
+ git_scm = double()
31
32
  git_scm.stub(:uncommitted_changes?).with('.').and_return true
32
33
  @deployer.instance_variable_set('@scm', git_scm)
33
34
  $LOG.should_receive(:error).with(Awestruct::Deploy::Base::UNCOMMITTED_CHANGES)
@@ -35,7 +36,7 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
35
36
  end
36
37
 
37
38
  it "should save and restore the current branch when publishing" do
38
- git_scm = mock()
39
+ git_scm = double()
39
40
  git_scm.stub(:uncommitted_changes?).with('.').and_return false
40
41
  @deployer.instance_variable_set('@scm', git_scm)
41
42
  @git.should_receive(:current_branch).and_return( 'bacon' )
@@ -48,7 +49,7 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
48
49
  end
49
50
 
50
51
  it "should save and restore the current detached branch when publishing" do
51
- git_scm = mock()
52
+ git_scm = double()
52
53
  git_scm.stub(:uncommitted_changes?).with('.').and_return false
53
54
  @deployer.instance_variable_set('@scm', git_scm)
54
55
  @git.should_receive(:current_branch).and_return( '(no branch)' )
@@ -43,14 +43,14 @@ verify_attributes = lambda { |output, page|
43
43
 
44
44
  verify_interpolation = lambda { |output, page|
45
45
  extend RSpec::Matchers
46
- output.should =~ %r(UTF-8)
47
46
  page.site.interpolate.should == true
47
+ output.should =~ %r(UTF-8)
48
48
  }
49
49
 
50
50
  verify_no_interpolation = lambda { |output, page|
51
51
  extend RSpec::Matchers
52
+ page.site.interpolate.should == false
52
53
  output.should =~ %r(\#\{site\.encoding\})
53
- page.site.interpolate.should == true
54
54
  }
55
55
 
56
56
  theories =
@@ -111,7 +111,6 @@ theories =
111
111
  :syntax => :asciidoc,
112
112
  :extension => '.html',
113
113
  :matcher => verify_no_interpolation,
114
- :site_overrides => { :interpolate => true }
115
114
  }
116
115
  ]
117
116
 
@@ -5,37 +5,37 @@ require 'awestruct/handlers/file_handler'
5
5
  describe Awestruct::Handlers::FileHandler do
6
6
 
7
7
  before :all do
8
- @site = Hashery::OpenCascade[ { :encoding=>false, :dir=>Pathname.new( File.dirname( __FILE__ ) + '/test-data' ) } ]
8
+ @site = Hashery::OpenCascade[ { :encoding=>false, :dir=>Pathname.new( test_data_dir '' )}]
9
9
  end
10
10
 
11
11
  it "should be able to read a valid absolute file handler" do
12
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
12
+ filename = Pathname.new( test_data_dir 'simple-file.txt' )
13
13
  handler = Awestruct::Handlers::FileHandler.new( @site, filename )
14
14
  handler.raw_content.strip.should == 'howdy'
15
15
  end
16
16
 
17
17
  it "should be able to read a valid relative file handler" do
18
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
18
+ filename = Pathname.new( test_data_dir 'simple-file.txt' )
19
19
  pwd = Pathname.new( Dir.pwd )
20
20
  handler = Awestruct::Handlers::FileHandler.new( @site, filename.relative_path_from( pwd ) )
21
21
  handler.raw_content.strip.should == 'howdy'
22
22
  end
23
23
 
24
24
  it "should be stale before being read" do
25
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
25
+ filename = Pathname.new( test_data_dir 'simple-file.txt' )
26
26
  handler = Awestruct::Handlers::FileHandler.new( @site, filename )
27
27
  handler.should be_stale
28
28
  end
29
29
 
30
30
  it "should not be stale after being read" do
31
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
31
+ filename = Pathname.new( test_data_dir 'simple-file.txt' )
32
32
  handler = Awestruct::Handlers::FileHandler.new( @site, filename )
33
33
  handler.raw_content.strip.should == 'howdy'
34
34
  handler.should_not be_stale
35
35
  end
36
36
 
37
37
  it "should be stale if touched after being read" do
38
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
38
+ filename = Pathname.new( test_data_dir 'simple-file.txt' )
39
39
  handler = Awestruct::Handlers::FileHandler.new( @site, filename )
40
40
  handler.raw_content.strip.should == 'howdy'
41
41
  handler.should_not be_stale
@@ -45,7 +45,7 @@ describe Awestruct::Handlers::FileHandler do
45
45
  end
46
46
 
47
47
  it "should provide reasonable paths" do
48
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
48
+ filename = Pathname.new( test_data_dir 'simple-file.txt' )
49
49
  handler = Awestruct::Handlers::FileHandler.new( @site, filename )
50
50
  handler.relative_source_path.should == '/simple-file.txt'
51
51
  handler.output_filename.should == 'simple-file.txt'
@@ -17,7 +17,7 @@ describe Awestruct::Handlers::FrontMatterHandler do
17
17
  end
18
18
 
19
19
  def file_input(filename)
20
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/#{filename}" )
20
+ filename = Pathname.new( test_data_dir filename )
21
21
  Awestruct::Handlers::FileHandler.new( @site, filename )
22
22
  end
23
23
 
@@ -5,7 +5,7 @@ require 'awestruct/handlers/interpolation_handler'
5
5
  describe Awestruct::Handlers::InterpolationHandler do
6
6
 
7
7
  before :all do
8
- @site = Hashery::OpenCascade[ { :encoding=>false } ]
8
+ @site = Hashery::OpenCascade[ { encoding: false, interpolate: true } ]
9
9
  end
10
10
 
11
11
  it "should interpolate content when rendered" do
@@ -14,7 +14,7 @@ describe Awestruct::Handlers::LayoutHandler do
14
14
 
15
15
 
16
16
  before :all do
17
- @config = Hashery::OpenCascade[ { :dir=>Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' ) } ]
17
+ @config = Hashery::OpenCascade[ { :dir=>Pathname.new( test_data_dir 'handlers' ) } ]
18
18
  @engine = Awestruct::Engine.new
19
19
  @site = Awestruct::Site.new( @engine, @config )
20
20
  layout_loader = Awestruct::PageLoader.new( @site, :layouts )
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'mustache'
2
3
 
3
4
  verify = lambda { |output|
4
5
  output.should =~ %r(<h1>This is a Mustache page</h1>)
@@ -8,7 +8,7 @@ require 'hashery'
8
8
  describe Awestruct::Handlers::PageDelegatingHandler do
9
9
 
10
10
  before :all do
11
- @config = Hashery::OpenCascade[ { :dir=>Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' ) } ]
11
+ @config = Hashery::OpenCascade[ { :dir=>Pathname.new( test_data_dir 'handlers' ) } ]
12
12
  @engine = Awestruct::Engine.new( @config )
13
13
  @site = @engine.site
14
14
  layout_loader = Awestruct::PageLoader.new( @site, :layouts )
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'haml/filters/textile'
2
3
 
3
4
  verify_without_span = lambda { |output|
4
5
  output.should == "<h3>Test</h3>\n<p>the WHO</p>"
@@ -1,13 +1,11 @@
1
1
  require 'logger'
2
2
  require 'awestruct/config'
3
- #require 'awestruct/engine'
4
3
  require 'awestruct/handlers/file_handler'
5
4
  require 'awestruct/handlers/tilt_handler'
6
5
 
7
6
  require 'hashery'
8
7
  require 'tilt/template'
9
8
 
10
-
11
9
  module Tilt
12
10
  class BogusTemplate < Template
13
11
  self.default_mime_type = 'text/html'
@@ -34,7 +32,7 @@ end
34
32
  describe Awestruct::Handlers::TiltHandler do
35
33
 
36
34
  before do
37
- dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' )
35
+ dir = Pathname.new( test_data_dir 'handlers' )
38
36
  opts = Awestruct::CLI::Options.new
39
37
  opts.source_dir = dir
40
38
 
@@ -79,7 +77,7 @@ describe Awestruct::Handlers::TiltHandler do
79
77
 
80
78
  it "should handle pages with no relative_source_path" do
81
79
  ## force relative_source_path.nil
82
- @site.dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers/outside_relative' )
80
+ @site.dir = Pathname.new( test_data_dir 'handlers/outside_relative' )
83
81
  file_handler = Awestruct::Handlers::FileHandler.new( @site, handler_file( "asciidoc-page.asciidoc" ) )
84
82
  handler = Awestruct::Handlers::TiltHandler.new( @site, file_handler )
85
83
 
@@ -92,7 +90,7 @@ describe Awestruct::Handlers::TiltHandler do
92
90
  end
93
91
 
94
92
  it "should handle non extension dots in source name" do
95
- @site.dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers/outside_relative' )
93
+ @site.dir = Pathname.new( test_data_dir 'handlers/outside_relative' )
96
94
  file_handler = Awestruct::Handlers::FileHandler.new( @site, handler_file( "warp-1.0.0.Alpha2.textile" ) )
97
95
  handler = Awestruct::Handlers::TiltHandler.new( @site, file_handler )
98
96
 
@@ -112,10 +110,10 @@ describe Awestruct::Handlers::TiltHandler do
112
110
  log = StringIO.new
113
111
  $LOG = Logger.new(log)
114
112
  $LOG.level = Logger::DEBUG
115
- @site.dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers/' )
113
+ @site.dir = Pathname.new( test_data_dir 'handlers' )
116
114
  path = handler_file( "hello.bogus" )
117
115
  expect(Awestruct::Handlers::TiltMatcher.new().match(path)).to be_false
118
- expect(log.string).to include('missing required gem')
116
+ expect(log.string).to include('could not load engine for type')
119
117
 
120
118
  # we don't even want to process a file if we cannot load its Tilt template
121
119
  #file_handler = Awestruct::Handlers::FileHandler.new( @site, path )
@@ -133,7 +131,7 @@ describe Awestruct::Handlers::TiltHandler do
133
131
  log = StringIO.new
134
132
  $LOG = Logger.new(log)
135
133
  $LOG.level = Logger::DEBUG
136
- @site.dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers/' )
134
+ @site.dir = Pathname.new( test_data_dir 'handlers' )
137
135
  file_handler = Awestruct::Handlers::FileHandler.new( @site, handler_file( "haml-error.html.haml" ) )
138
136
  handler = Awestruct::Handlers::TiltHandler.new( @site, file_handler )
139
137
  content = handler.rendered_content(create_context)
@@ -10,7 +10,7 @@ describe Awestruct::Handlers::YamlHandler do
10
10
  end
11
11
 
12
12
  it "should provide access to the yaml as front-matter" do
13
- filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-data.yaml" )
13
+ filename = Pathname.new( test_data_dir 'simple-data.yaml' )
14
14
  file_handler = Awestruct::Handlers::FileHandler.new( @site, filename )
15
15
  handler = Awestruct::Handlers::YamlHandler.new( @site, file_handler )
16
16
  handler.raw_content.should be_nil
@@ -6,7 +6,7 @@ require 'awestruct/cli/options'
6
6
  describe Awestruct::Config do
7
7
 
8
8
  it "should accept a list of files in .awestruct_ignore to ignore on site generation" do
9
- site_dir = File.join(File.dirname(__FILE__), 'test-data')
9
+ site_dir = test_data_dir ''
10
10
  opts = Awestruct::CLI::Options.new
11
11
  opts.source_dir = site_dir
12
12
 
@@ -15,7 +15,7 @@ describe Awestruct::Config do
15
15
  end
16
16
 
17
17
  it "should handle an empty .awestruct_ignore file without barfing" do
18
- site_dir = File.join(File.dirname(__FILE__), 'test-data')
18
+ site_dir = test_data_dir ''
19
19
  config_file = File.join(site_dir, ".awestruct_ignore")
20
20
  opts = Awestruct::CLI::Options.new
21
21
  opts.source_dir = site_dir
@@ -25,4 +25,4 @@ describe Awestruct::Config do
25
25
  File.open(config_file, "w") { |f| f.write("Rakefile\nGemfile\n") }
26
26
  end
27
27
 
28
- end
28
+ end
@@ -7,7 +7,7 @@ describe Awestruct::Engine do
7
7
 
8
8
  it "should be able to load default-site.yml" do
9
9
  opts = Awestruct::CLI::Options.new
10
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
10
+ opts.source_dir = test_data_dir 'engine'
11
11
  config = Awestruct::Config.new( opts )
12
12
 
13
13
  engine = Awestruct::Engine.new(config)
@@ -21,7 +21,7 @@ describe Awestruct::Engine do
21
21
 
22
22
  it "should be able to override default with site" do
23
23
  opts = Awestruct::CLI::Options.new
24
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
24
+ opts.source_dir = test_data_dir 'engine'
25
25
  config = Awestruct::Config.new( opts )
26
26
 
27
27
  engine = Awestruct::Engine.new(config)
@@ -37,7 +37,7 @@ describe Awestruct::Engine do
37
37
 
38
38
  it "should be able to load site.yml with the correct profile" do
39
39
  opts = Awestruct::CLI::Options.new
40
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
40
+ opts.source_dir = test_data_dir 'engine'
41
41
  config = Awestruct::Config.new( opts )
42
42
 
43
43
  engine = Awestruct::Engine.new(config)
@@ -57,9 +57,21 @@ describe Awestruct::Engine do
57
57
  engine.site.show_drafts.should == true
58
58
  end
59
59
 
60
+ it "should be able to handle UTF-8 in site.yml" do
61
+ opts = Awestruct::CLI::Options.new
62
+ opts.source_dir = test_data_dir 'engine'
63
+ config = Awestruct::Config.new( opts )
64
+
65
+ engine = Awestruct::Engine.new(config)
66
+ engine.load_default_site_yaml
67
+ engine.load_user_site_yaml( 'development' )
68
+ engine.site.intl_name.should == "Intern\u00e9\u0161nl"
69
+ end
70
+
71
+
60
72
  it "should be able to load arbitrary _config/*.yml files" do
61
73
  opts = Awestruct::CLI::Options.new
62
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
74
+ opts.source_dir = test_data_dir 'engine'
63
75
  config = Awestruct::Config.new( opts )
64
76
 
65
77
  engine = Awestruct::Engine.new(config)
@@ -69,7 +81,7 @@ describe Awestruct::Engine do
69
81
 
70
82
  it "should be able to load all arbitary yamls" do
71
83
  opts = Awestruct::CLI::Options.new
72
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
84
+ opts.source_dir = test_data_dir 'engine'
73
85
  config = Awestruct::Config.new( opts )
74
86
 
75
87
  engine = Awestruct::Engine.new(config)
@@ -80,20 +92,20 @@ describe Awestruct::Engine do
80
92
  end
81
93
 
82
94
  it "should exclude line comments and minify in compass by default in production mode" do
83
- compass = compass_config
84
95
  opts = Awestruct::CLI::Options.new
85
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
96
+ opts.source_dir = test_data_dir 'engine'
97
+
86
98
  config = Awestruct::Config.new( opts )
87
99
  engine = Awestruct::Engine.new(config)
88
100
  engine.load_user_site_yaml( 'production' )
89
- Compass.stub(:configuration).and_return(compass)
90
- compass.should_receive(:line_comments=).with(false)
91
- compass.stub(:line_comments).and_return(false)
92
- compass.should_receive(:output_style=).with(:compressed)
93
- compass.stub(:output_style).and_return(:compressed)
94
- compass.stub(:http_path=).with(nil)
95
- compass.stub(:relative_assets=).with(false)
101
+
96
102
  engine.configure_compass
103
+
104
+ expect( Compass.configuration.line_comments ).to eq false
105
+ expect( Compass.configuration.output_style ).to eq :compressed
106
+ expect( Compass.configuration.http_path ).to be nil
107
+ expect( Compass.configuration.relative_assets ).to eq false
108
+
97
109
  engine.site.sass.line_numbers.should == false
98
110
  engine.site.sass.style.should == :compressed
99
111
  engine.site.scss.line_numbers.should == false
@@ -101,20 +113,13 @@ describe Awestruct::Engine do
101
113
  end
102
114
 
103
115
  it "should include line comments in compass by default in development mode" do
104
- compass = compass_config
105
116
  opts = Awestruct::CLI::Options.new
106
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
117
+ opts.source_dir = test_data_dir 'engine'
107
118
  config = Awestruct::Config.new( opts )
108
119
  engine = Awestruct::Engine.new(config)
109
120
  engine.load_user_site_yaml( 'development' )
110
- Compass.stub(:configuration).and_return(compass)
111
- compass.should_receive(:line_comments=).with(true)
112
- compass.stub(:line_comments).and_return(true)
113
- compass.should_receive(:output_style=).with(:expanded)
114
- compass.stub(:output_style).and_return(:expanded)
115
- compass.stub(:http_path=).with(nil)
116
- compass.stub(:relative_assets=).with(false)
117
121
  engine.configure_compass
122
+
118
123
  engine.site.sass.line_numbers.should == true
119
124
  engine.site.sass.style.should == :expanded
120
125
  engine.site.scss.line_numbers.should == true
@@ -122,20 +127,13 @@ describe Awestruct::Engine do
122
127
  end
123
128
 
124
129
  it "wip should accept site.compass_line_comments and site.compass_output_style to configure behavior" do
125
- compass = compass_config
126
130
  opts = Awestruct::CLI::Options.new
127
- opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
131
+ opts.source_dir = test_data_dir 'engine'
128
132
  config = Awestruct::Config.new( opts )
129
133
  engine = Awestruct::Engine.new(config)
130
134
  engine.load_user_site_yaml( 'staging' )
131
- Compass.stub(:configuration).and_return(compass)
132
- compass.should_receive(:line_comments=).with(false)
133
- compass.stub(:line_comments).and_return(false)
134
- compass.should_receive(:output_style=).with(:compact)
135
- compass.stub(:output_style).and_return(:compact)
136
- compass.stub(:http_path=).with(nil)
137
- compass.stub(:relative_assets=).with(false)
138
135
  engine.configure_compass
136
+
139
137
  engine.site.sass.line_numbers.should == false
140
138
  engine.site.sass.style.should == :compact
141
139
  engine.site.scss.line_numbers.should == false
@@ -144,14 +142,3 @@ describe Awestruct::Engine do
144
142
 
145
143
  end
146
144
 
147
- def compass_config
148
- config = mock
149
- config.stub(:project_type=)
150
- config.stub(:project_path=)
151
- config.stub(:sass_dir=)
152
- config.stub(:css_dir=)
153
- config.stub(:javascripts_dir=)
154
- config.stub(:images_dir=)
155
- config.stub(:fonts_dir=)
156
- config
157
- end