Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1067) Ensure rspec-core binstubs are created for pdk test unit #546

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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