Class: Opal::RSpec::CachedEnvironment

Inherits:
Sprockets::CachedEnvironment
  • Object
show all
Defined in:
lib/opal/rspec/cached_environment.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, locator) ⇒ CachedEnvironment

this class is accessible from the ERB/runner file



8
9
10
11
# File 'lib/opal/rspec/cached_environment.rb', line 8

def initialize(env, locator)
  super env
  @locator = locator
end

Instance Method Details

#get_opal_spec_requiresObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/opal/rspec/cached_environment.rb', line 13

def get_opal_spec_requires
  @locator.get_opal_spec_requires.map do |file|
    asset = find_asset(file)
    unless asset
      raise "Unable to find asset for file #{file} within load paths. Check your load path/file specification.\n"+
            "Searched paths:\n- #{paths.join("\n- ")}\n"

    end
    logical_path = asset.logical_path
    # These will go directly into require '...' statements in Opal, so need to trim extensions
    logical_path.sub File.extname(logical_path), ''
  end
end