Sha256: ca9451d73792871b3dcbcb48030624a77158976a705ec1bec769b7d907e1ebe1

Contents?: true

Size: 1.75 KB

Versions: 11

Compression:

Stored size: 1.75 KB

Contents

require 'rspec'
begin
  require 'rails'
rescue LoadError
  # rails 2.3
  require 'initializer'
end
require 'action_controller'

module Rails
  class <<self
    def root
      File.expand_path(__FILE__).split('/')[0..-3].join('/')
    end
  end
end

$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'bullet'
extend Bullet::Dependency
Bullet.enable = true

MODELS = File.join(File.dirname(__FILE__), "models")
$LOAD_PATH.unshift(MODELS)
SUPPORT = File.join(File.dirname(__FILE__), "support")
Dir[ File.join(SUPPORT, "*.rb") ].reject { |filename| filename =~ /_seed.rb$/ }.sort.each { |file| require file }

RSpec.configure do |config|
  config.extend Bullet::Dependency

  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true
end

if active_record?
  ActiveRecord::Migration.verbose = false

  # Autoload every active_record model for the test suite that sits in spec/models.
  Dir[ File.join(MODELS, "*.rb") ].sort.each do |filename|
    name = File.basename(filename, ".rb")
    autoload name.camelize.to_sym, name
  end
  require File.join(SUPPORT, "sqlite_seed.rb")

  RSpec.configure do |config|
    config.before(:suite) do
      Support::SqliteSeed.setup_db
      Support::SqliteSeed.seed_db
    end

    config.after(:suite) do
      Support::SqliteSeed.teardown_db
    end
  end
end

if mongoid?
  # Autoload every mongoid model for the test suite that sits in spec/models.
  Dir[ File.join(MODELS, "mongoid", "*.rb") ].sort.each { |file| require file }
  require File.join(SUPPORT, "mongo_seed.rb")

  RSpec.configure do |config|
    config.before(:suite) do
      Support::MongoSeed.setup_db
      Support::MongoSeed.seed_db
    end

    config.after(:suite) do
      Support::MongoSeed.teardown_db
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bullet-4.5.0 spec/spec_helper.rb
bullet-4.4.0 spec/spec_helper.rb
bullet-4.3.1 spec/spec_helper.rb
bullet-4.3.0 spec/spec_helper.rb
bullet-4.2.0 spec/spec_helper.rb
bullet-4.1.6 spec/spec_helper.rb
bullet-4.1.5 spec/spec_helper.rb
bullet-4.1.4 spec/spec_helper.rb
bullet-4.1.3 spec/spec_helper.rb
bullet-4.1.2 spec/spec_helper.rb
bullet-4.1.1 spec/spec_helper.rb