Sha256: 4daa3c00fca55d74a8c69c80c37267426f826b26a6d555c0a3736bc6bae462d0

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

require 'sprockets'
require 'pathname'
require 'opal/rspec/cached_environment'
require 'opal/rspec/pre_rack_locator'
require 'forwardable'

module Opal
  module RSpec
    class SprocketsEnvironment < ::Sprockets::Environment
      extend Forwardable
      # this class accessible from config.ru and the rask task initializer

      def_delegators :@locator,
                     :spec_pattern=,
                     :spec_pattern,
                     :spec_exclude_pattern=,
                     :spec_exclude_pattern,
                     :spec_files=,
                     :spec_files

      def initialize(spec_pattern=nil, spec_exclude_pattern=nil, spec_files=nil)
        @locator = RSpec::PreRackLocator.new spec_pattern, spec_exclude_pattern, spec_files
        super()
      end

      def add_spec_paths_to_sprockets
        @locator.get_spec_load_paths.each { |p| append_path p }
      end

      def cached
        CachedEnvironment.new(self, @locator)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-rspec-0.5.0.beta3 lib/opal/rspec/sprockets_environment.rb