Class: Messiah::Configurator
- Inherits:
-
Object
- Object
- Messiah::Configurator
- Defined in:
- lib/messiah/configurator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #configure_database ⇒ Object
- #configure_framework ⇒ Object
- #configure_webrat ⇒ Object
- #configure_world ⇒ Object
- #cucumber? ⇒ Boolean
-
#initialize(config) ⇒ Configurator
constructor
A new instance of Configurator.
- #rspec? ⇒ Boolean
- #test_unit? ⇒ Boolean
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_database ⇒ Object
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_framework ⇒ Object
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_webrat ⇒ Object
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_world ⇒ Object
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
50 51 52 |
# File 'lib/messiah/configurator.rb', line 50 def cucumber? defined?(Cucumber) end |
#rspec? ⇒ Boolean
46 47 48 |
# File 'lib/messiah/configurator.rb', line 46 def rspec? defined?(Spec::Example::ExampleGroup) end |
#test_unit? ⇒ Boolean
54 55 56 |
# File 'lib/messiah/configurator.rb', line 54 def test_unit? defined?(Test::Unit) end |