Sha256: aa377a7a44a4c6c40e0184d29eb20811c5fc60437704689a28cc93b14c286c38

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

require 'opal/spec/rake_task'

Opal::Spec::RakeTask.new('opal:spec' => :environment) do |server|
  require 'tempfile'

  asset_paths = Opal.paths + Rails.configuration.assets.paths.to_a
  tempfile = Tempfile.new(['opal-spec', '.js.rb'])

  server.sprockets.clear_paths
  asset_paths << File.dirname(tempfile.path)
  server.main = File.basename(tempfile.path, '.js.rb')

  asset_paths.each { |path| server.append_path path }

  required_assets = ['opal']
  required_assets << 'opal-spec-runner'

  asset_paths.each do |path|
    Dir["#{path}/spec/**_spec.js.{opal,rb}"].each do |spec|
      spec = spec[path.size+1..-1] # +1 is for the trailing slash
      required_assets << spec
    end
  end

  required_assets.each { |a| tempfile.puts "require #{a.inspect}" }
  tempfile.close
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-rails-0.5.2 lib/tasks/opal-rails_tasks.rake