Sha256: 7e6e8a75f94e786bfe56110384ba1adba7390e73cf903e91cbc81a7ab7a69df1

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe New::Template do
  subject(:template){ New::Template.new type, 'new_template' }
  let(:type){ :foo_template }

  before do
    New::Template.any_instance.stub(:interpolate)
  end

  after do
    New::Template.any_instance.unstub(:interpolate)
  end

  describe '#template_dir' do
    context 'with a default template' do
      let(:type){ :foo_template }

      it 'should return the default template path' do
        expect(template.send(:template_dir)).to eq File.join(New::DEFAULT_DIR, New::TEMPLATES_DIR_NAME, type.to_s)
      end
    end

    context 'with a custom template' do
      let(:type){ :custom_bar_template }

      it 'should return the custom template path' do
        expect(template.send(:template_dir)).to eq File.join(New::CUSTOM_DIR, New::TEMPLATES_DIR_NAME, type.to_s)
      end

      it 'should set the custom flag' do
        expect(template.instance_variable_get('@custom')).to be_true
      end
    end
  end

  describe '#options' do
    before do
      stub_const('New::Template::CUSTOM_CONFIG_TEMPLATE', { default: true })
    end

    it 'should build complete options' do
      options = template.send(:options)

      # check default template options
      expect(options[:default]).to be_true

      # check template options
      expect(options[:template]).to be_true

      # check custom config options
      expect(options[:custom]).to be_true

      # check project specific options
      expect(options[:type]).to eq('foo_template')
      expect(options[:project_name]).to eq('new_template')
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
new-0.0.14 spec/lib/new/template_spec.rb
new-0.0.13 spec/lib/new/template_spec.rb
new-0.0.12 spec/lib/new/template_spec.rb
new-0.0.11 spec/lib/new/template_spec.rb
new-0.0.10 spec/lib/new/template_spec.rb
new-0.0.9 spec/lib/new/template_spec.rb
new-0.0.8 spec/lib/new/template_spec.rb
new-0.0.7 spec/lib/new/template_spec.rb
new-0.0.6 spec/lib/new/template_spec.rb
new-0.0.5 spec/lib/new/template_spec.rb
new-0.0.4 spec/lib/new/template_spec.rb
new-0.0.3 spec/lib/new/template_spec.rb
new-0.0.2 spec/lib/new/template_spec.rb
new-0.0.0 spec/lib/new/template_spec.rb