Skip to content

Commit

Permalink
(PDK-1061) Ensure rake binstub when building module
Browse files Browse the repository at this point in the history
Before building a module package, we first call
`PDK::Test::Unit.tear_down` to make sure that there are no artifacts
left over from possible test runs. This method depends on the `rake`
binstub being present which is ensured when running `pdk test unit`,
however when the user is running `pdk build` on a clean clone of
a module this binstub is not present and the build fails.
  • Loading branch information
rodjek committed Jul 2, 2018
1 parent 52e8fba commit fd03949
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/pdk/module/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def cleanup_build_dir
#
# @return nil
def cleanup_module
PDK::Util::Bundler.ensure_bundle!
PDK::Util::Bundler.ensure_binstubs!('rake')

PDK::Test::Unit.tear_down
end

Expand Down
16 changes: 16 additions & 0 deletions spec/unit/pdk/module/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,20 @@
end
end
end

describe '#cleanup_module' do
subject(:instance) { described_class.new(module_dir: module_dir) }

let(:module_dir) { File.join(root_dir, 'tmp', 'my-module') }

after(:each) do
instance.cleanup_module
end

it 'ensures the rake binstub is present before cleaning up spec fixtures' do
expect(PDK::Util::Bundler).to receive(:ensure_bundle!).ordered
expect(PDK::Util::Bundler).to receive(:ensure_binstubs!).with('rake').ordered
expect(PDK::Test::Unit).to receive(:tear_down).ordered
end
end
end

0 comments on commit fd03949

Please sign in to comment.