Class: SkipDatabase::Runner

Inherits:
Test::Unit::AutoRunner
  • Object
show all
Defined in:
lib/skip_database/runner.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.skipping_databaseObject

Returns the value of attribute skipping_database.



4
5
6
# File 'lib/skip_database/runner.rb', line 4

def skipping_database
  @skipping_database
end

Class Method Details

.run(force_standalone = false, default_dir = nil, argv = ARGV, &block) ⇒ Object

run the test suite, disconnecting the database and requiring any files in test/skip_database if skip-database option set



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/skip_database/runner.rb', line 7

def run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
  if self.skipping_database == true
    require "unit_record"
    ActiveRecord::Base.disconnect! :stub_associations => true, :strategy => :raise
    dir = Rails.root.join("test/skip_database")
    Dir["#{dir}/*"].each { |file| require "#{dir}/#{File.basename(file, File.extname(file))}" }
  end
  r = new(force_standalone || standalone?, &block)
  r.base = default_dir
  # adding this option here so that it will show up on the help menu
  r.options.on("-s", "--skip-database", "Raise an exception when database calls are executed") {}
  r.process_args(argv)
  r.run
end