awestruct 0.4.8 → 0.5.0.cr
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awestruct/astruct.rb +4 -0
- data/lib/awestruct/astruct_mixin.rb +3 -0
- data/lib/awestruct/cli/auto.rb +6 -6
- data/lib/awestruct/cli/deploy.rb +3 -3
- data/lib/awestruct/cli/generate.rb +5 -3
- data/lib/awestruct/cli/init.rb +1 -1
- data/lib/awestruct/cli/invoker.rb +10 -3
- data/lib/awestruct/cli/manifest.rb +18 -17
- data/lib/awestruct/cli/options.rb +7 -6
- data/lib/awestruct/cli/server.rb +7 -14
- data/lib/awestruct/config.rb +7 -1
- data/lib/awestruct/config/default-site.yml +30 -0
- data/lib/awestruct/context_helper.rb +7 -7
- data/lib/awestruct/dependencies.rb +14 -11
- data/lib/awestruct/deploy/base_deploy.rb +2 -2
- data/lib/awestruct/deploy/github_pages_deploy.rb +1 -1
- data/lib/awestruct/deploy/rsync_deploy.rb +11 -15
- data/lib/awestruct/deploy/s3_deploy.rb +9 -0
- data/lib/awestruct/engine.rb +72 -21
- data/lib/awestruct/extensions/minify.rb +21 -20
- data/lib/awestruct/extensions/paginator.rb +5 -5
- data/lib/awestruct/extensions/partial.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +5 -1
- data/lib/awestruct/extensions/posts.rb +8 -4
- data/lib/awestruct/extensions/relative.rb +7 -2
- data/lib/awestruct/extensions/remotePartial.rb +1 -1
- data/lib/awestruct/extensions/sitemap.rb +1 -1
- data/lib/awestruct/frameworks/bootstrap/base_index.html.haml +1 -1
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +1 -1
- data/lib/awestruct/handler_chains.rb +8 -23
- data/lib/awestruct/handlers/asciidoctor_handler.rb +114 -0
- data/lib/awestruct/handlers/base_tilt_handler.rb +114 -0
- data/lib/awestruct/handlers/css_tilt_handler.rb +43 -0
- data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
- data/lib/awestruct/handlers/interpolation_handler.rb +3 -3
- data/lib/awestruct/handlers/layout_handler.rb +6 -4
- data/lib/awestruct/handlers/restructuredtext_handler.rb +5 -5
- data/lib/awestruct/handlers/template/asciidoc.rb +41 -0
- data/lib/awestruct/handlers/template/mustache.rb +25 -0
- data/lib/awestruct/handlers/tilt_handler.rb +73 -0
- data/lib/awestruct/layouts.rb +1 -1
- data/lib/awestruct/logger.rb +59 -0
- data/lib/awestruct/page.rb +16 -3
- data/lib/awestruct/page_loader.rb +5 -5
- data/lib/awestruct/version.rb +1 -1
- data/man/awestruct.1 +163 -0
- data/spec/asciidoc_handler_spec.rb +75 -0
- data/spec/astruct_spec.rb +52 -0
- data/spec/coffeescript_handler_spec.rb +23 -0
- data/spec/config_spec.rb +22 -0
- data/spec/context_helper_spec.rb +115 -0
- data/spec/deploy_spec.rb +41 -0
- data/spec/disqus_spec.rb +43 -0
- data/spec/engine_spec.rb +115 -0
- data/spec/erb_handler_spec.rb +52 -0
- data/spec/file_handler_spec.rb +57 -0
- data/spec/front_matter_handler_spec.rb +42 -0
- data/spec/github_pages_deploy_spec.rb +56 -0
- data/spec/haml_handler_spec.rb +93 -0
- data/spec/handler_chain_spec.rb +44 -0
- data/spec/handler_chains_spec.rb +25 -0
- data/spec/interpolation_handler_spec.rb +35 -0
- data/spec/invoker_spec.rb +74 -0
- data/spec/javascript_handler_spec.rb +23 -0
- data/spec/layout_handler_spec.rb +77 -0
- data/spec/layouts_spec.rb +32 -0
- data/spec/less_handler_spec.rb +33 -0
- data/spec/markdown_handler_spec.rb +41 -0
- data/spec/minify_spec.rb +61 -0
- data/spec/mustache_handler_spec.rb +29 -0
- data/spec/options_spec.rb +97 -0
- data/spec/orgmode_handler_spec.rb +24 -0
- data/spec/page_delegating_handler_spec.rb +79 -0
- data/spec/page_loader_spec.rb +43 -0
- data/spec/page_loader_spec_for_layouts.rb +36 -0
- data/spec/page_spec.rb +65 -0
- data/spec/pipeline_spec.rb +12 -0
- data/spec/posts_archive_spec.rb +108 -0
- data/spec/redirect_handler_spec.rb +32 -0
- data/spec/restructuredtext_handler_spec.rb +22 -0
- data/spec/rsync_deploy_spec.rb +9 -0
- data/spec/sass_handler_spec.rb +23 -0
- data/spec/scss_handler_spec.rb +23 -0
- data/spec/server_spec.rb +45 -0
- data/spec/slim_handler_spec.rb +81 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/nokogiri_matchers.rb +21 -0
- data/spec/support/shared_handler_example.rb +98 -0
- data/spec/test-data/engine/_config/arbitrary.yml +2 -0
- data/spec/test-data/engine/_config/other.yml +1 -0
- data/spec/test-data/engine/_config/site.yml +14 -0
- data/spec/test-data/front-matter-file-no-content.txt +2 -0
- data/spec/test-data/front-matter-file-no-front.txt +1 -0
- data/spec/test-data/front-matter-file.txt +4 -0
- data/spec/test-data/handlers/asciidoc-page.ad +3 -0
- data/spec/test-data/handlers/asciidoc-page.adoc +3 -0
- data/spec/test-data/handlers/asciidoc-page.asciidoc +3 -0
- data/spec/test-data/handlers/asciidoctor_with_front_matter.ad +6 -0
- data/spec/test-data/handlers/asciidoctor_with_headers.ad +8 -0
- data/spec/test-data/handlers/coffeescript-page.coffee +8 -0
- data/spec/test-data/handlers/erb-page.html.erb +6 -0
- data/spec/test-data/handlers/erb-page.xml.erb +2 -0
- data/spec/test-data/handlers/erb-utf-page.html.erb +2 -0
- data/spec/test-data/handlers/haml-layout-two.html.haml +7 -0
- data/spec/test-data/handlers/haml-layout.html.haml +4 -0
- data/spec/test-data/handlers/haml-page.atom.haml +4 -0
- data/spec/test-data/handlers/haml-page.html.haml +2 -0
- data/spec/test-data/handlers/haml-page.xml.haml +1 -0
- data/spec/test-data/handlers/haml-with-markdown-page.html.haml +6 -0
- data/spec/test-data/handlers/haml-with-textile-page.html.haml +6 -0
- data/spec/test-data/handlers/haml-with-utf.html.haml +2 -0
- data/spec/test-data/handlers/haml-with-variables.html.haml +2 -0
- data/spec/test-data/handlers/inner-page.html.haml +4 -0
- data/spec/test-data/handlers/javascript-page.js +1 -0
- data/spec/test-data/handlers/less-page-include.less +1 -0
- data/spec/test-data/handlers/less-page-with-import.less +4 -0
- data/spec/test-data/handlers/less-page.less +4 -0
- data/spec/test-data/handlers/markdown-page.markdown +2 -0
- data/spec/test-data/handlers/markdown-page.md +2 -0
- data/spec/test-data/handlers/markdown-page.mkd +2 -0
- data/spec/test-data/handlers/mustache-page.html.mustache +2 -0
- data/spec/test-data/handlers/mustache-page.xml.mustache +1 -0
- data/spec/test-data/handlers/orgmode-page.org +6 -0
- data/spec/test-data/handlers/outer-layout.html.haml +2 -0
- data/spec/test-data/handlers/outside_relative/git_keep +3 -0
- data/spec/test-data/handlers/redirect-page.redirect +1 -0
- data/spec/test-data/handlers/restructuredtext-page.rst +8 -0
- data/spec/test-data/handlers/sass-page-include.sass +1 -0
- data/spec/test-data/handlers/sass-page.sass +4 -0
- data/spec/test-data/handlers/scss-page-include.scss +1 -0
- data/spec/test-data/handlers/scss-page.scss +5 -0
- data/spec/test-data/handlers/simple-redirect-page.redirect +1 -0
- data/spec/test-data/handlers/slim-page.atom.slim +4 -0
- data/spec/test-data/handlers/slim-page.html.slim +1 -0
- data/spec/test-data/handlers/slim-page.xml.slim +1 -0
- data/spec/test-data/handlers/slim-with-markdown-page.html.slim +5 -0
- data/spec/test-data/handlers/slim-with-utf.html.slim +2 -0
- data/spec/test-data/handlers/slim-with-variables.html.slim +1 -0
- data/spec/test-data/handlers/textile-page.textile +1 -0
- data/spec/test-data/images/logo.png +0 -0
- data/spec/test-data/index.html +242 -0
- data/spec/test-data/javascript/bootstrap-dropdown.js +92 -0
- data/spec/test-data/out-of-site/page-three.html.haml +2 -0
- data/spec/test-data/page-loader/_layouts/layout-one.md +2 -0
- data/spec/test-data/page-loader/_layouts/layout-two.html.haml +2 -0
- data/spec/test-data/page-loader/page-draft.md +5 -0
- data/spec/test-data/page-loader/page-one.md +2 -0
- data/spec/test-data/page-loader/page-two.html.haml +2 -0
- data/spec/test-data/simple-data.yaml +1 -0
- data/spec/test-data/simple-file.txt +1 -0
- data/spec/test-data/stylesheets/screen.css +688 -0
- data/spec/textile_handler_spec.rb +22 -0
- data/spec/tilt_handler_spec.rb +81 -0
- data/spec/yaml_handler_spec.rb +21 -0
- metadata +243 -202
- data/lib/awestruct/handlers/asciidoc_handler.rb +0 -86
- data/lib/awestruct/handlers/base_sass_handler.rb +0 -42
- data/lib/awestruct/handlers/coffeescript_handler.rb +0 -48
- data/lib/awestruct/handlers/erb_handler.rb +0 -43
- data/lib/awestruct/handlers/haml_handler.rb +0 -54
- data/lib/awestruct/handlers/less_handler.rb +0 -37
- data/lib/awestruct/handlers/markdown_handler.rb +0 -50
- data/lib/awestruct/handlers/mustache_handler.rb +0 -44
- data/lib/awestruct/handlers/orgmode_handler.rb +0 -48
- data/lib/awestruct/handlers/sass_handler.rb +0 -21
- data/lib/awestruct/handlers/scss_handler.rb +0 -21
- data/lib/awestruct/handlers/textile_handler.rb +0 -58
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'awestruct/engine'
|
2
|
+
require 'awestruct/site'
|
3
|
+
require 'awestruct/page_loader'
|
4
|
+
require 'awestruct/config'
|
5
|
+
|
6
|
+
describe Awestruct::PageLoader do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@config = Awestruct::Config.new( File.dirname(__FILE__) + "/test-data/page-loader" )
|
10
|
+
@engine = Awestruct::Engine.new
|
11
|
+
@engine.pipeline.handler_chains << :defaults
|
12
|
+
@site = Awestruct::Site.new( @engine, @config )
|
13
|
+
@loader = Awestruct::PageLoader.new( @site, :pages )
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to load a site page" do
|
17
|
+
page = @loader.load_page( File.join( @config.dir, "page-one.md" ) )
|
18
|
+
page.should_not be_nil
|
19
|
+
page.handler.to_chain.collect{|e| e.class}.should be_include Awestruct::Handlers::TiltHandler
|
20
|
+
page.relative_source_path.to_s.should == "/page-one.md"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be able to load an out-of-site page" do
|
24
|
+
page = @loader.load_page( File.join( @config.dir, '../out-of-site', "page-three.html.haml" ) )
|
25
|
+
page.should_not be_nil
|
26
|
+
page.handler.to_chain.collect{|e| e.class }.should be_include Awestruct::Handlers::TiltHandler
|
27
|
+
page.relative_source_path.should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to load all non-draft site pages" do
|
31
|
+
@loader.load_all
|
32
|
+
@site.pages.size.should == 2
|
33
|
+
|
34
|
+
@site.pages.sort!{|l,r| l.relative_source_path <=> r.relative_source_path }
|
35
|
+
|
36
|
+
@site.pages[0].relative_source_path.should == '/page-one.md'
|
37
|
+
@site.pages[0].output_path.should == '/page-one.html'
|
38
|
+
|
39
|
+
@site.pages[1].relative_source_path.should == '/page-two.html.haml'
|
40
|
+
@site.pages[1].output_path.should == '/page-two.html'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'awestruct/engine'
|
2
|
+
require 'awestruct/site'
|
3
|
+
require 'awestruct/page_loader'
|
4
|
+
require 'awestruct/config'
|
5
|
+
|
6
|
+
describe Awestruct::PageLoader do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@config = Awestruct::Config.new( File.dirname(__FILE__) + "/test-data/page-loader" )
|
10
|
+
@engine = Awestruct::Engine.new
|
11
|
+
@engine.pipeline.handler_chains << :defaults
|
12
|
+
@site = Awestruct::Site.new( @engine, @config )
|
13
|
+
@loader = Awestruct::PageLoader.new( @site, :layouts )
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to load a site layout" do
|
17
|
+
page = @loader.load_page( File.join( @config.dir, "_layouts", "layout-one.md" ) )
|
18
|
+
page.should_not be_nil
|
19
|
+
page.handler.to_chain.collect{|e| e.class}.should be_include Awestruct::Handlers::TiltHandler
|
20
|
+
page.relative_source_path.to_s.should == "/_layouts/layout-one.md"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be able to load all site layouts" do
|
24
|
+
@loader.load_all
|
25
|
+
@site.layouts.size.should == 2
|
26
|
+
|
27
|
+
@site.layouts.sort!{|l,r| l.relative_source_path <=> r.relative_source_path }
|
28
|
+
|
29
|
+
@site.layouts[0].relative_source_path.should == '/_layouts/layout-one.md'
|
30
|
+
@site.layouts[0].output_path.should == '/_layouts/layout-one.html'
|
31
|
+
|
32
|
+
@site.layouts[1].relative_source_path.should == '/_layouts/layout-two.html.haml'
|
33
|
+
@site.layouts[1].output_path.should == '/_layouts/layout-two.html'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/spec/page_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
require 'awestruct/page'
|
5
|
+
require 'awestruct/pipeline'
|
6
|
+
require 'awestruct/handlers/file_handler'
|
7
|
+
|
8
|
+
describe Awestruct::Handlers::FileHandler do
|
9
|
+
|
10
|
+
class TestTransformer
|
11
|
+
def transform(site, page, rendered)
|
12
|
+
rendered.gsub( /howdy/, 'adios' )
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before :all do
|
17
|
+
@site = OpenCascade.new :encoding=>false
|
18
|
+
@site.engine = OpenCascade.new
|
19
|
+
end
|
20
|
+
|
21
|
+
before :each do
|
22
|
+
@filename = Pathname.new( File.dirname(__FILE__) + "/test-data/simple-file.txt" )
|
23
|
+
@handler = Awestruct::Handlers::FileHandler.new( @site, @filename )
|
24
|
+
@page = Awestruct::Page.new( @site, @handler )
|
25
|
+
@site.engine.pipeline = Awestruct::Pipeline.new
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be stale before being read" do
|
29
|
+
@page.should be_stale
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not be stale after being read" do
|
33
|
+
@page.raw_content.strip.should == 'howdy'
|
34
|
+
@page.should_not be_stale
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be stale if touched after being read" do
|
38
|
+
@page.raw_content.strip.should == 'howdy'
|
39
|
+
@page.should_not be_stale
|
40
|
+
sleep(1)
|
41
|
+
FileUtils.touch( @filename )
|
42
|
+
@page.should be_stale
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be able to create an appropriate context" do
|
46
|
+
context = @page.create_context
|
47
|
+
context.site.should == @site
|
48
|
+
context.page.should == @page
|
49
|
+
context.content.should == ''
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should allow relative_source_path to be assignable" do
|
53
|
+
@page.relative_source_path.should be_nil
|
54
|
+
@page.relative_source_path = '/taco'
|
55
|
+
@page.relative_source_path.should == '/taco'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not apply transformers, even if present" do
|
59
|
+
@site.engine.pipeline.transformer TestTransformer.new
|
60
|
+
@page.rendered_content.strip.should == 'howdy'
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'awestruct/extensions/posts'
|
2
|
+
require 'awestruct/util/inflector'
|
3
|
+
require 'hashery/open_cascade'
|
4
|
+
|
5
|
+
describe Awestruct::Extensions::Posts do
|
6
|
+
|
7
|
+
it "should have an empty string as the default path prefix" do
|
8
|
+
extension = Awestruct::Extensions::Posts.new
|
9
|
+
extension.path_prefix.should == ''
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have :posts as the default assign_to" do
|
13
|
+
extension = Awestruct::Extensions::Posts.new('/posts')
|
14
|
+
extension.assign_to.should == :posts
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have a nil archive template by default" do
|
18
|
+
extension = Awestruct::Extensions::Posts.new('/posts', :posts)
|
19
|
+
extension.archive_template.should be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a nil archive template by default" do
|
23
|
+
extension = Awestruct::Extensions::Posts.new('/posts', :posts)
|
24
|
+
extension.archive_path.should be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should accept a path prefix parameter" do
|
28
|
+
extension = Awestruct::Extensions::Posts.new( '/posts' )
|
29
|
+
extension.path_prefix.should == '/posts'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should accept a method assignment name parameter" do
|
33
|
+
extension = Awestruct::Extensions::Posts.new( '/posts', :news )
|
34
|
+
extension.assign_to.should == :news
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should accept an archive path prefix" do
|
38
|
+
extension = Awestruct::Extensions::Posts.new( '/posts', :news, '/archive/index', '/archive' )
|
39
|
+
extension.archive_path.should == '/archive'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should accept an archive template file path parameter" do
|
43
|
+
extension = Awestruct::Extensions::Posts.new( '/posts', :news, '/archive/index' )
|
44
|
+
extension.archive_template.should == '/archive/index'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should accept a default layout for post pages" do
|
48
|
+
extension = Awestruct::Extensions::Posts.new( '/posts', :news, nil, nil, :default_layout => 'post' )
|
49
|
+
extension.archive_path.should be_nil
|
50
|
+
extension.archive_template.should be_nil
|
51
|
+
extension.default_layout.should == 'post'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should assign default layout if specified to post without layout" do
|
55
|
+
extension = Awestruct::Extensions::Posts.new( '/posts', :news, nil, nil, :default_layout => 'post' )
|
56
|
+
site = OpenCascade.new :encoding=>false
|
57
|
+
page = __create_page( 2012, 8, 9, '/posts/mock-post.md' )
|
58
|
+
page.stub(:layout).and_return(nil)
|
59
|
+
page.should_receive(:layout=).with('post')
|
60
|
+
page.stub(:slug).and_return(nil, 'mock-post')
|
61
|
+
page.should_receive(:slug=).with('mock-post')
|
62
|
+
page.should_receive(:output_path=).with('/posts/2012/08/09/mock-post.html')
|
63
|
+
|
64
|
+
site.pages = [page]
|
65
|
+
extension.execute(site)
|
66
|
+
site.news.size.should == 1
|
67
|
+
site.news.first.should == page
|
68
|
+
end
|
69
|
+
|
70
|
+
describe Awestruct::Extensions::Posts::Archive do
|
71
|
+
|
72
|
+
before :each do
|
73
|
+
@archive = Awestruct::Extensions::Posts::Archive.new
|
74
|
+
@page = __create_page( 2012, 8, 9 )
|
75
|
+
@archive << @page
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should store pages by year, month, and day" do
|
79
|
+
@archive.posts[2012].should_not be_nil
|
80
|
+
@archive.posts[2012][8][9][0].should == @page
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should use the provided template when generating the archive" do
|
84
|
+
engine = mock("Engine")
|
85
|
+
template = mock("Template")
|
86
|
+
template.should_receive( :archive= ).with( @archive.posts[2012][8][9] )
|
87
|
+
template.should_receive( :output_path= ).with( '/archive/2012/8/9/index.html' )
|
88
|
+
engine.should_receive( :find_and_load_site_page ).with( '/archive/index' ).and_return( template )
|
89
|
+
@archive.generate_pages( engine, '/archive/index', '/archive' )
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def __create_page(year, month, day, path = nil)
|
95
|
+
page = mock( "Page for #{year}-#{month}-#{day}" )
|
96
|
+
page.stub(:date?).and_return( true )
|
97
|
+
page.stub(:date=).with(anything())
|
98
|
+
page.stub_chain(:date, :year).and_return( year )
|
99
|
+
page.stub_chain(:date, :month).and_return( month )
|
100
|
+
page.stub_chain(:date, :day).and_return( day )
|
101
|
+
page.stub(:relative_source_path).and_return( path ) if path
|
102
|
+
page.stub(:create_context)
|
103
|
+
page.stub(:sequence).and_return( nil )
|
104
|
+
page.stub(:source_path).and_return( '.' )
|
105
|
+
page
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
verify = lambda { |output|
|
4
|
+
output.should =~ %r(<head><meta http-equiv="location" content="URL=http://google.com" /></head>)
|
5
|
+
}
|
6
|
+
verify_with_interpol = lambda { |output|
|
7
|
+
output.should =~ %r(<head><meta http-equiv="location" content="URL=http://bacon.com" /></head>)
|
8
|
+
}
|
9
|
+
|
10
|
+
theories =
|
11
|
+
[
|
12
|
+
{
|
13
|
+
:page => "simple-redirect-page.redirect",
|
14
|
+
:simple_name => "simple-redirect-page",
|
15
|
+
:syntax => :text,
|
16
|
+
:extension => '.html',
|
17
|
+
:matcher => verify
|
18
|
+
},
|
19
|
+
{
|
20
|
+
:page => "redirect-page.redirect",
|
21
|
+
:simple_name => "redirect-page",
|
22
|
+
:syntax => :text,
|
23
|
+
:extension => '.html',
|
24
|
+
:matcher => verify_with_interpol
|
25
|
+
}
|
26
|
+
]
|
27
|
+
|
28
|
+
describe Awestruct::Handlers::TiltHandler.to_s + "-Redirect" do
|
29
|
+
let(:additional_config) { {:interpolate => true, :crunchy => "bacon"} }
|
30
|
+
it_should_behave_like "a handler", theories
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
verify = lambda { |output|
|
4
|
+
#output.should == "<h3>Test</h3>" ? unknown
|
5
|
+
}
|
6
|
+
|
7
|
+
theories =
|
8
|
+
[
|
9
|
+
{
|
10
|
+
:page => "restructuredtext-page.rst",
|
11
|
+
:simple_name => "restructuredtext-page",
|
12
|
+
:syntax => :rst,
|
13
|
+
:extension => '.html'
|
14
|
+
#:matcher => verify ? requires rst2html command line tool
|
15
|
+
}
|
16
|
+
]
|
17
|
+
|
18
|
+
describe Awestruct::Handlers::TiltHandler.to_s + "-reStructuredText" do
|
19
|
+
|
20
|
+
it_should_behave_like "a handler", theories
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
verify = lambda { |output|
|
4
|
+
output.should =~ /#test \{/
|
5
|
+
output.should =~ /background-color: #ce4dd6; \}/
|
6
|
+
}
|
7
|
+
|
8
|
+
theories =
|
9
|
+
[
|
10
|
+
{
|
11
|
+
:page => "sass-page.sass",
|
12
|
+
:simple_name => "sass-page",
|
13
|
+
:syntax => :sass,
|
14
|
+
:extension => '.css',
|
15
|
+
:matcher => verify
|
16
|
+
}
|
17
|
+
]
|
18
|
+
|
19
|
+
describe Awestruct::Handlers::TiltHandler.to_s + "-Sass" do
|
20
|
+
|
21
|
+
it_should_behave_like "a handler", theories
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
verify = lambda { |output|
|
4
|
+
output.should =~ /#test \{/
|
5
|
+
output.should =~ /background-color: #ce4dd6; \}/
|
6
|
+
}
|
7
|
+
|
8
|
+
theories =
|
9
|
+
[
|
10
|
+
{
|
11
|
+
:page => "scss-page.scss",
|
12
|
+
:simple_name => "scss-page",
|
13
|
+
:syntax => :scss,
|
14
|
+
:extension => '.css',
|
15
|
+
:matcher => verify
|
16
|
+
}
|
17
|
+
]
|
18
|
+
|
19
|
+
describe Awestruct::Handlers::TiltHandler.to_s + "-Scss" do
|
20
|
+
|
21
|
+
it_should_behave_like "a handler", theories
|
22
|
+
|
23
|
+
end
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'awestruct/rack/app'
|
2
|
+
require 'rack/test'
|
3
|
+
|
4
|
+
describe Awestruct::Rack::App do
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
def app
|
8
|
+
Awestruct::Rack::App.new(Pathname.new( File.dirname(__FILE__) + '/test-data'))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "HTML media type" do
|
12
|
+
it "should return text/html" do
|
13
|
+
get('/index.html')
|
14
|
+
last_response.headers['Content-Type'].should == 'text/html'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "CSS media type" do
|
19
|
+
it "should return text/css" do
|
20
|
+
get('/stylesheets/screen.css')
|
21
|
+
last_response.headers['Content-Type'].should == 'text/css'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "PNG media type" do
|
26
|
+
it "should return image/png" do
|
27
|
+
get('/images/logo.png')
|
28
|
+
last_response.headers['Content-Type'].should == 'image/png'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "JavaScript media type" do
|
33
|
+
it "should return application/javascript" do
|
34
|
+
get('/javascript/bootstrap-dropdown.js')
|
35
|
+
last_response.headers['Content-Type'].should == 'application/javascript'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "File not found" do
|
40
|
+
it "should return a 404 status code" do
|
41
|
+
get('/b-is-for-beer.html')
|
42
|
+
last_response.status.should == 404
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
verify = lambda { |output|
|
5
|
+
output.should =~ %r(<h1>This is a Slim page</h1>)
|
6
|
+
}
|
7
|
+
|
8
|
+
verify_atom = lambda { |output|
|
9
|
+
output.should == '<?xml version="1.0" encoding="utf-8" ?><feed xmlns="http://www.w3.org/2005/Atom"><id>http://example.com</id><title>A News Feed</title></feed>'
|
10
|
+
}
|
11
|
+
|
12
|
+
verify_with_markdown = lambda { |output|
|
13
|
+
output.should =~ %r(<h1[^>]*>Hello From Markdown</h1>)
|
14
|
+
}
|
15
|
+
|
16
|
+
verify_with_textile = lambda { |output|
|
17
|
+
output.should =~ %r(<h1>Hello From Textile</h1>)
|
18
|
+
}
|
19
|
+
|
20
|
+
verify_with_utf8 = lambda { |output|
|
21
|
+
output.should =~ %r(<h1>Besøg fra Danmark</h1>)
|
22
|
+
}
|
23
|
+
|
24
|
+
verify_with_variables = lambda { |output|
|
25
|
+
output.should =~ %r(<h1>bacon</h1>)
|
26
|
+
}
|
27
|
+
|
28
|
+
theories =
|
29
|
+
[
|
30
|
+
{
|
31
|
+
:page => 'slim-page.html.slim',
|
32
|
+
:simple_name => 'slim-page',
|
33
|
+
:syntax => :slim,
|
34
|
+
:extension => '.html',
|
35
|
+
:format => :html5,
|
36
|
+
:matcher => verify
|
37
|
+
},
|
38
|
+
{
|
39
|
+
:page => 'slim-page.xml.slim',
|
40
|
+
:simple_name => 'slim-page',
|
41
|
+
:syntax => :slim,
|
42
|
+
:extension => '.xml',
|
43
|
+
:format => :xhtml,
|
44
|
+
:matcher => verify
|
45
|
+
},
|
46
|
+
{
|
47
|
+
:page => 'slim-page.atom.slim',
|
48
|
+
:simple_name => 'slim-page',
|
49
|
+
:syntax => :slim,
|
50
|
+
:extension => '.atom',
|
51
|
+
:format => :xhtml,
|
52
|
+
:matcher => verify_atom
|
53
|
+
},
|
54
|
+
{
|
55
|
+
:page => 'slim-with-markdown-page.html.slim',
|
56
|
+
:simple_name => 'slim-with-markdown-page',
|
57
|
+
:syntax => :slim,
|
58
|
+
:extension => '.html',
|
59
|
+
:matcher => verify_with_markdown
|
60
|
+
},
|
61
|
+
{
|
62
|
+
:page => 'slim-with-utf.html.slim',
|
63
|
+
:simple_name => 'slim-with-utf',
|
64
|
+
:syntax => :slim,
|
65
|
+
:extension => '.html',
|
66
|
+
:matcher => verify_with_utf8
|
67
|
+
},
|
68
|
+
{
|
69
|
+
:page => 'slim-with-variables.html.slim',
|
70
|
+
:simple_name => 'slim-with-variables',
|
71
|
+
:syntax => :slim,
|
72
|
+
:extension => '.html',
|
73
|
+
:matcher => verify_with_variables
|
74
|
+
}
|
75
|
+
]
|
76
|
+
|
77
|
+
describe Awestruct::Handlers::TiltHandler.to_s + '-Slim' do
|
78
|
+
let(:additional_config) { {:crunchy => 'bacon'} }
|
79
|
+
it_should_behave_like 'a handler', theories
|
80
|
+
|
81
|
+
end
|