diff --git a/features/render/engine.feature b/features/render/engine.feature index 5022ec1f..8dc2b1a3 100644 --- a/features/render/engine.feature +++ b/features/render/engine.feature @@ -6,7 +6,7 @@ Feature: Engine Given I have the site: "test site" set up Scenario: Simple Page - Given I have a simple page created at "hello-world" with the body: + Given I have a simple page at "hello-world" with the body: """ Hello World """ @@ -16,21 +16,20 @@ Feature: Engine Hello World """ - @wip Scenario: Page with layout - Given a layout named "above_and_below" with the content: + Given a layout named "above_and_below" with the body: """
{{ content_for_layout }}
""" - And a page at "/hello_world_layout" with the layout "above_and_below" and the content: + And I have a simple page at "/hello-world-with-layout" with the layout "above_and_below" and the body: """ Hello World """ - When I render "/hello_world_layout" + When I view the rendered page at "/hello-world-with-layout" Then the rendered output should look like: """
diff --git a/features/step_definitions/page_steps.rb b/features/step_definitions/page_steps.rb index fa63e3f1..5aa533c1 100644 --- a/features/step_definitions/page_steps.rb +++ b/features/step_definitions/page_steps.rb @@ -1,20 +1,35 @@ ### Pages -Given /^I have a simple page created at "([^"]*)" with the body:$/ do |slug, page_contents| - @page = Factory("content page", :site => @site, :slug => slug, :body => page_contents) +Given /^I have a simple page at "([^"]*)" with the body:$/ do |page_slug, page_contents| + @page = Factory("content page", :slug => page_slug, :body => page_contents, :site => @site) +end + +Given /^I have a simple page at "([^"]*)" 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 = Factory("content page", :slug => page_slug, :layout => layout, :body => page_contents, :site => @site) end When /^I view the rendered page at "([^"]*)"$/ do |slug| visit "http://#{@site.domains.first}/#{slug}" end -Then /^I should have "(.*)" in the (.*) page (.*)$/ do |content, page_slug, slug| +Then /^I should have "(.*)" in the (.*) page (.*)$/ do |content, page_slug, part_slug| page = @site.pages.where(:slug => page_slug).first - part = page.parts.where(:slug => slug).first - part.should_not be_nil + raise "Could not find page: #{page_slug}" unless page + + part = page.parts.where(:slug => part_slug).first + raise "Could not find part: #{part_slug} within page: #{page_slug}" unless part + part.value.should == content end Then /^the rendered output should look like:$/ do |body_contents| page.body.should == body_contents end + +Given /^a layout named "([^"]*)" with the body:$/ do |layout_name, layout_body| + @layout = Factory(:layout, :name => layout_name, :value => layout_body, :site => @site) +end +