Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

specs fixed

  • Loading branch information...
commit be6d2176f3c508a36ecc70130bf137cba2423c8e 1 parent b954234
Dirk Kelly authored
5 config/routes.rb
... ... @@ -0,0 +1,5 @@
  1 +if ENV["RAILS_ENV"] == "test"
  2 + ActionController::Routing::Routes.draw do |map|
  3 + map.connect ':controller/:action/:id'
  4 + end
  5 +end
36 spec/datasets/layouts_layouts.rb
... ... @@ -0,0 +1,36 @@
  1 +class LayoutsLayoutsDataset < Dataset::Base
  2 +
  3 + def load
  4 + create_record :layout, :parent,
  5 + :name => 'parent',
  6 + :content_type => 'haml',
  7 + :content => <<-CONTENT
  8 +!!! 5
  9 +%html
  10 + %head
  11 + %title Title
  12 + :plain
  13 + <r:body class="site">
  14 + <r:content_for_layout />
  15 + </r:body>
  16 +CONTENT
  17 +
  18 + create_record :layout, :child,
  19 + :name => 'child',
  20 + :content => <<-CONTENT
  21 +<r:inside_layout name='parent'>
  22 + <h1><r:layout /></h1>
  23 +</r:inside_layout>
  24 +CONTENT
  25 +
  26 + create_record :layout, :haml,
  27 + :name => 'haml',
  28 + :content_type => 'haml',
  29 + :content => <<-CONTENT
  30 +%r:inside_layout{:name=>"parent"}
  31 + %h1
  32 + %r:layout
  33 +CONTENT
  34 + end
  35 +
  36 +end
43 spec/datasets/layouts_pages.rb
... ... @@ -0,0 +1,43 @@
  1 +class LayoutsPagesDataset < Dataset::Base
  2 +
  3 + uses :layouts_layouts
  4 +
  5 + def load
  6 + create_record :page, :parent,
  7 + :title => 'Parent',
  8 + :layout_id => layouts(:parent).id,
  9 + :breadcrumb => 'parent',
  10 + :slug => '/',
  11 + :status_id => 100
  12 +
  13 + create_record :page, :child,
  14 + :title => 'Child',
  15 + :layout_id => layouts(:child).id,
  16 + :parent_id => pages(:parent).id,
  17 + :breadcrumb => 'child',
  18 + :slug => '/child',
  19 + :status_id => 100
  20 +
  21 + create_record :page, :rails,
  22 + :title => 'App page',
  23 + :breadcrumb => 'App page',
  24 + :slug => 'app',
  25 + :class_name => 'RailsPage',
  26 + :status_id => 100,
  27 + :parent_id => pages(:parent).id
  28 +
  29 + create_record :page, :rails_child,
  30 + :title => 'Child',
  31 + :breadcrumb => 'Child',
  32 + :slug => 'child-page',
  33 + :status_id => 100,
  34 + :parent_id => pages(:rails).id
  35 +
  36 + create_record :page, :other,
  37 + :title => 'Other',
  38 + :breadcrumb => 'Other',
  39 + :slug => 'other',
  40 + :status_id => 100,
  41 + :parent_id => pages(:parent).id
  42 + end
  43 +end
38 spec/datasets/nested_layouts_dataset.rb
... ... @@ -1,38 +0,0 @@
1   -class NestedLayoutsDataset < Dataset::Base
2   - def load
3   - create_record :layout, :parent,
4   - :name => 'parent',
5   - :content => <<-CONTENT
6   -<html>
7   - <body class="<r:layout />">
8   - <r:content_for_layout />
9   - </body>
10   -</html>
11   -CONTENT
12   -
13   - create_record :layout, :child,
14   - :name => 'child',
15   - :content => <<-CONTENT
16   -<r:inside_layout name='parent'>
17   - <h1>child</h1>
18   -</r:inside_layout>
19   -CONTENT
20   -
21   - create_record :page, :parent_layout,
22   - :title => 'child layout',
23   - :layout_id => layouts(:parent).id,
24   - :breadcrumb => 'Homepage',
25   - :slug => '/',
26   - :status_id => 100,
27   - :published_at => '2008-01-01 08:00:00'
28   -
29   - create_record :page, :child_layout,
30   - :title => 'child layout',
31   - :layout_id => layouts(:child).id,
32   - :breadcrumb => 'Homepage',
33   - :slug => '/',
34   - :status_id => 100,
35   - :published_at => '2008-01-01 08:00:00'
36   -
37   - end
38   -end
38 spec/datasets/share_layouts_dataset.rb
... ... @@ -1,38 +0,0 @@
1   -class ShareLayoutsDataset < Dataset::Base
2   - def load
3   - create_record :page, :homepage, :id => 1,
4   - :title => 'Homepage',
5   - :breadcrumb => 'Homepage',
6   - :slug => '/',
7   - :status_id => 100,
8   - :published_at => '2008-01-01 08:00:00'
9   -
10   - create_record :page, :rails_page,
11   - :id => 2,
12   - :title => 'App page',
13   - :breadcrumb => 'App page',
14   - :slug => 'app',
15   - :class_name => 'RailsPage',
16   - :status_id => 100,
17   - :parent_id => 1,
18   - :published_at => '2008-01-01 08:00:00'
19   -
20   - create_record :page, :rails_page_child,
21   - :id => 3,
22   - :title => 'Child',
23   - :breadcrumb => 'Child',
24   - :slug => 'child-page',
25   - :status_id => 100,
26   - :parent_id => 2,
27   - :published_at => '2008-01-01 08:00:00'
28   -
29   - create_record :page, :other,
30   - :id => 4,
31   - :title => 'Other',
32   - :breadcrumb => 'Other',
33   - :slug => 'other',
34   - :status_id => 100,
35   - :parent_id => 1,
36   - :published_at => '2008-01-01 08:00:00'
37   - end
38   -end
36 spec/lib/haml_layouts/models/layout_spec.rb
... ... @@ -0,0 +1,36 @@
  1 +require 'spec/spec_helper'
  2 +
  3 +describe HamlLayouts::Models::Layout do
  4 +
  5 + dataset :layouts_layouts, :layouts_pages
  6 +
  7 + describe 'content' do
  8 + context 'a haml layout' do
  9 + it 'should return html rendered' do
  10 + expected = <<-CONTENT
  11 +<r:inside_layout name='parent'>
  12 + <h1>
  13 + <r:layout></r:layout>
  14 + </h1>
  15 +</r:inside_layout>
  16 +CONTENT
  17 + layouts(:haml).content.should === expected
  18 + end
  19 + end
  20 + end
  21 +
  22 + describe 'is_haml?' do
  23 + context 'layout has a content type of haml' do
  24 + it 'should return true' do
  25 + layouts(:haml).is_haml?.should be_true
  26 + end
  27 + end
  28 +
  29 + context 'layout does not have a content type of haml' do
  30 + it 'should return false' do
  31 + layouts(:child).is_haml?.should be_false
  32 + end
  33 + end
  34 + end
  35 +
  36 +end
40 spec/lib/haml_layouts/models/page_spec.rb
... ... @@ -0,0 +1,40 @@
  1 +require 'spec/spec_helper'
  2 +
  3 +describe HamlLayouts::Models::Page do
  4 +
  5 + dataset :layouts_layouts, :layouts_pages
  6 +
  7 + describe 'parse_object' do
  8 + context 'haml filter type' do
  9 + it 'should render haml radius tags' do
  10 + @part = PagePart.new({
  11 + :content => '%r:title',
  12 + :filter_id => 'Haml'
  13 + })
  14 + @page = pages(:parent)
  15 +
  16 + @page.parse_object(@part).should === "#{@page.title}\n"
  17 + end
  18 +
  19 + it 'should render textile radius tags' do
  20 + @part = PagePart.new({
  21 + :content => 'h1. <r:title />',
  22 + :filter_id => 'Textile'
  23 + })
  24 + @page = pages(:parent)
  25 +
  26 + @page.parse_object(@part).should === "<h1>#{@page.title}</h1>"
  27 + end
  28 +
  29 + it 'should render non filtered tags' do
  30 + @part = PagePart.new({
  31 + :content => '<r:title />'
  32 + })
  33 + @page = pages(:parent)
  34 +
  35 + @page.parse_object(@part).should === @page.title
  36 + end
  37 + end
  38 + end
  39 +
  40 +end
58 spec/lib/nested_layouts/tags_spec.rb → spec/lib/nested_layouts/tags/core_spec.rb
... ... @@ -1,33 +1,41 @@
1   -require File.dirname(__FILE__) + '/../../spec_helper'
  1 +require 'spec/spec_helper'
2 2
3   -describe NestedLayouts::Tags do
4   - dataset :pages
5   - dataset :nested_layouts
  3 +describe NestedLayouts::Tags::Core do
6 4
7   - describe '<r:inside_layout>, <r:layout> and <r:content_for_layout>' do
  5 + dataset :layouts_pages, :layouts_layouts
  6 +
  7 + describe '<r:inside_layout>, <r:layout>, <r:body /> and <r:content_for_layout>' do
8 8
9 9 it 'should output tag within the body of class name for parent layout' do
10 10 tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
11 11 expected = <<-CONTENT
  12 +<!DOCTYPE html>
12 13 <html>
13   - <body class="parent">
  14 + <head>
  15 + <title>Title</title>
  16 + </head>
  17 + <body class="site parent">
14 18 <h1>Hi</h1>
15 19 </body>
16 20 </html>
17 21 CONTENT
18   - pages(:parent_layout).should render(tag).as(expected)
  22 + pages(:parent).should render(tag).as(expected)
19 23 end
20 24
21 25 it 'should output tag within the body of class name for a child_layout' do
22 26 tag = %{<r:inside_layout name='parent'><h1>Hi</h1></r:inside_layout>}
23 27 expected = <<-CONTENT
  28 +<!DOCTYPE html>
24 29 <html>
25   - <body class="child">
  30 + <head>
  31 + <title>Title</title>
  32 + </head>
  33 + <body class="site child">
26 34 <h1>Hi</h1>
27 35 </body>
28 36 </html>
29 37 CONTENT
30   - pages(:child_layout).should render(tag).as(expected)
  38 + pages(:child).should render(tag).as(expected)
31 39 end
32 40
33 41 end
@@ -37,25 +45,33 @@
37 45 it 'it should render the contents if true' do
38 46 tag = %{<r:inside_layout name='parent'><r:if_layout name='parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
39 47 expected = <<-CONTENT
  48 +<!DOCTYPE html>
40 49 <html>
41   - <body class="parent">
  50 + <head>
  51 + <title>Title</title>
  52 + </head>
  53 + <body class="site parent">
42 54 <h1>Hi</h1>
43 55 </body>
44 56 </html>
45 57 CONTENT
46   - pages(:parent_layout).should render(tag).as(expected)
  58 + pages(:parent).should render(tag).as(expected)
47 59 end
48 60
49 61 it 'it should not render the contents if false' do
50 62 tag = %{<r:inside_layout name='parent'><r:if_layout name='not parent'><h1>Hi</h1></r:if_layout></r:inside_layout>}
51 63 expected = <<-CONTENT
  64 +<!DOCTYPE html>
52 65 <html>
53   - <body class="parent">
  66 + <head>
  67 + <title>Title</title>
  68 + </head>
  69 + <body class="site parent">
54 70
55 71 </body>
56 72 </html>
57 73 CONTENT
58   - pages(:parent_layout).should render(tag).as(expected)
  74 + pages(:parent).should render(tag).as(expected)
59 75 end
60 76
61 77 end
@@ -65,25 +81,33 @@
65 81 it 'it should not render the contents if true' do
66 82 tag = %{<r:inside_layout name='parent'><r:unless_layout name='parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
67 83 expected = <<-CONTENT
  84 +<!DOCTYPE html>
68 85 <html>
69   - <body class="parent">
  86 + <head>
  87 + <title>Title</title>
  88 + </head>
  89 + <body class="site parent">
70 90
71 91 </body>
72 92 </html>
73 93 CONTENT
74   - pages(:parent_layout).should render(tag).as(expected)
  94 + pages(:parent).should render(tag).as(expected)
75 95 end
76 96
77 97 it 'it should not render the contents if false' do
78 98 tag = %{<r:inside_layout name='parent'><r:unless_layout name='not parent'><h1>Hi</h1></r:unless_layout></r:inside_layout>}
79 99 expected = <<-CONTENT
  100 +<!DOCTYPE html>
80 101 <html>
81   - <body class="parent">
  102 + <head>
  103 + <title>Title</title>
  104 + </head>
  105 + <body class="site parent">
82 106 <h1>Hi</h1>
83 107 </body>
84 108 </html>
85 109 CONTENT
86   - pages(:parent_layout).should render(tag).as(expected)
  110 + pages(:parent).should render(tag).as(expected)
87 111 end
88 112
89 113 end
5 spec/lib/share_layouts/controllers/action_controller_spec.rb
... ... @@ -0,0 +1,5 @@
  1 +require 'spec/spec_helper'
  2 +
  3 +describe ShareLayouts::Controllers::ActionController do
  4 +
  5 +end
61 spec/helpers/share_layouts_helper_spec.rb → spec/lib/share_layouts/helpers/action_view_spec.rb
... ... @@ -1,17 +1,19 @@
1 1 require 'spec/spec_helper'
2 2
3   -describe ShareLayouts::Helper do
4   - include ShareLayouts::Helper
5   - dataset :layouts, :pages, :share_layouts
  3 +describe ShareLayouts::Helpers::ActionView do
  4 + include ShareLayouts::Helpers::ActionView
  5 +
  6 + dataset :layouts_layouts, :layouts_pages
6 7 test_helper :page
7 8 attr_accessor :request, :response
8   -
9   -MAIN_RESULT = <<-TEXT
  9 +
  10 + MAIN_RESULT = <<-TEXT
  11 +<!DOCTYPE html>
10 12 <html>
11 13 <head>
12   - <title>My Title</title>
  14 + <title>Title</title>
13 15 </head>
14   - <body>
  16 + <body class="site parent">
15 17 something
16 18 </body>
17 19 </html>
@@ -20,45 +22,45 @@
20 22 before(:each) do
21 23 @page = RailsPage.new(page_params(:class_name => "RailsPage"))
22 24 @content_for_layout = "something"
23   - @radiant_layout = layouts(:main).name
  25 + @radiant_layout = layouts(:parent).name
24 26 @request = OpenStruct.new(:path => "/some/page/")
25 27 end
26   -
  28 +
27 29 it "should extract_content_captures_as_hash" do
28 30 extract_captures.should == {:body => "something"}
29 31 @content_for_sidebar = "sidebar"
30 32 extract_captures.should == {:body => "something", :sidebar => "sidebar"}
31 33 end
32   -
  34 +
33 35 # testing assignment of layout
34 36 it "should assign_layout_of_page" do
35 37 assign_attributes!(@page)
36   - @page.layout.should == layouts(:main)
  38 + @page.layout.should == layouts(:parent)
37 39 end
38   -
  40 +
39 41 it "should assign_layout_of_page_when_missing" do
40 42 previous_layout = @page.layout
41 43 @radiant_layout = ''
42 44 assign_attributes!(@page)
43 45 previous_layout.should == @page.layout
44 46 end
45   -
  47 +
46 48 # testing assignment of page.title
47 49 it "should assign_page_title_from_instance_var" do
48 50 @title = "My title"
49 51 assign_attributes!(@page)
50 52 @page.title.should == "My title"
51 53 end
52   -
  54 +
53 55 it "should assign_page_title_from_capture" do
54 56 @content_for_title = "My title"
55 57 assign_attributes!(@page)
56 58 @page.title.should == "My title"
57 59 end
58   -
  60 +
59 61 it "should assign_title_from_existing_page_title_when_not_specified" do
60 62 assign_attributes!(@page)
61   - @page.title.should =~ /Page \d+$/ # was 'New Page' before. I assume this changed in Radiant 0.8
  63 + @page.title.should =~ /New Page/ # was 'New Page' before. I assume this changed in Radiant 0.8
62 64 end
63 65
64 66 it "should assign_empty_title_if_missing" do
@@ -69,20 +71,20 @@
69 71 assign_attributes!(@page)
70 72 @page.title.should == ''
71 73 end
72   -
  74 +
73 75 #testing assignment of page.breadcrumb
74 76 it "should assign_page_breadcrumb_from_instance_var" do
75 77 @breadcrumb = "My breadcrumb"
76 78 assign_attributes!(@page)
77 79 @page.breadcrumb.should == "My breadcrumb"
78 80 end
79   -
  81 +
80 82 it "should assign_page_breadcrumb_from_capture" do
81 83 @content_for_breadcrumb = "My breadcrumb"
82 84 assign_attributes!(@page)
83 85 @page.breadcrumb.should == "My breadcrumb"
84 86 end
85   -
  87 +
86 88 it "should assign_breadcrumb_from_existing_breadcrumb_when_not_specified" do
87 89 @page.breadcrumb = "existing breadcrumb"
88 90 assign_attributes!(@page)
@@ -98,7 +100,7 @@
98 100 assign_attributes!(@page)
99 101 @page.breadcrumb.should == 'Title into BC'
100 102 end
101   -
  103 +
102 104 it "should assign_empty_breadcrumb_if_title_missing_too" do
103 105 @page.title = nil
104 106 @title.should be_nil
@@ -111,14 +113,14 @@
111 113 assign_attributes!(@page)
112 114 @page.breadcrumb.should == ''
113 115 end
114   -
  116 +
115 117 # testing assignment of page.breadcrumbs
116 118 it "should assign_breadcrumbs_from_instance_var" do
117 119 @breadcrumbs = "bc"
118 120 assign_attributes!(@page)
119 121 @page.breadcrumbs.should == 'bc'
120 122 end
121   -
  123 +
122 124 it "should assign_breadcrumbs_from_capture" do
123 125 @content_for_breadcrumbs = "bc"
124 126 assign_attributes!(@page)
@@ -139,30 +141,31 @@
139 141 assign_attributes!(@page)
140 142 @page.url.should == '/some/page/'
141 143 end
142   -
  144 +
143 145 # testing assigment of page.slug
144 146 it "should assign_slug_from_request_path" do
145 147 assign_attributes!(@page)
146 148 @page.slug.should == 'page'
147 149 end
148   -
  150 +
149 151 # testing assignment of page.published_at
150 152 it "should assign_published_at" do
151 153 assign_attributes!(@page)
152 154 @page.published_at.should_not be_nil
153 155 end
154   -
  156 +
155 157 it "should render_page" do
156 158 @title = "My Title"
157 159 radiant_layout.strip.should == MAIN_RESULT.strip
158 160 end
159   -
  161 +
160 162 it "should find_page" do
161 163 @request.path = "/app/something/"
162   - find_page.should == pages(:rails_page)
  164 + find_page.should == pages(:rails)
163 165 find_page.should be_a_kind_of(RailsPage)
164 166 @request.path = "/some-other/url/"
165   - find_page.should_not == pages(:rails_page)
  167 + find_page.should_not == pages(:rails)
166 168 find_page.should be_a_kind_of(RailsPage)
167 169 end
168   -end
  170 +
  171 +end
35 spec/lib/share_layouts_extension_spec.rb
... ... @@ -1,23 +1,38 @@
1 1 require 'spec/spec_helper'
2 2
  3 +# Ensures that the Extension initializes correctly
3 4 describe LayoutsExtension do
4 5
5 6 context 'activate' do
6 7
7   - it 'should have a RailsPage class to call' do
8   - RailsPage.should_not be_nil
  8 + describe 'share layouts' do
  9 + it 'should have a RailsPage class to call' do
  10 + RailsPage.should_not be_nil
  11 + end
  12 + it 'should extend ActionController base methods' do
  13 + ActionController::Base.included_modules.include?(ShareLayouts::Controllers::ActionController).should be_true
  14 + end
  15 + it 'should extend ActionView helper methods' do
  16 + ActionView::Base.included_modules.include?(ShareLayouts::Helpers::ActionView).should be_true
  17 + end
9 18 end
10 19
11   - it 'should extend ActionController base methods' do
12   - ActionController::Base.included_modules.include?(ShareLayouts::RadiantLayouts).should be_true
  20 + describe 'nested layouts' do
  21 + it 'should extend Page base methods' do
  22 + Page.included_modules.include?(NestedLayouts::Tags::Core).should be_true
  23 + end
13 24 end
14 25
15   - it 'should extend ActionView helper methods' do
16   - ActionView::Base.included_modules.include?(ShareLayouts::Helper).should be_true
17   - end
18   -
19   - it 'should extend Page base methods' do
20   - Page.included_modules.include?(NestedLayouts::Tags).should be_true
  26 + describe 'haml layouts' do
  27 + it 'should have a HamlFilter class to call' do
  28 + HamlFilter.should_not be_nil
  29 + end
  30 + it 'should extend Layout base methods' do
  31 + Layout.included_modules.include?(HamlLayouts::Models::Layout).should be_true
  32 + end
  33 + it 'should extend Page base methods' do
  34 + Page.included_modules.include?(HamlLayouts::Models::Page).should be_true
  35 + end
21 36 end
22 37
23 38 end
0  spec/models/haml_filter_spec.rb
No changes.
18 spec/models/rails_page_spec.rb
@@ -3,7 +3,7 @@
3 3
4 4 describe RailsPage do
5 5 test_helper :render, :page
6   - dataset :share_layouts, :pages
  6 + dataset :layouts_layouts, :layouts_pages
7 7
8 8 before(:each) do
9 9 @page = RailsPage.new(page_params(:class_name => "RailsPage"))
@@ -18,9 +18,9 @@
18 18 end
19 19
20 20 it "should use_old_breadcrumbs_tag_if_breadcrumbs_attr_is_nil" do
21   - @page = pages(:rails_page)
  21 + @page = pages(:rails)
22 22 @page.breadcrumbs = nil
23   - @page.should render("<r:breadcrumbs nolinks='true' />").as("Homepage &gt; App page")
  23 + @page.should render("<r:breadcrumbs nolinks='true' />").as("parent &gt; App page")
24 24 end
25 25
26 26 it "should build_parts_from_hash" do
@@ -32,13 +32,13 @@
32 32 end
33 33
34 34 it "should find_rails_page_for_sub_urls_that_do_not_match_an_existing_page" do
35   - Page.find_by_url('/app/').should == pages(:rails_page)
36   - Page.find_by_url('/app/some-other-url/').should == pages(:rails_page)
37   - Page.find_by_url('/app/some-other-url/sub-url/').should == pages(:rails_page)
  35 + Page.find_by_url('/app/').should == pages(:rails)
  36 + Page.find_by_url('/app/some-other-url/').should == pages(:rails)
  37 + Page.find_by_url('/app/some-other-url/sub-url/').should == pages(:rails)
38 38 end
39 39
40 40 it "should find_page_if_sub_url_matches_one" do
41   - Page.find_by_url('/app/child-page/').should == pages(:rails_page_child)
  41 + Page.find_by_url('/app/child-page/').should == pages(:rails_child)
42 42 end
43 43
44 44 it "should find_page_for_non_sub_urls" do
@@ -46,11 +46,11 @@
46 46 end
47 47
48 48 it "should defer_to_default_url_when_not_initialized" do
49   - pages(:rails_page).url.should == '/app/'
  49 + pages(:rails).url.should == '/app/'
50 50 end
51 51
52 52 it "should modify_existing_parts_but_not_save_them" do
53   - @page = pages(:rails_page)
  53 + @page = pages(:rails)
54 54 @page.parts.create(:name => "sidebar", :content => "This is the sidebar.")
55 55
56 56 @page.build_parts_from_hash!(:body => "This is the body")
2  spec/rcov.opts
... ... @@ -1,2 +0,0 @@
1   ---exclude "spec/*,gems/*"
2   ---rails
5 spec/spec.opts
... ... @@ -1,4 +1,3 @@
1 1 --colour
2   ---format progress
3   ---loadby mtime
4   ---reverse
  2 +--format specdoc
  3 +--loadby mtime

0 comments on commit be6d217

Please sign in to comment.
Something went wrong with that request. Please try again.