Sha256: caa07c5e2b06d0f96b5839915eb135e59206bf8bedce0a36ebac0f6b4a669ecd
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
root = File.expand_path(File.dirname(__FILE__) + '/..') $: << "#{root}/lib" require 'sinatra/base' require 'sinatra/sequel' class MockSinatraApp < Sinatra::Base register Sinatra::SequelExtension end describe 'A Sinatra app with Sequel extensions' do before { File.unlink 'test.db' rescue nil ENV.delete('DATABASE_URL') @app = Class.new(MockSinatraApp) @app.set :migrations_log, File.open('/dev/null', 'wb') } it 'exposes the Sequel database object' do @app.should.respond_to :database end it 'uses the DATABASE_URL environment variable if set' do ENV['DATABASE_URL'] = 'sqlite://test-database-url.db' @app.database_url.should.equal 'sqlite://test-database-url.db' end it 'uses sqlite://<environment>.db when no DATABASE_URL is defined' do @app.environment = :foo @app.database_url.should.equal "sqlite://foo.db" end it 'establishes a database connection when set' do @app.database = 'sqlite://test.db' @app.database.should.respond_to :table_exists? end it 'runs database migrations' do @app.database = 'sqlite://test.db' @app.migration 'create the foos table' do |db| db.create_table :foos do primary_key :id text :foo integer :bar end end @app.database[:migrations].count.should.equal 1 @app.database.should.table_exists :foos end it 'does not run database migrations more than once' do @app.database = 'sqlite://test.db' @app.migration('this should run once') { } @app.migration('this should run once') { fail } @app.database[:migrations].count.should.equal 1 end it 'allows you to query what adapter is being used' do @app.database = 'sqlite://test.db' @app.sqlite?.should.equal true end it 'exposes a query for all available sequel adapters' do Sequel::Database::ADAPTERS.each do |adapter| @app.should.respond_to "#{adapter}?" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aura-0.0.1.pre10 | vendor/sinatra-sequel/spec/spec_sinatra_sequel.rb |