test/helpers/test_rendering.rb in nanoc-4.0.0b4 vs test/helpers/test_rendering.rb in nanoc-4.0.0rc1

- old
+ new

@@ -9,10 +9,12 @@ File.open('layouts/foo.erb', 'w') do |io| io.write 'This is the <%= @layout.identifier %> layout.' end + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) assert_equal('This is the /foo/ layout.', render('/foo/')) end @@ -26,10 +28,12 @@ File.open('layouts/foo.erb', 'w') do |io| io.write 'This is the <%= @layout.identifier %> layout.' end + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) assert_equal('This is the /foo/ layout.', render('/foo')) end @@ -43,19 +47,42 @@ File.open('layouts/foo.erb', 'w') do |io| io.write 'I am the <%= @layout.class %> class.' end + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) assert_equal('I am the Nanoc::LayoutView class.', render('/foo/')) end end + def test_render_wrapped_class + with_site do |site| + File.open('Rules', 'w') do |io| + io.write("layout '/foo/', :erb\n") + end + + File.open('layouts/foo.erb', 'w') do |io| + io.write 'I am the <%= @layout.unwrap.class %> class.' + end + + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load + @site = Nanoc::SiteView.new(site) + @layouts = Nanoc::LayoutCollectionView.new(site.layouts) + + assert_equal('I am the Nanoc::Int::Layout class.', render('/foo/')) + end + end + def test_render_with_unknown_layout with_site do |site| + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) assert_raises(Nanoc::Int::Errors::UnknownLayout) do render '/dsfghjkl/' @@ -69,10 +96,12 @@ io.write("layout '/foo/', nil\n") end File.open('layouts/foo.erb', 'w').close + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) assert_raises(Nanoc::Int::Errors::CannotDetermineFilter) do render '/foo/' @@ -86,10 +115,12 @@ io.write("layout '/foo/', :asdf\n") end File.open('layouts/foo.erb', 'w').close + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) assert_raises(Nanoc::Int::Errors::UnknownFilter) do render '/foo/' @@ -105,9 +136,11 @@ File.open('layouts/foo.erb', 'w') do |io| io.write '[partial-before]<%= yield %>[partial-after]' end + site = Nanoc::Int::SiteLoader.new.new_from_cwd + site.compiler.load @site = Nanoc::SiteView.new(site) @layouts = Nanoc::LayoutCollectionView.new(site.layouts) _erbout = '[erbout-before]' result = render '/foo/' do