Sha256: 46725ab287f33d296bdea2e1f2475526590a2cb79445bdca8b4c3ce1b8760f06

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe Teststrap::Teststrap do
  let(:teststrap) { described_class.new }

  describe "generate_tests" do
    FILES = [ 'Gemfile',
              'Berksfile',
              'Strainerfile',
              '.gitignore',
              'LICENSE']
    TEMPLATES = [
      'README.md',
      'metadata.rb',
      '.kitchen.yml',
      'spec/default_spec.rb',
      'test/integration/default/serverspec/default_spec.rb',
      'test/integration/default/serverspec/spec_helper.rb'
    ]

    before do
      allow(teststrap).to receive(:copy_file)
      allow(teststrap).to receive(:template)
      allow(teststrap).to receive(:current_directory_name)
        .and_return('test_cookbook')
    end

    it "should generate files" do
      FILES.each do |file|
        expect(teststrap).to receive(:copy_file).with(file)
      end
      teststrap.generate_tests
    end

    it "should generate templates" do
      TEMPLATES.each do |template|
        expect(teststrap).to receive(:template).with(template)
      end
      teststrap.generate_tests
    end

    it 'removes the thorfile' do
      expect(teststrap).to receive(:remove_file).with('Thorfile')
      teststrap.generate_tests
    end
  end

  describe "current_directory_name" do
    it "return current working directory name" do
      allow(Dir).to receive(:pwd).and_return('test/dir/test_cookbook')
      expect(teststrap.current_directory_name).to eq 'test_cookbook'
    end
  end

  describe "source_root" do
    it "return generator file path" do
      expect(described_class.source_root)
        .to include 'teststrap/generator_files'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teststrap-1.3.0 spec/teststrap_spec.rb