Sha256: 06581b4f86747820d18423421f893258be08419d607c0d20ca92ac5924a382c2

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

require 'lib/spec_helper'
require 'opal/sprockets/processor'

describe Opal::Processor do
  let(:pathname) { Pathname("/Code/app/mylib/opal/foo.#{ext}") }
  let(:_context) { double('_context', :logical_path => "foo.#{ext}", :pathname => pathname) }
  let(:env) { double('env') }

  before do
    env.stub(:resolve) { pathname.expand_path.to_s }
    env.stub(:[])
    _context.stub(:environment) { env }
  end

  %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 eq(described_class)
      end

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

      it "can be rendered more than once" do
        template = described_class.new(_context) { |t| "puts 'Hello, World!'\n" }
        3.times { expect(template.render(_context)).to include('"Hello, World!"') }
      end
    end
  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
opal-0.7.2 spec/lib/sprockets/processor_spec.rb
opal-0.7.1 spec/lib/sprockets/processor_spec.rb
opal-0.7.0 spec/lib/sprockets/processor_spec.rb
opal-0.7.0.rc1 spec/lib/sprockets/processor_spec.rb
opal-0.7.0.beta3 spec/lib/sprockets/processor_spec.rb
opal-0.7.0.beta2 spec/lib/sprockets/processor_spec.rb
opal-cj-0.7.0.beta2 spec/lib/sprockets/processor_spec.rb
opal-cj-0.7.0.beta1 spec/lib/sprockets/processor_spec.rb
opal-0.7.0.beta1 spec/lib/sprockets/processor_spec.rb