Sha256: 62aa0ff9254adc4771cbace0b6b5fdde6359c4adc4c183f988e8a5cd048b66f5

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe 'task_generator' do
  before(:each) do
    FileUtils.rm_rf(tasks_path) if File.exist?(tasks_path)
  end

  let(:generator_opts) do
    { :name => 'task1', :puppet_context => puppet_context, :template_dir => retrospec_templates_path,
      task_type: 'ruby', task_params: 'name, all' }
  end

  let(:module_path) do
    sample_module_path
  end

  let(:tasks_path) do
    File.join(module_path, 'tasks')
  end

  let(:puppet_context) do
    path = File.join(fixture_modules_path, 'tomcat')
    opts = { :module_path => path, :enable_beaker_tests => false, :name => 'name-test123',
             :enable_user_templates => false, :template_dir => retrospec_templates_path }
    mod = Retrospec::Plugins::V1::Puppet.new(opts[:module_path], opts)
    mod.post_init
    mod.context
  end

  let(:generator) do
    Retrospec::Puppet::Generators::TaskGenerator.new(module_path, generator_opts)
  end

  it 'should create files without error' do
    expect(generator.generate_task_files).to eq([File.join(tasks_path, 'task1.rb'), File.join(tasks_path, 'task1.json')])
    expect(File.exist?(tasks_path)).to eq(true)
  end

  it 'should return the correct task file' do
    expect(generator.task_filepath).to eq(File.join(tasks_path, 'task1.rb'))
  end

  it 'should return the correct task file' do
    expect(generator.task_params_filepath).to eq(File.join(tasks_path, 'task1.json'))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-retrospec-1.8.0 spec/unit/generators/task_generator_spec.rb
puppet-retrospec-1.7.0 spec/unit/generators/task_generator_spec.rb
puppet-retrospec-1.6.1 spec/unit/generators/task_generator_spec.rb
puppet-retrospec-1.6.0 spec/unit/generators/task_generator_spec.rb