Skip to content

Commit

Permalink
Initial implementation of recipe instructions and summaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
eee-c committed Apr 7, 2009
1 parent 9a8bc5b commit 9150993
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
24 changes: 24 additions & 0 deletions features/step_definitions/recipe_details.rb
Expand Up @@ -110,6 +110,30 @@
:content_type => 'application/json'
end

Given /^a recipe for Curried Shrimp$/ do
@date = Date.new(2009, 4, 2)
@title = "Mango and Tomato Salad"
@permalink = @date.to_s + "-" + @title.downcase.gsub(/\W/, '-')

@summary = "This dish is *yummy*."
@instructions = <<_EOM
While the shrimp are defrosting, we chop the vegetables.
The onion and the garlic are finely chopped, keeping them separate on the large cutting board.
_EOM

recipe = {
:title => @title,
:date => @date,
:summary => @summary,
:instructions => @instructions
}

RestClient.put "#{@@db}/#{@permalink}",
recipe.to_json,
:content_type => 'application/json'
end

When /^I view the recipe$/ do
visit("/recipes/#{@permalink}")
end
Expand Down
4 changes: 4 additions & 0 deletions helpers.rb
Expand Up @@ -17,5 +17,9 @@ def recipe_category_link(recipe, category)
%Q|<a>#{category}</a>|
end
end

def wiki(text)
text
end
end
end
11 changes: 11 additions & 0 deletions spec/eee_helpers_spec.rb
@@ -0,0 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper' )

describe "wiki" do
it "should return simple text as unaltered text" do
wiki("bob").should == "bob"
end
it "should convert textile to HTML"
it "should wikify temperatures"
it "should wikify kids names"
it "should wikify recipe URIs"
end
24 changes: 23 additions & 1 deletion spec/views/recipe.haml_spec.rb
Expand Up @@ -3,14 +3,36 @@
describe "recipe.haml" do
before(:each) do
@title = "Recipe Title"
assigns[:recipe] = @recipe = { 'title' => @title }
@summary = "Recipe Summary"
@instructions = "Recipe Instructions"
assigns[:recipe] = @recipe = {
'title' => @title,
'summary' => @summary,
'instructions' => @instructions
}
end

it "should display the recipe's title" do
render("/views/recipe.haml")
response.should have_selector("h1", :content => @title)
end

it "should display the recipe's summary" do
self.stub!(:wiki).and_return("wiki #{@summary}")

render("/views/recipe.haml")
response.should have_selector("#eee-summary",
:content => "wiki #{@summary}")
end

it "should display the recipe's instructions" do
self.stub!(:wiki).and_return("wiki #{@instructions}")

render("/views/recipe.haml")
response.should have_selector("#eee-instructions",
:content => "wiki #{@instructions}")
end

context "a recipe with no tools or appliances" do
before(:each) do
@recipe[:tools] = nil
Expand Down
6 changes: 6 additions & 0 deletions views/recipe.haml
Expand Up @@ -14,6 +14,9 @@
%h1
= @recipe['title']

#eee-summary
= wiki @recipe['summary']

.eee-recipe-meta
%div= "Preparation Time: " + hours(@recipe['prep_time'])
- if @recipe['inactive_time']
Expand Down Expand Up @@ -43,3 +46,6 @@
- if preparation['brand']
%span.brand
= "(" + preparation['brand'] + ")"

#eee-instructions
= wiki @recipe['instructions']

0 comments on commit 9150993

Please sign in to comment.