diff --git a/features/engine/basic.feature b/features/engine/basic.feature index 294b41f8..c0f2c50e 100644 --- a/features/engine/basic.feature +++ b/features/engine/basic.feature @@ -1,6 +1,7 @@ Feature: Engine - As a website user - I want to be able to view someones created locomotive pages + As a designer + I want to be able to build simple page html layouts + that render correctly to the client Background: Given I have the site: "test site" set up @@ -16,102 +17,6 @@ Scenario: Simple Page Hello World """ -Scenario: Page extending a layout with multiple blocks - Given a layout named "layout_with_sidebar" with the source: - """ -
-
- -
- {% block body %}DEFAULT BODY CONTENT{% endblock %} -
-
- - """ - And a page named "hello-world-multiblocks" with the template: - """ - {% extends 'layout_with_sidebar' %} - {% block body %}Hello world{% endblock %} - """ - When I view the rendered page at "/hello-world-multiblocks" - Then the rendered output should look like: - """ -
-
- -
- Hello world -
-
- - """ - -Scenario: Page extending a layout with multiple blocks which extends another template - Given a layout named "layout_with_sidebar" with the source: - """ -
-
- -
- {% block body %}DEFAULT BODY CONTENT{% endblock %} -
-
- - """ - And a layout named "custom_layout_with_sidebar" with the source: - """ - {% extends 'layout_with_sidebar' %} - {% block sidebar %}Custom sidebar{% endblock %} - {% block body %}Hello{% endblock %} - """ - And a page named "hello-world-multiblocks" with the template: - """ - {% extends 'custom_layout_with_sidebar' %} - {% block body %}{{ block.super }} world{% endblock %} - """ - When I view the rendered page at "/hello-world-multiblocks" - Then the rendered output should look like: - """ -
-
- -
- Hello world -
-
- - """ - -Scenario: Simple Page with layout - Given a layout named "above_and_below" with the source: - """ -
-
- {% block body %}{% endblock %} -
- - """ - - And a page named "hello-world-with-layout" with the template: - """ - {% extends 'above_and_below' %} - {% block body %}Hello World{% endblock %} - """ - - When I view the rendered page at "/hello-world-with-layout" - Then the rendered output should look like: - """ -
-
- Hello World -
- - """ - # Scenario: Page with Parts # Given a layout named "layout_with_sidebar" with the source: # """ diff --git a/features/engine/inheritance.feature b/features/engine/inheritance.feature index d18f1a2f..c1c0697a 100644 --- a/features/engine/inheritance.feature +++ b/features/engine/inheritance.feature @@ -1,4 +1,110 @@ -Scenario: Simple Page extending a layout with multiple embedded blocks which extends another template +Feature: Engine + As a designer + I want to be able to build more complex page html layouts + with shared template code + that render correctly to the client + +Background: + Given I have the site: "test site" set up + +Scenario: Liquid Inheritance with a single block + Given a layout named "above_and_below" with the source: + """ +
+
+ {% block body %}{% endblock %} +
+ + """ + + And a page named "hello-world-with-layout" with the template: + """ + {% extends 'above_and_below' %} + {% block body %}Hello World{% endblock %} + """ + + When I view the rendered page at "/hello-world-with-layout" + Then the rendered output should look like: + """ +
+
+ Hello World +
+ + """ + +Scenario: Liquid Inheritance with multiple blocks + Given a layout named "layout_with_sidebar" with the source: + """ +
+
+ +
+ {% block body %}DEFAULT BODY CONTENT{% endblock %} +
+
+ + """ + And a page named "hello-world-multiblocks" with the template: + """ + {% extends 'layout_with_sidebar' %} + {% block body %}Hello world{% endblock %} + """ + When I view the rendered page at "/hello-world-multiblocks" + Then the rendered output should look like: + """ +
+
+ +
+ Hello world +
+
+ + """ + +Scenario: Multiple inheritance (layout extending another layout) + Given a layout named "layout_with_sidebar" with the source: + """ +
+
+ +
+ {% block body %}DEFAULT BODY CONTENT{% endblock %} +
+
+ + """ + And a layout named "custom_layout_with_sidebar" with the source: + """ + {% extends 'layout_with_sidebar' %} + {% block sidebar %}Custom sidebar{% endblock %} + {% block body %}Hello{% endblock %} + """ + And a page named "hello-world-multiblocks" with the template: + """ + {% extends 'custom_layout_with_sidebar' %} + {% block body %}{{ block.super }} world{% endblock %} + """ + When I view the rendered page at "/hello-world-multiblocks" + Then the rendered output should look like: + """ +
+
+ +
+ Hello world +
+
+ + """ + + +Scenario: Page extending a layout with multiple embedded blocks which extends another template Given a layout named "layout_with_sidebar" with the source: """
diff --git a/features/step_definitions/page_steps.rb b/features/step_definitions/page_steps.rb index 0ec87596..e31560bb 100644 --- a/features/step_definitions/page_steps.rb +++ b/features/step_definitions/page_steps.rb @@ -1,9 +1,9 @@ ### Pages # helps create a simple content page (parent: "index") with a slug, contents, and layout -def create_content_page(page_slug, page_contents, layout = nil, template = nil) +def create_content_page(page_slug, page_contents, template = nil) @home = @site.pages.where(:slug => "index").first || Factory(:page) - page = @site.pages.create(:slug => page_slug, :body => page_contents, :layout => layout, :parent => @home, :title => "some title", :published => true, :layout_template => template) + page = @site.pages.create(:slug => page_slug, :body => page_contents, :parent => @home, :title => "some title", :published => true, :layout_template => template) page.should be_valid page end @@ -13,16 +13,8 @@ Given /^a simple page named "([^"]*)" with the body:$/ do |page_slug, page_conte @page = create_content_page(page_slug, page_contents) end -# creates a page (that has a layout) -Given /^a page named "([^"]*)" with the layout "([^"]*)" and the body:$/ do |page_slug, layout_name, page_contents| - layout = @site.layouts.where(:name => layout_name).first - raise "Could not find layout: #{layout_name}" unless layout - - @page = create_content_page(page_slug, page_contents, layout) -end - Given /^a page named "([^"]*)" with the template:$/ do |page_slug, template| - @page = create_content_page(page_slug, '', nil, template) + @page = create_content_page(page_slug, '', template) end # creates a layout