Module: Adva::Testing

Extended by:
Engine
Defined in:
lib/adva/testing.rb,
lib/adva/testing/engine.rb

Defined Under Namespace

Modules: Engine

Class Method Summary collapse

Methods included from Engine

load_all, load_assertions, load_cucumber_support, load_factories, load_helpers, migrate, setup_load_paths

Class Method Details

.each_engine(&block) ⇒ Object


23
24
25
# File 'lib/adva/testing.rb', line 23

def each_engine(&block)
  Adva.engines.each(&block)
end

.load_assertionsObject


27
28
29
# File 'lib/adva/testing.rb', line 27

def load_assertions
  Adva.engines.each { |e| e.load_assertions }
end

.load_cucumber_supportObject


35
36
37
# File 'lib/adva/testing.rb', line 35

def load_cucumber_support
  Adva.engines.each { |e| e.load_cucumber_support }
end

.load_factoriesObject


31
32
33
# File 'lib/adva/testing.rb', line 31

def load_factories
  Adva.engines.each { |e| e.load_factories }
end

.load_helpersObject


39
40
41
# File 'lib/adva/testing.rb', line 39

def load_helpers
  Adva.engines.each { |e| e.load_helpers }
end

.setup(options = {}) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/adva/testing.rb', line 8

def setup(options = {})
  Adva.out = StringIO.new('')
  setup_logging(options)
  setup_active_record

  each_engine { |e| e.setup_load_paths }
  ActiveSupport::Slices.register

  each_engine { |e| e.new.require_patches }
  each_engine { |e| e.migrate }

  load_assertions
  load_factories
end

.setup_active_recordObject


51
52
53
54
55
# File 'lib/adva/testing.rb', line 51

def setup_active_record
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
  ActiveRecord::Migration.verbose = false
  DatabaseCleaner.strategy = :truncation
end

.setup_logging(options) ⇒ Object


43
44
45
46
47
48
49
# File 'lib/adva/testing.rb', line 43

def setup_logging(options)
  if log = options[:log]
    FileUtils.touch(log) unless File.exists?(log)
    ActiveRecord::Base.logger = Logger.new(log)
    ActiveRecord::LogSubscriber.attach_to(:active_record)
  end
end