tests/staticpress/content/base_test.rb in staticpress-0.5.0 vs tests/staticpress/content/base_test.rb in staticpress-0.5.1
- old
+ new
@@ -14,10 +14,12 @@
let(:category_2) { Staticpress::Content::Category.new(:name => 'programming', :number => '2') }
let(:index) { Staticpress::Content::Index.new }
let(:index_2) { Staticpress::Content::Index.new :number => 2 }
+ let(:chained) { Staticpress::Content::Page.new(:slug => 'chained') }
+ let(:chain) { Staticpress::Content::Page.new(:slug => 'chain.html') }
let(:page) { Staticpress::Content::Page.new(:slug => 'about') }
let(:second_page) { Staticpress::Content::Page.new :slug => 'contact' }
let(:page_root) { Staticpress::Content::Page.new :slug => '' }
let(:style_2) { Staticpress::Content::Page.new :slug => 'style2.css' }
let(:page_nested) { Staticpress::Content::Page.new :slug => 'foo/bar/baz' }
@@ -59,20 +61,23 @@
refute_operator Staticpress::Content::Category.new(:name => 'programming'), :==, Staticpress::Content::Tag.new(:name => 'programming')
refute_operator Staticpress::Content::Tag.new(:name => 'charlotte'), :==, Staticpress::Content::Category.new(:name => 'charlotte')
end
def test_content_type
+ assert_equal 'text/html', chained.content_type
assert_equal 'text/html', page.content_type
assert_equal 'text/css', style_2.content_type
assert_equal 'image/png', static_bin.content_type
assert_equal 'text/plain', static_txt.content_type
end
def test_exist?
assert category.exist?, "#{category} does not exist"
assert index.exist?, "#{index} does not exist"
+ assert chained.exist?, "#{chained} does not exist"
+ assert chain.exist?, "#{chain} does not exist"
assert page.exist?, "#{page} does not exist"
assert second_page.exist?, "#{second_page} does not exist"
assert static_bin.exist?, "#{static_bin} does not exist"
assert static_txt.exist?, "#{static_txt} does not exist"
assert page_root.exist?, "#{page_root} does not exist"
@@ -89,10 +94,11 @@
def test_find_by_url_path
assert_equal category, Staticpress::Content::Category.find_by_url_path('/category/programming')
assert_equal index, Staticpress::Content::Index.find_by_url_path('/')
assert_equal page_root, Staticpress::Content::Page.find_by_url_path('/')
+ assert_equal chained, Staticpress::Content::Page.find_by_url_path('/chained')
assert_equal page, Staticpress::Content::Page.find_by_url_path('/about')
assert_equal static_bin, Staticpress::Content::Page.find_by_url_path('/ruby.png')
assert_equal post, Staticpress::Content::Post.find_by_url_path('/2011/07/20/hello')
assert_equal tag, Staticpress::Content::Tag.find_by_url_path('/tag/charlotte')
@@ -105,11 +111,21 @@
def test_full_title
assert_equal 'Foo -> Bar -> Baz | Test Blog', page_nested.full_title
end
+ def test_markup_template?
+ assert chained.markup_template?, "#{chained} is not markup"
+ assert chain.markup_template?, "#{chain} is not markup"
+ assert page.markup_template?, "#{page} is not markup"
+
+ refute style_2.markup_template?, "#{chained} is markup"
+ end
+
def test_output_path
+ assert_equal (Staticpress.blog_path + 'public' + 'chained' + 'index.html'), chained.output_path
+ assert_equal (Staticpress.blog_path + 'public' + 'chain.html'), chain.output_path
assert_equal (Staticpress.blog_path + 'public' + 'about' + 'index.html'), page.output_path
assert_equal (Staticpress.blog_path + 'public' + 'index.html'), page_root.output_path
assert_equal (Staticpress.blog_path + 'public' + 'style2.css'), style_2.output_path
assert_equal (Staticpress.blog_path + 'public' + 'ruby.png'), static_bin.output_path
assert_equal (Staticpress.blog_path + 'public' + 'plain.txt'), static_txt.output_path
@@ -122,15 +138,18 @@
expected = { :name => 'charlotte', :number => 1 }
assert_equal expected, tag.params
assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte', :number => nil).params
assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte', :number => 1).params
assert_equal expected, Staticpress::Content::Tag.new(:name => 'charlotte', :number => '1').params
+
+ assert_equal({ :slug => 'chain.html' }, Staticpress::Content::Page.new(:slug => 'chain.html').params)
end
def test_raw
assert_equal '= partial :list_posts, :posts => page.sub_content', category.raw
+ assert_equal "<%= 'Processed with ERB' %>, then Markdown.", chained.raw
assert_equal 'in page', page.raw
assert_equal "in page\n\nin page", second_page.raw
assert_equal 'this file intentionally left blank', static_txt.raw
assert_equal 'in post', post.raw
@@ -180,10 +199,11 @@
JS
assert_equal expected, asset_script.render
end
def test_render_partial
+ assert_equal "<p>Processed with ERB, then Markdown.</p>\n", chained.render_partial
assert_equal "<p>in page</p>\n", page.render_partial
assert_equal "<p>in page</p>\n\n<p>in page</p>\n", second_page.render_partial
expected_style2 = <<-CSS
body{color:green}
@@ -215,18 +235,20 @@
assert_equal static_txt.template_path.read, static_txt.output_path.read
end
def test_template_engine_options
expected = Compass.sass_engine_options.merge :line_comments => false, :style => :compressed
- assert_eql expected, asset_style.template_engine_options
- assert_equal({}, asset_script.template_engine_options)
+ assert_eql expected, asset_style.template_engine_options(:sass)
+ assert_equal({}, asset_script.template_engine_options(:js))
end
- def test_template_type
- assert_equal :markdown, page.template_type
- assert_equal :sass, asset_style.template_type
- assert_equal :js, asset_script.template_type
+ def test_template_types
+ assert_equal [:erb, :markdown], chained.template_types
+ assert_equal [:erb, :markdown], chain.template_types
+ assert_equal [:markdown], page.template_types
+ assert_equal [:sass], asset_style.template_types
+ assert_equal [], asset_script.template_types
end
def test_title
assert_equal 'Foo -> Bar -> Baz', page_nested.title
end
@@ -256,9 +278,11 @@
assert_equal '/', index.url_path
assert_equal '/page/2', index_2.url_path
assert_equal '/', page_root.url_path
+ assert_equal '/chained', chained.url_path
+ assert_equal '/chain.html', chain.url_path
assert_equal '/about', page.url_path
assert_equal '/contact', second_page.url_path
assert_equal '/ruby.png', static_bin.url_path
assert_equal '/plain.txt', static_txt.url_path