Peter Coulton
Peter Coulton

Reputation: 55829

Get Cucumber to use the test environment in Sinatra

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?

Upvotes: 2

Views: 815

Answers (2)

Richard Conroy
Richard Conroy

Reputation: 1880

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.

Upvotes: 0

Peter Coulton
Peter Coulton

Reputation: 55829

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

Upvotes: 2

Related Questions