Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactor specs, add specs for pipe and toc

  • Loading branch information...
commit ad2f02a6600fa276ce94a4e4a2f8cb513597fa25 1 parent e27f013
@zzak authored
View
1  spec/glorify/helper_with_pipe.erb
@@ -0,0 +1 @@
+<%= glorify(@some_code, :pipe => true) %>
View
1  spec/glorify/helper_with_toc.erb
@@ -0,0 +1 @@
+<%= glorify(@some_code, :toc => true) %>
View
2  spec/glorify/with_helper.erb
@@ -1 +1 @@
-<%= glorify(@some_code) %>
+<%= glorify(@some_code, :pipe => true) %>
View
55 spec/glorify_spec.rb
@@ -4,10 +4,9 @@
it "should parse a header" do
mock_app do
- Tilt.prefer Sinatra::Glorify::Template
get('/') { markdown :header }
end
- expected = "<h1 id=\"label-a+sip+of+glory\">a sip of glory<span><a href=\"#label-a+sip+of+glory\">&para;</a> <a href=\"#documentation\">&uarr;</a></span></h1>"
+ expected = '<h1 id="label-a+sip+of+glory">a sip of glory<span><a href="#label-a+sip+of+glory">&para;</a> <a href="#documentation">&uarr;</a></span></h1>'
get('/')
assert ok?
assert_equal expected, body
@@ -15,10 +14,9 @@
it "should parse code blocks" do
mock_app do
- Tilt.prefer Sinatra::Glorify::Template
get('/') { markdown :blocks }
end
- expected = "<pre class=\"highlight text\">&quot;Hello, world!&quot;</pre>"
+ expected = '<pre class="highlight text">&quot;Hello, world!&quot;</pre>'
get('/')
assert ok?
assert_equal expected, body
@@ -27,7 +25,6 @@
it "should parse ruby blocks" do
mock_app do
get('/') do
- Tilt.prefer Sinatra::Glorify::Template
markdown :ruby_blocks
end
end
@@ -51,6 +48,36 @@
refute_empty Nokogiri::HTML(body).search("pre.highlight")
end
+ it "should use helper with pipe" do
+ mock_app do
+ get('/') do
+ @some_code = File.open(
+ File.expand_path('../glorify/header.md', __FILE__),
+ "rb"
+ ).read
+ erb :helper_with_pipe
+ end
+ end
+ get('/')
+ assert ok?
+ assert_equal '<h1 id="label-a+sip+of+glory">a sip of glory</h1>', body
+ end
+
+ it "should use helper with toc" do
+ mock_app do
+ get('/') do
+ @some_code = File.open(
+ File.expand_path('../glorify/header.md', __FILE__),
+ "rb"
+ ).read
+ erb :helper_with_toc
+ end
+ end
+ get('/')
+ assert ok?
+ assert_equal "<li><a href='#label-a+sip+of+glory'>a sip of glory</a></li>", body
+ end
+
it "should include a valid css helper for pygments" do
mock_app
get('/pygments.css')
@@ -59,4 +86,22 @@
assert_match /text\/css/, content_type
assert_empty validate_css(body).errors
end
+
+ it "should render template with pipe" do
+ mock_app do
+ get('/') { markdown :header, :pipe => true }
+ end
+ get('/')
+ assert ok?
+ assert_equal '<h1 id="label-a+sip+of+glory">a sip of glory</h1>', body
+ end
+
+ it "should render template with toc" do
+ mock_app do
+ get('/') { markdown :header, :toc => true }
+ end
+ get('/')
+ assert ok?
+ assert_equal "<li><a href='#label-a+sip+of+glory'>a sip of glory</a></li>", body
+ end
end
View
5 spec/spec_helper.rb
@@ -19,7 +19,10 @@ class MiniTest::Spec
include W3CValidators
def mock_app(base=Sinatra::Base, &block)
- @app = Sinatra.new(base, &block)
+ @app = Sinatra.new(base) do
+ Tilt.prefer Sinatra::Glorify::Template
+ class_eval &block if block_given?
+ end
end
def app
Please sign in to comment.
Something went wrong with that request. Please try again.