Sunday, March 22, 2009

First Steps Toward Implementation

‹prev | My Chain | next›

Having spiked both Merb and Sinatra, I prefer Sinatra for reimplementing EEE Cooks on CouchDB. It keeps me close to the metal. I am not planning on adding any editing features that might benefit from an ORM like DataMapper. Getting the spike running for Sinatra was at least as easy as it was for Merb. All of which makes Sinatra the right choice for me.

I have three features drafted, so I will get started with the recipe details feature. First up, I need to add the env.rb Cucumber support file. The standard Cucumber file works just fine now (I had to muck with it some during the spike):
# NOTE: This must come before the require 'webrat', otherwise
# sinatra will look in the wrong place for its views.
require File.dirname(__FILE__) + '/../../eee'

# RSpec matchers
require 'spec/expectations'

# Webrat
require 'webrat'
Webrat.configure do |config|
config.mode = :sinatra

World do
session =
Running the story with cucumber features/recipe_details.feature, I get:
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- ./features/support/../../eee (LoadError)
Failed to load features/support/env.rb
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./features/support/env.rb:3
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/cstrom/.gem/ruby/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/cli.rb:227:in `require_files'
from /home/cstrom/.gem/ruby/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/cli.rb:225:in `each'
from /home/cstrom/.gem/ruby/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/cli.rb:225:in `require_files'
from /home/cstrom/.gem/ruby/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/cli.rb:148:in `execute!'
from /home/cstrom/.gem/ruby/1.8/gems/cucumber-0.1.16/bin/../lib/cucumber/cli.rb:13:in `execute'
from /home/cstrom/.gem/ruby/1.8/gems/cucumber-0.1.16/bin/cucumber:6
from /home/cstrom/.gem/ruby/1.8/bin/cucumber:19:in `load'
from /home/cstrom/.gem/ruby/1.8/bin/cucumber:19
To address the error message, I simply need to create my sinatra code file
cstrom@jaynestown:~/repos/eee-code$ touch eee.rb
Re-running the story, I find that I need to implement some steps:
cstrom@jaynestown:~/repos/eee-code$ cucumber features/recipe_details.feature 
Feature: Recipe Details # features/recipe_details.feature

So that I can accurately reproduce a recipe at home
As a web user
I want to be able to easily recognize important details
Scenario: Viewing a recipe with several ingredients # features/recipe_details.feature:7
Given a recipe for Buttermilk Chocolate Chip Pancakes # features/recipe_details.feature:9
When I view the recipe # features/recipe_details.feature:10
Then I should see an ingredient of "1 cup of all-purpose, unbleached flour" # features/recipe_details.feature:11
And I should see an ingredient of "¼ teaspoons salt" # features/recipe_details.feature:12
And I should see an ingredient of "chocolate chips (Nestle Tollhouse)" # features/recipe_details.feature:13
Next up, I need to create a test DB into which I can dump test data. I did that with a ternary operator in my spike, but would like to get it into Sinatra configuration this time around. Something to figure out tomorrow.

No comments:

Post a Comment