Sha256: df388d543a18ca6d39a05d95b2a427213b04ee1b3886f7bbaf89e3bccdb9bc5e
Contents?: true
Size: 1.31 KB
Versions: 7
Compression:
Stored size: 1.31 KB
Contents
require 'base64' require 'spec_helper' require 'opal/source_map' describe Opal::SourceMap do let(:js_asset_path) { '/assets/source_map_example.self.js' } before do expect(Rails.application.config.opal.source_map_enabled).to be_truthy expect(Rails.application.config.assets.compile).to be_truthy expect(Rails.application.assets).to be_present expect(Rails.application.config.assets.debug).to be_truthy end let(:map_body) do get js_asset_path inline_map_prefix = '//# sourceMappingURL=data:application/json;base64,' if response.body.lines.last.start_with? inline_map_prefix Base64.decode64(response.body.lines.last.split(inline_map_prefix, 2)[1]) else source_map_regexp = %r{^//[@#] sourceMappingURL=([^\n]+)} header_map_path = response.headers['X-SourceMap'].presence comment_map_path = response.body.scan(source_map_regexp).flatten.first.to_s.strip.presence map_path = header_map_path || comment_map_path get map_path expect(response).to be_successful, "url: #{map_path}\nstatus: #{response.status}" response.body end end let(:map) { JSON.parse(map_body, symbolize_names: true) } it 'has the source map be there' do expect(map).to be_present expect(map[:sources]).to be_present expect(map[:mappings]).to be_present end end
Version data entries
7 entries across 7 versions & 1 rubygems