Sha256: 226a26871d13f128c749f8dd97be0074f899fc627fbaa36d5f440af5feabf2eb

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

require 'spec_helper'
require 'opal/source_map'

describe Opal::SourceMap do
  before do
    expect(Rails.application.config.opal.source_map_enabled).to be_true
    get '/assets/source_map_example.js'
  end

  let(:map_url) { extract_map_url(response) }

  let(:map_body) do
    get map_url
    raise "#{response.status}\n\n#{response.body}" unless response.success?
    response.body
  end

  let(:map) { JSON.parse(map_body) }

  it 'has the source map header or magic comment' do
    expect(extract_map_url(response)).to be_present
  end

  it "the map is a valid json" do
    %w[sources mappings].each do |key|
      expect(map_body[key]).to be_present
    end
  end

  def extract_map_url response
    response.headers['X-SourceMap'] or
    response.body.scan(%r{^//@ sourceMappingURL=([^\n]+)}).flatten.first.strip
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-rails-0.6.2 spec/integration/source_map_spec.rb
opal-rails-0.6.1 spec/integration/source_map_spec.rb
opal-rails-0.6.0 spec/integration/source_map_spec.rb