test/support/rails_helper.rb in active_assets-0.2.8 vs test/support/rails_helper.rb in active_assets-0.3.0

- old
+ new

@@ -10,17 +10,23 @@ FileUtils.rm_rf(dir) end end def initialize_application_or_load_sprites! - load_sprites! if Rails.application && Rails.application.instance_variable_defined?(:@ran) - initialize_application! unless Rails.application && Rails.application.instance_variable_defined?(:@ran) + if Rails.application && initialized? + load_sprites! + elsif Rails.application && !initialized? + initialize_application! + end end def initialize_application_or_load_expansions! - load_assets! if Rails.application && Rails.application.instance_variable_defined?(:@ran) - initialize_application! unless Rails.application && Rails.application.instance_variable_defined?(:@ran) + if Rails.application && (Rails.version.to_i < 3 || Rails.application.instance_variable_defined?(:@ran)) + load_assets! + elsif !(Rails.application && Rails.application.instance_variable_defined?(:@ran)) + initialize_application! + end end def load_assets! if File.exists?(File.join(rails_root, 'config/assets.rb')) load File.join(rails_root, 'config/assets.rb') @@ -34,8 +40,14 @@ def load_sprites! load File.join(rails_root, 'config/sprites.rb') if File.exists?(File.join(rails_root, 'config/sprites.rb')) end def initialize_application! - ActiveAssetsTest::Application.initialize! + if Rails.version.to_i >= 3 + ActiveAssetsTest::Application.initialize! + end + end + + def initialized? + Rails.version.to_i < 3 || Rails.application.instance_variable_defined?(:@ran) end end