lib/combustion.rb in combustion-0.7.0 vs lib/combustion.rb in combustion-0.8.0
- old
+ new
@@ -1,60 +1,73 @@
-require 'rails'
-require 'active_support/dependencies'
+# frozen_string_literal: true
+require "rails"
+require "active_support/dependencies"
+
module Combustion
- mattr_accessor :path, :schema_format
- mattr_reader :setup_environment
+ module Configurations
+ #
+ end
- self.path = '/spec/internal'
+ mattr_accessor :path, :schema_format, :setup_environment
+
+ self.path = "/spec/internal"
self.schema_format = :ruby
- if Rails.version.to_s > '3.1'
- Modules = %w( active_record action_controller action_view action_mailer
- sprockets )
+ MODULES = if Rails.version.to_f >= 3.1
+ %w[ active_record action_controller action_view action_mailer sprockets ]
else
- Modules = %w( active_record action_controller action_view action_mailer )
+ %w[ active_record action_controller action_view action_mailer ]
end
def self.initialize!(*modules, &block)
- @@setup_environment = block if block_given?
+ self.setup_environment = block if block_given?
options = modules.extract_options!
- modules = Modules if modules == [:all]
+ modules = MODULES if modules == [:all]
modules.each { |mod| require "#{mod}/railtie" }
Bundler.require :default, Rails.env
Combustion::Application.configure_for_combustion
+ include_database modules, options
+ Combustion::Application.initialize!
+ include_rspec
+ end
- if modules.map(&:to_s).include? 'active_record'
- Combustion::Application.config.to_prepare do
- Combustion::Database.setup(options)
- end
+ def self.include_database(modules, options)
+ return unless modules.map(&:to_s).include? "active_record"
+
+ Combustion::Application.config.to_prepare do
+ Combustion::Database.setup(options)
end
+ end
- Combustion::Application.initialize!
+ def self.include_rspec
+ return unless defined?(RSpec) && RSpec.respond_to?(:configure)
RSpec.configure do |config|
include_capybara_into config
config.include Combustion::Application.routes.url_helpers
if Combustion::Application.routes.respond_to?(:mounted_helpers)
config.include Combustion::Application.routes.mounted_helpers
end
- end if defined?(RSpec) && RSpec.respond_to?(:configure)
+ end
end
def self.include_capybara_into(config)
return unless defined?(Capybara)
config.include Capybara::RSpecMatchers if defined?(Capybara::RSpecMatchers)
config.include Capybara::DSL if defined?(Capybara::DSL)
+ return if defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
- unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
- config.include Capybara
- end
+ config.include Capybara
end
end
-require 'combustion/application'
-require 'combustion/database'
+require "combustion/application"
+require "combustion/configurations/action_controller"
+require "combustion/configurations/action_mailer"
+require "combustion/configurations/active_record"
+require "combustion/database"