/
meal_details.rb
66 lines (52 loc) · 1.82 KB
/
meal_details.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Given /^a "([^\"]*)" meal enjoyed in (.+)$/ do |title, date_str|
date = (date_str =~ /^\s*(\d+)\s*$/) ?
Date.new($1.to_i, 5, 13) : Date.parse(date_str)
permalink = "id-#{date.to_s}"
meal = {
:title => title,
:date => date.to_s,
:serves => 4,
:summary => "meal summary",
:description => "meal description",
:type => "Meal",
:menu => []
}
RestClient.put "#{@@db}/#{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
end
When /^I follow the link to the list of meals in 2008$/ do
click_link "2008"
end
When /^I view the list of meals prepared in May of 2009$/ do
visit("/meals/2009/05")
response.status.should == 200
end
When /^I follow the link to the list of meals in April of 2009$/ do
click_link "2009-04"
end
Then /^the "([^\"]*)" meal should be included in the list$/ do |title|
response.should have_selector("li a", :content => title)
end
Then /^the "([^\"]*)" meal should not be included in the list$/ do |title|
response.should_not have_selector("a", :content => title)
end
Then /^I should see the "([^\"]*)" meal among the meals of this month$/ do |title|
response.should have_selector("h2", :content => title)
end
Then /^I should not see the "([^\"]*)" meal among the meals of this month$/ do |title|
response.should_not have_selector("h2", :content => title)
end
Then /^I should not see a link to June of 2009$/ do
response.should_not have_selector("a", :content => "2009-06")
end
Then /^I should not see a link to February of 2009$/ do
response.should_not have_selector("a", :content => "2009-02")
end
Then /^I should see a link to May of 2009$/ do
response.should have_selector("a", :content => "2009-05")
end