Permalink
Browse files

specs fixed

  • Loading branch information...
1 parent b954234 commit be6d2176f3c508a36ecc70130bf137cba2423c8e Dirk Kelly committed Oct 20, 2010
View
@@ -0,0 +1,5 @@
+if ENV["RAILS_ENV"] == "test"
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ end
+end
@@ -0,0 +1,36 @@
+class LayoutsLayoutsDataset < Dataset::Base
+
+ def load
+ create_record :layout, :parent,
+ :name => 'parent',
+ :content_type => 'haml',
+ :content => <<-CONTENT
+!!! 5
+%html
+ %head
+ %title Title
+ :plain
+ <r:body class="site">
+ <r:content_for_layout />
+ </r:body>
+CONTENT
+
+ create_record :layout, :child,
+ :name => 'child',
+ :content => <<-CONTENT
+<r:inside_layout name='parent'>
+ <h1><r:layout /></h1>
+</r:inside_layout>
+CONTENT
+
+ create_record :layout, :haml,
+ :name => 'haml',
+ :content_type => 'haml',
+ :content => <<-CONTENT
+%r:inside_layout{:name=>"parent"}
+ %h1
+ %r:layout
+CONTENT
+ end
+
+end
@@ -0,0 +1,43 @@
+class LayoutsPagesDataset < Dataset::Base
+
+ uses :layouts_layouts
+
+ def load
+ create_record :page, :parent,
+ :title => 'Parent',
+ :layout_id => layouts(:parent).id,
+ :breadcrumb => 'parent',
+ :slug => '/',
+ :status_id => 100
+
+ create_record :page, :child,
+ :title => 'Child',
+ :layout_id => layouts(:child).id,
+ :parent_id => pages(:parent).id,
+ :breadcrumb => 'child',
+ :slug => '/child',
+ :status_id => 100
+
+ create_record :page, :rails,
+ :title => 'App page',
+ :breadcrumb => 'App page',
+ :slug => 'app',
+ :class_name => 'RailsPage',
+ :status_id => 100,
+ :parent_id => pages(:parent).id
+
+ create_record :page, :rails_child,
+ :title => 'Child',
+ :breadcrumb => 'Child',
+ :slug => 'child-page',
+ :status_id => 100,
+ :parent_id => pages(:rails).id
+
+ create_record :page, :other,
+ :title => 'Other',
+ :breadcrumb => 'Other',
+ :slug => 'other',
+ :status_id => 100,
+ :parent_id => pages(:parent).id
+ end
+end
@@ -1,38 +0,0 @@
-class NestedLayoutsDataset < Dataset::Base
- def load
- create_record :layout, :parent,
- :name => 'parent',
- :content => <<-CONTENT
-<html>
- <body class="<r:layout />">
- <r:content_for_layout />
- </body>
-</html>
-CONTENT
-
- create_record :layout, :child,
- :name => 'child',
- :content => <<-CONTENT
-<r:inside_layout name='parent'>
- <h1>child</h1>
-</r:inside_layout>
-CONTENT
-
- create_record :page, :parent_layout,
- :title => 'child layout',
- :layout_id => layouts(:parent).id,
- :breadcrumb => 'Homepage',
- :slug => '/',
- :status_id => 100,
- :published_at => '2008-01-01 08:00:00'
-
- create_record :page, :child_layout,
- :title => 'child layout',
- :layout_id => layouts(:child).id,
- :breadcrumb => 'Homepage',
- :slug => '/',
- :status_id => 100,
- :published_at => '2008-01-01 08:00:00'
-
- end
-end
@@ -1,38 +0,0 @@
-class ShareLayoutsDataset < Dataset::Base
- def load
- create_record :page, :homepage, :id => 1,
- :title => 'Homepage',
- :breadcrumb => 'Homepage',
- :slug => '/',
- :status_id => 100,
- :published_at => '2008-01-01 08:00:00'
-
- create_record :page, :rails_page,
- :id => 2,
- :title => 'App page',
- :breadcrumb => 'App page',
- :slug => 'app',
- :class_name => 'RailsPage',
- :status_id => 100,
- :parent_id => 1,
- :published_at => '2008-01-01 08:00:00'
-
- create_record :page, :rails_page_child,
- :id => 3,
- :title => 'Child',
- :breadcrumb => 'Child',
- :slug => 'child-page',
- :status_id => 100,
- :parent_id => 2,
- :published_at => '2008-01-01 08:00:00'
-
- create_record :page, :other,
- :id => 4,
- :title => 'Other',
- :breadcrumb => 'Other',
- :slug => 'other',
- :status_id => 100,
- :parent_id => 1,
- :published_at => '2008-01-01 08:00:00'
- end
-end
@@ -0,0 +1,36 @@
+require 'spec/spec_helper'
+
+describe HamlLayouts::Models::Layout do
+
+ dataset :layouts_layouts, :layouts_pages
+
+ describe 'content' do
+ context 'a haml layout' do
+ it 'should return html rendered' do
+ expected = <<-CONTENT
+<r:inside_layout name='parent'>
+ <h1>
+ <r:layout></r:layout>
+ </h1>
+</r:inside_layout>
+CONTENT
+ layouts(:haml).content.should === expected
+ end
+ end
+ end
+
+ describe 'is_haml?' do
+ context 'layout has a content type of haml' do
+ it 'should return true' do
+ layouts(:haml).is_haml?.should be_true
+ end
+ end
+
+ context 'layout does not have a content type of haml' do
+ it 'should return false' do
+ layouts(:child).is_haml?.should be_false
+ end
+ end
+ end
+
+end
@@ -0,0 +1,40 @@
+require 'spec/spec_helper'
+
+describe HamlLayouts::Models::Page do
+
+ dataset :layouts_layouts, :layouts_pages
+
+ describe 'parse_object' do
+ context 'haml filter type' do
+ it 'should render haml radius tags' do
+ @part = PagePart.new({
+ :content => '%r:title',
+ :filter_id => 'Haml'
+ })
+ @page = pages(:parent)
+
+ @page.parse_object(@part).should === "#{@page.title}\n"
+ end
+
+ it 'should render textile radius tags' do
+ @part = PagePart.new({
+ :content => 'h1. <r:title />',
+ :filter_id => 'Textile'
+ })
+ @page = pages(:parent)
+
+ @page.parse_object(@part).should === "<h1>#{@page.title}</h1>"
+ end
+
+ it 'should render non filtered tags' do
+ @part = PagePart.new({
+ :content => '<r:title />'
+ })
+ @page = pages(:parent)
+
+ @page.parse_object(@part).should === @page.title
+ end
+ end
+ end
+
+end
@@ -1,33 +1,41 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require 'spec/spec_helper'
-describe NestedLayouts::Tags do
- dataset :pages
- dataset :nested_layouts
+describe NestedLayouts::Tags::Core do
- describe '<r:inside_layout>, <r:layout> and <r:content_for_layout>' do
+ dataset :layouts_pages, :layouts_layouts
+
+ describe '<r:inside_layout>, <r:layout>, <r:body /> and <r:content_for_layout>' do
it 'should output tag within the body of class name for parent layout' do
tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
expected = <<-CONTENT
+<!DOCTYPE html>
<html>
- <body class="parent">
+ <head>
+ <title>Title</title>
+ </head>
+ <body class="site parent">
<h1>Hi</h1>
</body>
</html>
CONTENT
- pages(:parent_layout).should render(tag).as(expected)
+ pages(:parent).should render(tag).as(expected)
end
it 'should output tag within the body of class name for a child_layout' do
tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
expected = <<-CONTENT
+<!DOCTYPE html>
<html>
- <body class="child">
+ <head>
+ <title>Title</title>
+ </head>
+ <body class="site child">
<h1>Hi</h1>
</body>
</html>
CONTENT
- pages(:child_layout).should render(tag).as(expected)
+ pages(:child).should render(tag).as(expected)
end
end
@@ -37,25 +45,33 @@
it 'it should render the contents if true' do
tag = %{<r:inside_layout name='parent'><r:if_layout name='parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
expected = <<-CONTENT
+<!DOCTYPE html>
<html>
- <body class="parent">
+ <head>
+ <title>Title</title>
+ </head>
+ <body class="site parent">
<h1>Hi</h1>
</body>
</html>
CONTENT
- pages(:parent_layout).should render(tag).as(expected)
+ pages(:parent).should render(tag).as(expected)
end
it 'it should not render the contents if false' do
tag = %{<r:inside_layout name='parent'><r:if_layout name='not parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
expected = <<-CONTENT
+<!DOCTYPE html>
<html>
- <body class="parent">
+ <head>
+ <title>Title</title>
+ </head>
+ <body class="site parent">
</body>
</html>
CONTENT
- pages(:parent_layout).should render(tag).as(expected)
+ pages(:parent).should render(tag).as(expected)
end
end
@@ -65,25 +81,33 @@
it 'it should not render the contents if true' do
tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
expected = <<-CONTENT
+<!DOCTYPE html>
<html>
- <body class="parent">
+ <head>
+ <title>Title</title>
+ </head>
+ <body class="site parent">
</body>
</html>
CONTENT
- pages(:parent_layout).should render(tag).as(expected)
+ pages(:parent).should render(tag).as(expected)
end
it 'it should not render the contents if false' do
tag = %{<r:inside_layout name='parent'><r:unless_layout name='not parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
expected = <<-CONTENT
+<!DOCTYPE html>
<html>
- <body class="parent">
+ <head>
+ <title>Title</title>
+ </head>
+ <body class="site parent">
<h1>Hi</h1>
</body>
</html>
CONTENT
- pages(:parent_layout).should render(tag).as(expected)
+ pages(:parent).should render(tag).as(expected)
end
end
@@ -0,0 +1,5 @@
+require 'spec/spec_helper'
+
+describe ShareLayouts::Controllers::ActionController do
+
+end
Oops, something went wrong.

0 comments on commit be6d217

Please sign in to comment.