Sha256: 357a7494d66a1df168176592258c65b24fef7e2e859053c8d6631bb978432579

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'rake check:test_file', type: :task do
  context 'when there are .pp files under tests/' do
    before do
      test_files.each do |f|
        FileUtils.mkdir_p(File.dirname(f))
        FileUtils.touch(f)
      end
    end

    let(:test_files) do
      [
        File.join(Dir.pwd, 'tests', 'an_example.pp'),
        File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp')
      ]
    end

    it 'raises an error' do
      expected_output = test_files.join("\n")

      expect { task.execute }
        .to raise_error(/pp files present in tests folder/)
        .and output(a_string_including(expected_output)).to_stdout
    end
  end

  context 'when there are no .pp files under tests/' do
    before do
      FileUtils.mkdir('tests')
    end

    it 'runs without raising an error' do
      expect { task.execute }.not_to raise_error
    end
  end

  context 'when there is no tests/ directory' do
    it 'runs without raising an error' do
      expect { task.execute }.not_to raise_error
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
puppetlabs_spec_helper-7.3.1 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.2.0 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.1.0 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.0.5 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.0.4 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.0.3 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.0.2 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-7.0.1 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-6.0.3 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-6.0.2 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-6.0.1 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-6.0.0 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
puppetlabs_spec_helper-6.0.0.rc.1 spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb