Sha256: 820c8f1570f21530a16e854aaaadb1a916362c3a5bbaa35ff8204ad6ee48cd95

Contents?: true

Size: 1.16 KB

Versions: 29

Compression:

Stored size: 1.16 KB

Contents

require 'lib/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/lib/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/lib/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

29 entries across 29 versions & 2 rubygems

Version Path
opal-0.10.6 spec/lib/tilt/opal_spec.rb
opal-0.10.6.beta spec/lib/tilt/opal_spec.rb
opal-0.10.5 spec/lib/tilt/opal_spec.rb
opal-0.10.4 spec/lib/tilt/opal_spec.rb
opal-0.10.3 spec/lib/tilt/opal_spec.rb
opal-0.10.2 spec/lib/tilt/opal_spec.rb
opal-0.10.1 spec/lib/tilt/opal_spec.rb
opal-0.10.0 spec/lib/tilt/opal_spec.rb
opal-0.10.0.rc2 spec/lib/tilt/opal_spec.rb
opal-0.9.4 spec/lib/tilt/opal_spec.rb
opal-0.9.3 spec/lib/tilt/opal_spec.rb
opal-0.10.0.rc1 spec/lib/tilt/opal_spec.rb
opal-0.10.0.beta5 spec/lib/tilt/opal_spec.rb
opal-0.10.0.beta4 spec/lib/tilt/opal_spec.rb
opal-0.10.0.beta3 spec/lib/tilt/opal_spec.rb
opal-0.10.0.beta2 spec/lib/tilt/opal_spec.rb
opal-0.10.0.beta1 spec/lib/tilt/opal_spec.rb
opal-0.9.2 spec/lib/tilt/opal_spec.rb
opal-0.9.0 spec/lib/tilt/opal_spec.rb
opal-0.9.0.rc1 spec/lib/tilt/opal_spec.rb