-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from rodjek/pdk-997
(PDK-997) Remove Dir.chdir call from check:test_file task
- Loading branch information
Showing
4 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'spec_helper' | ||
|
||
describe 'rake check:test_file', type: :task do | ||
context 'when there are .pp files under tests/' do | ||
before(:each) 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(%r{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(:each) 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 |