Cleaning up Page steps and adding layout feature scenario

This commit is contained in:
Jacques Crocker 2010-08-01 13:52:24 -07:00
parent 2b14c9c992
commit 48c056c723
2 changed files with 24 additions and 10 deletions

View File

@ -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:
"""
<div class="up_above"></div>
{{ content_for_layout }}
<div class="down_below"></div>
"""
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:
"""
<div class="up_above"></div>

View File

@ -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