Monday, June 8, 2009

Between Meals (Outside)

‹prev | My Chain | next›

With some Rack investigation under my belt, it is back to the drive towards deployment. That means back into Cucumber scenarios. Next up is the "navigation between meals" scenarios:



Aw, nuts:
Sinatra::Test is deprecated; use Rack::Test instead.
I upgraded everything from Sinatra::Test to Rack::Test last night. I even ack'd (thppt) through the code to make sure that I removed all references to the old Sinatra::Test. What gives?

Unfortunately, I need to punt on that question for tonight. I gave it a go following these instructions, but ended up with last_response vs. response issues. Will revisit later.

For now, I continue with the navigation-between-meals scenario. The next "undefined" step is already defined—I simply missed the word "a" in the text. Adding it, I get this far:
cstrom@jaynestown:~/repos/eee-code$ cucumber features -s "Navigating between meals"
Sinatra::Test is deprecated; use Rack::Test instead.
Feature: Browse Meals

So that I can find meals made on special occasions
As a person interested in finding meals
I want to browse meals by date

Scenario: Navigating between meals # features/browse_meals.feature:54
Given a "Focaccia! The Dinner" meal enjoyed on March 3, 2009 # features/step_definitions/meal_details.rb:1
And a "Star Wars: The Dinner" meal enjoyed on February 28, 2009 # features/step_definitions/meal_details.rb:1
And a "Pumpkin is a Very Exciting Vegetable" meal enjoyed on December 3, 2008 # features/step_definitions/meal_details.rb:1
When I view the "Focaccia! The Dinner" meal # features/step_definitions/meal_details.rb:52
Then I should see the "Focaccia! The Dinner" title # features/step_definitions/meal_details.rb:65
expected following output to contain a <h1>Focaccia! The Dinner</h1> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<div class="breadcrumbs">
<a href="/">home</a> > <a href="/meals/2008">2008</a> > <a href="/meals/2008/12">December</a> > <span>3</span>
</div>
<h1>
Pumpkin is a Very Exciting Vegetable
</h1>
<div id="summary">
<p>meal summary</p>
</div>
<ul id="menu"></ul>
<div id="description">
<p>meal description</p>
</div>
</body></html>
(Spec::Expectations::ExpectationNotMetError)
features/browse_meals.feature:60:in `Then I should see the "Focaccia! The Dinner" title'
The reason the pumpkin meal is displaying instead of the focaccia meal is that the pumpkin meal is the last of the given steps. As the last of the given steps, it defines the instance variables used to drive the when-i-view step.

I ought to be able to resolve this, without compromising the integrity of the scenario, by re-arranging the given steps:



Yup—passing all the way up to an undefined step, which I define as:
When /^I click "([^\"]*)"$/ do |text|
click_link text
end
With that, I have all steps defined, but the navigation link steps not passing:
cstrom@jaynestown:~/repos/eee-code$ cucumber features -n -s "Navigating between meals"
Sinatra::Test is deprecated; use Rack::Test instead.
Feature: Browse Meals

So that I can find meals made on special occasions
As a person interested in finding meals
I want to browse meals by date

Scenario: Navigating between meals
Given a "Pumpkin is a Very Exciting Vegetable" meal enjoyed on December 3, 2008
And a "Star Wars: The Dinner" meal enjoyed on February 28, 2009
And a "Focaccia! The Dinner" meal enjoyed on March 3, 2009
When I view the "Focaccia! The Dinner" meal
Then I should see the "Focaccia! The Dinner" title
When I click "Star Wars: The Dinner"
Could not find link with text or title or id "Star Wars: The Dinner" (Webrat::NotFoundError)
features/browse_meals.feature:61:in `When I click "Star Wars: The Dinner"'
Then I should see the "Star Wars: The Dinner" title
When I click "Pumpkin is a Very Exciting Vegetable"
Then I should see the "Pumpkin is a Very Exciting Vegetable" title
When I click "Star Wars: The Dinner"
Then I should see the "Star Wars: The Dinner" title
When I click "Focaccia! The Dinner"
Then I should see the "Focaccia! The Dinner" title

1 scenario
1 failed step
7 skipped steps
5 passed steps
I think I will stop there for the day. I still have much work to do on my presentation for the B'More on Rails group. Besides, it will be easy to know where to pick up tomorrow—working my way into the code to implement these steps.

No comments:

Post a Comment