Sha256: 22117f698efa386a223d5858dba6b898ffc1dc9fb81c15c3df447cd3f176ee68

Contents?: true

Size: 1.31 KB

Versions: 22

Compression:

Stored size: 1.31 KB

Contents

require 'fileutils'

module RailsHelper
  def rails_root
    @rails_root = TEST_RAILS_ROOT
  end

  def delete_cached_assets!
    Dir[File.join(rails_root, 'public/javascripts/cache'), File.join(rails_root, 'public/stylesheets/cache')].each do |dir|
      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)
  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)
  end

  def load_assets!
    if File.exists?(File.join(rails_root, 'config/assets.rb'))
      load File.join(rails_root, 'config/assets.rb')
    elsif File.directory?(File.join(rails_root, 'config/assets'))
      Dir[File.join(rails_root, 'config/assets/*.rb')].each do |f|
        load f
      end
    end
  end

  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!
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
active_assets-1.1.3 test/support/rails_helper.rb
active_assets-1.1.2 test/support/rails_helper.rb
active_assets-1.1.1 test/support/rails_helper.rb
active_assets-1.0.3 test/support/rails_helper.rb
active_assets-1.1.0 test/support/rails_helper.rb
active_assets-1.0.2 test/support/rails_helper.rb
active_assets-1.0.1 test/support/rails_helper.rb
active_assets-1.0.0 test/support/rails_helper.rb
active_assets-1.0.0.rc1 test/support/rails_helper.rb
active_assets-0.2.8 test/support/rails_helper.rb
active_assets-0.2.7 test/support/rails_helper.rb
active_assets-0.2.6 test/support/rails_helper.rb
active_assets-0.2.5 test/support/rails_helper.rb
active_assets-0.2.4 test/support/rails_helper.rb
active_assets-0.2.3 test/support/rails_helper.rb
active_assets-0.2.2 test/support/rails_helper.rb
active_assets-0.2.1 test/support/rails_helper.rb
active_assets-0.2.0 test/support/rails_helper.rb
active_assets-0.2.0.rc4 test/support/rails_helper.rb
active_assets-0.2.0.rc3 test/support/rails_helper.rb