Sha256: baa22d797e83f4c36e86abed8eb38d8b4bb89c8cc8e9d8747a73d47c8f30d044

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
module WLang
  describe Dialect, 'new' do

    let(:base){ Dialect.default_options }
    let(:template){ Template.new "blah" }

    subject{ Dialect.new(*args) }

    context 'with no arguments' do
      let(:args){ [] }
      it 'should have default options' do
        subject.options.should eq(base)
      end
      it 'should not have a template' do
        subject.template.should be_nil
      end
    end

    context 'with only options' do
      let(:args){ [{:foo => :bar}] }
      it 'should have merged options' do
        subject.options.should eq(base.merge(:foo => :bar))
      end
      it 'should not have a template' do
        subject.template.should be_nil
      end
    end

    context 'with only a template' do
      let(:args){ [template] }
      it 'should have default options' do
        subject.options.should eq(base)
      end
      it 'should not have a template' do
        subject.template.should eq(template)
      end
    end

    context 'with options and a template' do
      let(:args){ [{:foo => :bar}, template] }
      it 'should have merged options' do
        subject.options.should eq(base.merge(:foo => :bar))
      end
      it 'should not have a template' do
        subject.template.should eq(template)
      end
    end

    context 'with options and a template in reverse order' do
      let(:args){ [template, {:foo => :bar}] }
      it 'should have merged options' do
        subject.options.should eq(base.merge(:foo => :bar))
      end
      it 'should not have a template' do
        subject.template.should eq(template)
      end
    end

  end # describe Dialect, 'new'
end # module WLang

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wlang-3.0.1 spec/unit/dialect/test_new.rb
wlang-3.0.0 spec/unit/dialect/test_new.rb
wlang-2.3.1 spec/unit/dialect/test_new.rb
wlang-2.3.0 spec/unit/dialect/test_new.rb
wlang-2.2.4 spec/unit/dialect/test_new.rb
wlang-2.2.3 spec/unit/dialect/test_new.rb
wlang-2.2.2 spec/unit/dialect/test_new.rb
wlang-2.2.1 spec/unit/dialect/test_new.rb
wlang-2.2.0 spec/unit/dialect/test_new.rb
wlang-2.1.2 spec/unit/dialect/test_new.rb
wlang-2.1.1 spec/unit/dialect/test_new.rb
wlang-2.1.0 spec/unit/dialect/test_new.rb
wlang-2.0.1 spec/unit/dialect/test_new.rb
wlang-2.0.0 spec/unit/dialect/test_new.rb