Sha256: 61d63363c54aee0c69a6d28cdc7b667c17b2b610db20c34fb50202851a2bd8b5

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

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

describe Opal::ERB::Processor do
  let(:pathname) { Pathname("/Code/app/mylib/opal/foo.#{ext}") }
  let(:environment) { double(Sprockets::Environment,
    cache: nil,
    :[] => nil,
    resolve: pathname.expand_path.to_s,
    engines: double(keys: %w[.rb .js .erb .opal]),
  ) }
  let(:sprockets_context) { double(Sprockets::Context,
    logical_path: "foo.#{ext}",
    environment: environment,
    pathname: pathname,
    filename: pathname.to_s,
    root_path: '/Code/app/mylib',
    is_a?: true,
  ) }
  let(:required_assets) { [] }
  let(:template) { described_class.new { |t| %Q{<% print("") %><a href="<%= url %>"><%= name %></a>} } }
  before { allow(sprockets_context).to receive(:require_asset) {|asset| required_assets << asset } }

  let(:ext) { 'opalerb' }

  it "is registered for '.opalerb' files" do
    expect(Tilt["test.#{ext}"]).to eq(described_class)
  end

  it 'renders the template' do
    expect(template.render(sprockets_context)).to include('"<a href=\""')
  end

  it 'implicitly requires "erb"' do
    template.render(sprockets_context)
    expect(required_assets).to eq(['erb'])
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
opal-sprockets-0.4.9.1.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.8.1.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.7.1.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.6.1.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.5.1.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.4.1.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.3.0.11.0.3.7 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.2.0.11.0.3.1 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.2.pre.1.0.11.0.3.1 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.1.0.11.0.3.1 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.1.0.11.0.rc1.3.1 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.1.0.11.0.rc1.3.1.beta2 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.1.0.10.4.3.1.0 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.0.0.11.0.rc1.3.1.beta2 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.0.0.10.0.3.0.0 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.0.0.10.0.3.0.beta1 spec/sprockets/erb_spec.rb
opal-sprockets-0.4.0.0.11.dev.3.1.beta1 spec/sprockets/erb_spec.rb