Sha256: 86d7297e2ea895121fee9f70e15dbe250c879665512041fe5f6808bf9f2c49ac

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

ENV["RACK_ENV"] = "test"

gem "rspec", "~> 1.2.0"
gem "rack-test", ">= 0.4.0"
gem "webrat", ">= 0.5.0"

# Load app
app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
require app_file

require "spec/expectations"
require "rack/test"
require "webrat"
require "sequel/extensions/migration"

# Webrat setup
Webrat.configure do |config|
  config.mode = :rack
end

# Set the Sinatra environment
<%= name.camelize %>::App.configure do |c|
  c.set     :environment, :test
  c.disable :run
  c.enable  :raise_errors
  c.disable :logging
end

class <%= name.camelize %>World
  include Rack::Test::Methods
  include Webrat::Methods
  include Webrat::Matchers
  
  Webrat::Methods.delegate_to_session :response
  
  def app
    <%= name.camelize %>::App
  end
end

# Cucumber world setup
World { <%= name.camelize %>World.new }

Before do
  Sequel::Model.db.tables.each do |table_name|
    Sequel::Model.db.drop_table table_name
  end
  dirname = File.join(File.dirname(__FILE__), "..", "..", "migrations")
  Sequel::Migrator.apply(Sequel::Model.db, dirname) if File.directory?(dirname)
end

After do
  Sequel::Model.db.tables.each do |table_name|
    Sequel::Model.db["TRUNCATE #{table_name}"]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openhood-sinatra_app_gen-0.0.1 lib/generators/sinatra_app/templates/features/support/env.rb.erb
openhood-sinatra_app_gen-0.1.0 lib/generators/sinatra_app/templates/features/support/env.rb.erb