Sha256: fce7ee09dd6d6de022ed699c4226ad869b2c0715d28e387a1e548f45d387f225

Contents?: true

Size: 836 Bytes

Versions: 4

Compression:

Stored size: 836 Bytes

Contents

require "sprockets"
require "sprockets-helpers"
require "construct"
require "pathname"

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

RSpec.configure do |config|
  config.include Construct::Helpers
  
  # Returns a Sprockets environment. Automatically
  # appends the "assets" path if available.
  def env
    @env ||= Sprockets::Environment.new.tap do |env|
      env.append_path "assets" if File.directory?("assets")
    end
  end
  
  # Returns a fresh context, that can be used to test helpers.
  def context(logical_path = "application.js", pathname = nil)
    pathname ||= Pathname.new(File.join("assets", logical_path)).expand_path
    env.context_class.new env, logical_path, pathname
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sprockets-helpers-0.3.0 spec/spec_helper.rb
sprockets-helpers-0.2.1 spec/spec_helper.rb
sprockets-helpers-0.2.0 spec/spec_helper.rb
sprockets-helpers-0.1.0 spec/spec_helper.rb