Friday, May 22, 2009

Menu Items

‹prev | My Chain | next›

Let's see, where was I?
cstrom@jaynestown:~/repos/eee-code$ rake
(in /home/cstrom/repos/eee-code)

==
Sinatra app spec
.....................

Finished in 0.263321 seconds

21 examples, 0 failures

==
Helper specs
............................

Finished in 0.021924 seconds

28 examples, 0 failures

==
View specs
....**...................................

Pending:

meal_by_month.haml should include the menu items (Not Yet Implemented)
./spec/views/meal_by_month.haml_spec.rb:52

meal_by_month.haml should include recipe titles in the menu items (Not Yet Implemented)
./spec/views/meal_by_month.haml_spec.rb:54

Finished in 0.221946 seconds

41 examples, 0 failures, 2 pending
Ah yes, I need to get menu items included in the meals-by-month listing. Thanks RSpec!

To specify how the Haml template will present the CouchDB menu items, I need to add menu items to the CouchDB data structure in the spec's before(:each):
  before(:each) do
assigns[:meals] = {
'rows' => [
...
{ "value" => [{ "_id" => '2009-05-15',
"date" => '2009-05-15',
"title" => 'Meal 2',
"summary" => 'Meal 2 Summary',
"menu" => %w(foo bar baz),
"_attachments" => {"image2.jpg" => { }}
}]
}
]
}
...
end
Then I specify how this data will be used by the template:
  it "should include the menu items" do
render("/views/meal_by_month.haml")
response.should have_selector(".menu",
:content => "foo, bar, baz")
end
The spec fails because I have yet to instruct the template how to render the data. So I do so:
...
%p= meal['value'][0]['summary']
.menu= meal['value'][0]['menu'].join(', ')
With that, I am down to to one pending spec:
cstrom@jaynestown:~/repos/eee-code$ rake
...
==
View specs
.....*...................................

Pending:

meal_by_month.haml should include recipe titles in the menu items (Not Yet Implemented)
./spec/views/meal_by_month.haml_spec.rb:60

Finished in 0.229601 seconds

41 examples, 0 failures, 1 pending

(commit)

I will pick that up tomorrow and then move my way back out to the Cucumber scenario to pick up the next thing on the checklist.

No comments:

Post a Comment