Skip to content

Commit

Permalink
Complete implementation of the first Recipe Details scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
eee-c committed Mar 29, 2009
1 parent 8e05027 commit 8043cca
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/recipe_details.feature
Expand Up @@ -8,7 +8,7 @@ Feature: Recipe Details

Given a recipe for Buttermilk Chocolate Chip Pancakes
When I view the recipe
Then I should see an ingredient of "1 cup of all-purpose, unbleached flour"
Then I should see an ingredient of "1 cup all-purpose, unbleached flour"
And I should see an ingredient of "¼ teaspoons salt"
And I should see an ingredient of "chocolate chips (Nestle Tollhouse)"

Expand Down
36 changes: 33 additions & 3 deletions features/step_definitions/recipe_details.rb
Expand Up @@ -3,9 +3,35 @@
@title = "Buttermilk Chocolate Chip Pancakes"
@permalink = @date.to_s + "-" + @title.downcase.gsub(/\W/, '-')

recipe = {
:title => @title,
:date => @date,
:preparations => [
{
'quantity' => 1,
'unit' => 'cup',
'ingredient' => {
'name' => 'flour',
'kind' => 'all-purpose, unbleached'
}
},
{
'quantity' => '¼',
'unit' => 'teaspoons',
'ingredient' => { 'name' => 'salt'}
},
{
'brand' => 'Nestle Tollhouse',
'ingredient' => {
'name' => 'chocolate chips'
}
}
]
}


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

Expand All @@ -14,5 +40,9 @@
end

Then /^I should see an ingredient of "(.+)"$/ do |ingredient|
response.should contain(ingredient)
matcher = ingredient.
gsub(/\s+/, "\\s+").
gsub(/\(/, "\\(").
gsub(/\)/, "\\)")
response.should contain(Regexp.new(matcher))
end

0 comments on commit 8043cca

Please sign in to comment.