views:

32

answers:

2

This seems right, but doesn't seem to work.

env.rb:

class MyWorld
  set :environment, :test
end

app.rb:

configure :development do
  DataMapper::setup(:default, "sqlite3://development.sqlite3")
end

configure :test do
  DataMapper::setup(:default, "sqlite3://test.sqlite3")
end

It keeps using the development environment. Am I missing something, or am I doing it wrong?

A: 

Put this at the top of env.rb, and things work perfectly:

env.rb

ENV['RACK_ENV'] = 'test'

Alternatively, this will do the same without having to edit any files:

$ RACK_ENV=test cucumber features
Peter Coulton
A: 

You might want to look into the cucumber-sinatra gem. It has options to autogenerate a minimal amount of code (including your Sinatra app & rackup file). It should provide the correct syntax for getting cucumber scripts to run in test configuration.

Richard Conroy