Skip to content

Commit

Permalink
Merge pull request #546 from scotje/1067_test_unit_parallel
Browse files Browse the repository at this point in the history
(PDK-1067) Ensure rspec-core binstubs are created for `pdk test unit`
  • Loading branch information
bmjen authored Jul 11, 2018
2 parents 154a333 + 6a3c446 commit 8cd4204
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pdk/tests/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def self.setup
end

def self.invoke(report, options = {})
PDK::Util::Bundler.ensure_binstubs!('rake')
PDK::Util::Bundler.ensure_binstubs!('rake', 'rspec-core')

setup

Expand Down
35 changes: 35 additions & 0 deletions package-testing/spec/package/unit_test_a_new_module_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper_package'

describe 'Generate a module for unit testing' do
module_name = 'unit_test_module'

context 'when creating a new module and new class' do
describe command("pdk new module #{module_name} --skip-interview") do
its(:exit_status) { is_expected.to eq(0) }
end

describe command("pdk new class #{module_name}") do
let(:cwd) { module_name }

its(:exit_status) { is_expected.to eq(0) }
end
end

context 'when unit testing' do
describe command('pdk test unit') do
let(:cwd) { module_name }

its(:exit_status) { is_expected.to eq(0) }
its(:stderr) { is_expected.to match(%r{evaluated 4 tests.*0 failures}im) }
end
end

context 'when unit testing in parallel' do
describe command('pdk test unit --parallel') do
let(:cwd) { module_name }

its(:exit_status) { is_expected.to eq(0) }
its(:stderr) { is_expected.to match(%r{evaluated 4 tests.*0 failures}im) }
end
end
end
2 changes: 1 addition & 1 deletion package-testing/spec/package/version_selection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
puppet_versions.map { |r| Regexp.escape(r) }.join('|')
end

describe command('pdk bundle update') do
describe command('pdk bundle update --local') do
its(:exit_status) { is_expected.to eq(0) }
end

Expand Down
11 changes: 11 additions & 0 deletions package-testing/spec/spec_helper_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@
RSpec.configuration.logger.log_level = :verbose
end
# rubocop:enable RSpec/BeforeAfterAll

c.after(:each) do
cmd = if windows_node?
command('rm -Recurse -Force $env:LOCALAPPDATA/PDK/Cache/ruby')
else
command('rm -rf ~/.pdk/cache/ruby')
end

# clear out any cached gems
cmd.run
end
end

0 comments on commit 8cd4204

Please sign in to comment.