Sha256: 03225acd6cc01476e445c695ac7700f5e86730f4538154acf39d6b68fec31a66

Contents?: true

Size: 1.15 KB

Versions: 17

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'tilt/opal'

describe Opal::TiltTemplate do
  %w[rb js.rb opal js.opal].each do |ext|
    let(:ext) { ext }

    describe %Q{with extension ".#{ext}"} do
      it "is registered for '.#{ext}' files" do
        expect(Tilt["test.#{ext}"]).to be <= described_class
      end

      it "compiles and evaluates the template on #render" do
        template = described_class.new('file') { |t| "puts 'Hello, World!'\n" }
        expect(template.render(Object.new)).to include('"Hello, World!"')
      end
    end
  end

  it "support :build option" do
    template = described_class.new('./spec/fixtures/opal_file.rb', :build=>true)
    output = template.render
    expect(output).to include('"hi from opal!"')
    expect(output).to include('self.$require("corelib/runtime");')
  end

  it "support :builder option" do
    builder = Opal::Builder.new(:stubs=>['opal'])
    template = described_class.new('./spec/fixtures/opal_file.rb', :builder=>builder)

    2.times do
      output = template.render
      expect(output.scan(/hi from opal!/).length).to eql(1)
      expect(output).not_to include('self.$require("corelib/runtime");')
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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