Sha256: 7e25cfb621c8d1ad7e5a5cd6ae8c1581b4c76fc29b39891e3992e9186481689f

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

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

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

    before do
      teststrap.stub(:copy_file)
      teststrap.stub(:template)
      teststrap.stub(:current_directory_name)
        .and_return('test_cookbook')
    end

    it "should generate files" do

      FILES.each do |file|
        teststrap.should_receive(:copy_file).with(file)
      end

      teststrap.generate_tests
    end

    it "should generate templates" do

      TEMPLATES.each do |template|
        teststrap.should_receive(:template).with(template)
      end

      teststrap.generate_tests
    end
  end

  describe "current_directory_name" do
    it "return current working directory name" do
      Dir.stub('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

  describe "encrypt" do
    it "encrypt data file with secret key" do
      directory = File.dirname(__FILE__)
      data_path = File.expand_path('test/data.json', directory)
      secret_path = File.expand_path('test/secret', directory)
      key = teststrap.encrypt(data_path, secret_path)
      expect(key["id"]).to eq "user"
      expect(key["password"]["cipher"]).to eq "aes-256-cbc"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teststrap-1.1.8 spec/teststrap_spec.rb
teststrap-1.1.7 spec/teststrap_spec.rb