Sha256: b55ee053507e9e390e45c0ccabdc117055770762f5dccb21e6be4b5b52184a57

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

ENV["RACK_ENV"] = "test"

# Load the Sinatra app
require File.join(File.dirname(__FILE__), "..", "app")

# Load the testing libraries
require "spec"
require "sequel/extensions/migration"
require "rspec_sequel_matchers"

# 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

Spec::Runner.configure do |config|
  config.include(RspecSequel::Matchers)
  
  config.before(:suite) 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

  config.after(:each) do
    Sequel::Model.db.tables.each do |table_name|
      Sequel::Model.db["TRUNCATE #{table_name}"]
    end
  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/spec/spec_helper.rb.erb
openhood-sinatra_app_gen-0.1.0 lib/generators/sinatra_app/templates/spec/spec_helper.rb.erb