Class: Messiah::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/messiah/configurator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Configurator

Returns a new instance of Configurator.



2
3
4
5
6
7
8
# File 'lib/messiah/configurator.rb', line 2

def initialize(config)
  @config = config
  configure_framework
  configure_world
  configure_webrat
  configure_database if @config.database
end

Class Method Details

.configure!(config) ⇒ Object



10
11
12
# File 'lib/messiah/configurator.rb', line 10

def self.configure!(config)
  new(config)
end

Instance Method Details

#configure_databaseObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/messiah/configurator.rb', line 33

def configure_database
  require 'active_record'
  ActiveRecord::Base.establish_connection(@config.database)

  require 'dr_nic_magic_models'
  DrNicMagicModels.extend_module_class!
  DrNicMagicModels::Schema.new(Object).load_schema

  require 'factory_girl'
  require 'database_cleaner'
  DatabaseCleaner.strategy = :truncation
end

#configure_frameworkObject



14
15
16
17
18
19
# File 'lib/messiah/configurator.rb', line 14

def configure_framework
  @framwork = case @config.framework
  when :code_igniter
    Messiah::Supports::CodeIgniter.new(@config)
  end
end

#configure_webratObject



21
22
23
24
25
# File 'lib/messiah/configurator.rb', line 21

def configure_webrat
  Webrat.configure do |config|
    config.mode = :rack
  end
end

#configure_worldObject



27
28
29
30
31
# File 'lib/messiah/configurator.rb', line 27

def configure_world
  Spec::Example::ExampleGroup.send(:include, Messiah::Supports::RSpec) if rspec?
  Object.send(:include, Messiah::Supports::Cucumber) if cucumber?
  Object.send(:include, Messiah::Supports::TestUnit) if test_unit?
end

#cucumber?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/messiah/configurator.rb', line 50

def cucumber?
  defined?(Cucumber)
end

#rspec?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/messiah/configurator.rb', line 46

def rspec?
  defined?(Spec::Example::ExampleGroup)
end

#test_unit?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/messiah/configurator.rb', line 54

def test_unit?
  defined?(Test::Unit)
end