Friday, July 3, 2009

Back out the RSS Rabbit Hole

‹prev | My Chain | next›

I was almost done with the recipe RSS feed last night, but had to stop when I realized that the first "Given" step was insufficient for the last "Then" step in the Cucumber scenario:
Feature: RSS

So that I tell my user when there are updates to this great cooking site
As an RSS bot
I want to be able to consume your RSS

Scenario: Recipe RSS

Given 20 delicious, easy to prepare recipes
When I access the recipe RSS feed
Then I should see the 10 most recent recipes
And I should see the summary of each recipe
Specifically, the "20 delicious, easy to prepare recipes" did not include the summaries that would need to be verified by "Then I should see the summary of each recipe". I considered creating a new step rather than re-using this step (from the recipe search feature). After reviewing the step, it seemed unlikely that adding a summary to each recipe would have any adverse effects on existing scenarios. The reworked scenario becomes:
Given /^(\d+) (.+) recipes$/ do |count, keyword|
date = Date.new(2009, 4, 22)

(1..count.to_i).each do |i|
permalink = "id-#{i}-#{keyword.gsub(/\W/, '-')}"

recipe = {
:title => "#{keyword} recipe #{i}",
:summary => "recipe summary",
:date => date,
:preparations => [
{ 'ingredient' => { 'name' => 'ingredient' } }
],
:tag_names => [keyword.downcase]
}

RestClient.put "#{@@db}/#{permalink}",
recipe.to_json,
:content_type => 'application/json'
end
end
I can now check for the "recipe summary" in the RSS feed's <description> tag:
Then /^I should see the summary of each recipe$/ do
response.
should have_selector("channel > item > description",
:content => "recipe summary")
end
And, with that, I am done with the recipe RSS feed scenario:
cstrom@jaynestown:~/repos/eee-code$ cucumber features -n \
> -s "Recipe RSS"
Sinatra::Test is deprecated; use Rack::Test instead.
Feature: RSS

So that I tell my user when there are updates to this great cooking site
As an RSS bot
I want to be able to consume your RSS

Scenario: Recipe RSS
Given 20 delicious, easy to prepare recipes
When I access the recipe RSS feed
Then I should see the 10 most recent recipes
And I should see the summary of each recipe

1 scenario
4 passed steps
To be certain that I have not broken anything, I re-run all tests and Cucumber scenarios. Happily nothing is broken and I have :
27 scenarios
9 skipped steps
1 undefined step
226 passed steps
Only one scenario is undefined at this point. That unfinished scenario, navigation between recipes, is not all that important so I could easily deploy without it done. I do need to make sure that lookup values (tools, people, books, etc) are handled properly and I need some CSS. I will head down that rabbit hole tomorrow.

No comments:

Post a Comment