Sha256: a1e4b845d76d8494e01d9ad7ef3312e677ab71a27acc6bb9f98cb4935698018e

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

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

describe EmberScript do

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

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

  describe EmberScript::EmberScriptTemplate do

    # Ensure default_bare has its default value.
    default_bare = EmberScript::EmberScriptTemplate.default_bare
    before { EmberScript::EmberScriptTemplate.default_bare = default_bare }

    subject { EmberScript::EmberScriptTemplate.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
        EmberScript::EmberScriptTemplate.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 = EmberScript::EmberScriptTemplate.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
ember_script-0.0.3 spec/ember_script_spec.rb