Skip to content

Commit

Permalink
Add no_span_caps option for Textile to default-site.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Sep 8, 2013
1 parent 266b4f8 commit d0e5d95
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/awestruct/config/default-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ asciidoctor:
:attributes:
imagesdir: /images
stylesdir: /stylesheets

textile:
:no_span_caps: true
7 changes: 6 additions & 1 deletion spec/support/shared_handler_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'hashery'

REQUIRED_VARIABLES = [:page, :simple_name, :syntax, :extension]
ALL_VARIABLES = REQUIRED_VARIABLES + [:format, :matcher, :unless]
ALL_VARIABLES = REQUIRED_VARIABLES + [:format, :matcher, :unless, :additional_config]

shared_examples 'a handler' do |theories|

Expand Down Expand Up @@ -37,6 +37,10 @@ def create_handler(page)
@engine.load_page File.join(@engine.config.dir, page)
end

def merge_additional_config(theory)
@site.merge! theory[:additional_config] if theory[:additional_config]
end

theories.each do |theory|

# Validate input
Expand Down Expand Up @@ -82,6 +86,7 @@ def create_handler(page)

it "should render page '#{theory[:page]}'" do
if theory[:unless].nil? or !theory[:unless][:exp].call()
merge_additional_config(theory)
handler = create_handler theory[:page]
handler.update(additional_config_page) { |k, oldval, newval| oldval } if respond_to?('additional_config_page')
output = handler.rendered_content(handler.create_context)
Expand Down
4 changes: 3 additions & 1 deletion spec/test-data/handlers/textile-page.textile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
h3. Test
h3. Test

the WHO
21 changes: 16 additions & 5 deletions spec/textile_handler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'spec_helper'

verify = lambda { |output|
output.should == "<h3>Test</h3>"
verify_without_span = lambda { |output|
output.should == "<h3>Test</h3>\n<p>the WHO</p>"
}

verify_with_span = lambda { |output|
output.should == "<h3>Test</h3>\n<p>the <span class=\"caps\">WHO</span></p>"
}

theories =
Expand All @@ -11,12 +15,19 @@
:simple_name => "textile-page",
:syntax => :textile,
:extension => '.html',
:matcher => verify
:matcher => verify_with_span,
:additional_config => { :textile => { ':no_span_caps' => false } }
},
{
:page => "textile-page.textile",
:simple_name => "textile-page",
:syntax => :textile,
:extension => '.html',
:matcher => verify_without_span
}
]

describe Awestruct::Handlers::TiltHandler.to_s + "-Textile" do

it_should_behave_like "a handler", theories

end
end

0 comments on commit d0e5d95

Please sign in to comment.