Sha256: 46033e95547d19aa47a3f35d7b8f43aa8275ebf36fb8fd939461d4120d9c19fe

Contents?: true

Size: 790 Bytes

Versions: 5

Compression:

Stored size: 790 Bytes

Contents

require 'spec_helper'
require 'opal/sprockets/erb'

describe Opal::Sprockets::ERB do
  let(:pathname) { Pathname("/Code/app/mylib/opal/foo.#{ext}") }
  let(:data) { %{<% print("") %><a href="<%= url %>"><%= name %></a>} }
  let(:input) { {
    environment: Opal::Sprockets::Environment.new.tap {|e| e.append_path "/Code/app/mylib/opal"},
    data: data,
    filename: pathname.to_s,
    load_path: "/Code/app/mylib/opal",
    metadata: {},
    cache: Sprockets::Cache.new
  } }
  let(:ext) { 'opalerb' }

  it 'renders the template' do
    result = described_class.call(input)

    expect(result[:data]).to include('"<a href=\""')
  end

  it 'implicitly requires "erb"' do
    result = described_class.call(input)

    expect(result[:required].first).to include("stdlib/erb.rb")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-sprockets-1.0.4 spec/sprockets/erb_spec.rb
opal-sprockets-1.0.3 spec/sprockets/erb_spec.rb
opal-sprockets-1.0.2 spec/sprockets/erb_spec.rb
opal-sprockets-1.0.1 spec/sprockets/erb_spec.rb
opal-sprockets-1.0.0 spec/sprockets/erb_spec.rb