Skip to content

Commit

Permalink
Menu items in meals (including recipe links)
Browse files Browse the repository at this point in the history
  • Loading branch information
eee-c committed May 31, 2009
1 parent b06e3ac commit 54b7707
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
6 changes: 3 additions & 3 deletions features/browse_meals.feature
Expand Up @@ -35,11 +35,11 @@ Feature: Browse Meals

Scenario: Browsing a meal on a specific date

Given a "Focaccia!" meal enjoyed on March 3, 2009
And a "Focaccia" recipe from March 3, 2009
Given a "Focaccia" recipe from March 3, 2009
Given a "Focaccia!" meal with the "Focaccia" recipe on the menu
When I view the "Focaccia!" meal
Then I should see the "Focaccia!" title
And I should see a link to the "Focaccia" recipe in the menu
And I should see a "Focaccia" recipe link in the menu
When I click the "March" link
Then I should see "Focaccia!" in the list of meals
When I click the "Focaccia" link
Expand Down
24 changes: 24 additions & 0 deletions features/step_definitions/meal_details.rb
Expand Up @@ -19,6 +19,26 @@
:content_type => 'application/json'
end

Given /^a "([^\"]*)" meal with the "([^\"]*)" recipe on the menu$/ do |title, recipe_title|
date = Date.new(2009, 5, 30)
@meal_permalink = date.to_s

meal = {
:title => title,
:date => date.to_s,
:serves => 4,
:summary => "meal summary",
:description => "meal description",
:type => "Meal",
:menu => ["[recipe:#{@recipe_permalink}]"]
}

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


When /^I view the list of meals prepared in 2009$/ do
visit("/meals/2009")
response.status.should == 200
Expand Down Expand Up @@ -58,6 +78,10 @@
response.should_not have_selector("h2", :content => title)
end

Then /^I should see a "(.+)" recipe link in the menu$/ do |recipe_title|
response.should have_selector("a", :content => recipe_title)
end

Then /^I should see a link to (.+)$/ do |date|
response.should have_selector("a", :content => date)
end
Expand Down
7 changes: 7 additions & 0 deletions features/support/env.rb
Expand Up @@ -7,6 +7,13 @@
# Force the application name because polyglot breaks the auto-detection logic.
Sinatra::Application.app_file = File.join(File.dirname(__FILE__), *%w[.. .. eee.rb])

module Eee
module Helpers
def _db
"http://localhost:5984/eee-test"
end
end
end

# RSpec matchers
require 'spec/expectations'
Expand Down
20 changes: 17 additions & 3 deletions spec/views/meal.haml_spec.rb
Expand Up @@ -8,7 +8,8 @@
assigns[:meal] = @meal = {
'title' => @title,
'summary' => @summary,
'description' => @description
'description' => @description,
'menu' => ["Peanut Butter and Jelly Sandwich"]
}
end

Expand All @@ -28,9 +29,22 @@
response.should have_selector("#summary p", :content => "paragraph 1")
end

it "should display a description of the meal" do
it "should include the menu after the summary" do
render("/views/meal.haml")
response.should have_selector("#summary + #description",
response.should have_selector("#summary + ul#menu li",
:content => "Peanut Butter and Jelly Sandwich")
end

it "should wikify the menu items" do
assigns[:meal]['menu'] << "foo *bar* baz"
render("/views/meal.haml")
response.should have_selector("ul#menu li strong",
:content => "bar")
end

it "should display a description of the meal after the menu" do
render("/views/meal.haml")
response.should have_selector("#menu + #description",
:content => @description)
end

Expand Down
4 changes: 4 additions & 0 deletions views/meal.haml
Expand Up @@ -4,5 +4,9 @@
#summary
= wiki @meal['summary']

%ul#menu
- @meal['menu'].each do |menu_item|
%li= wiki(menu_item)

#description
= wiki @meal['description']

0 comments on commit 54b7707

Please sign in to comment.