Sha256: f67d4d9b2b235b5b76020366bb6415127227d901a896140a026c1b265d5ab2ac

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

RSpec::Matchers.define :be_wrapped_in_closure do
  match do |result|
    result =~ /void function ()/
  end
end

describe Emblem do

  source = <<-eos
class App
  +computed
  myProp: -> 'hello world'
eos

  it 'should compile' do
    result = Emblem.compile(source)
    result.should =~ /Ember\.Object\.extend/
    result.should =~ /property/
  end

  describe Emblem::EmblemTemplate do

    # Ensure default_bare has its default value.
    default_bare = Emblem::EmblemTemplate.default_bare
    before { Emblem::EmblemTemplate.default_bare = default_bare }

    subject { Emblem::EmblemTemplate.new{ source } }

    def render_and_check_output
      result = subject.render
      result.should =~ /Ember\.Object\.extend/
      result.should =~ /property/
      result
    end

    it 'should render' do
      result = render_and_check_output
      result.should be_wrapped_in_closure
    end

    context 'without closure wrapping' do
      it 'should render without closure if default_bare is true' do
        Emblem::EmblemTemplate.default_bare = true
        result = render_and_check_output
        result.should_not be_wrapped_in_closure
      end

      it 'should render without closure if options[:bare] is true' do
        subject = Emblem::EmblemTemplate.new(bare: true) { source }
        result = subject.render
        result.should_not be_wrapped_in_closure
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emblem-0.0.2 spec/ember_script_spec.rb