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-1172) Call PDK::Util::Bundler.ensure_bundle! after module creation #589

Merged
merged 1 commit into from
Nov 6, 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: 2 additions & 0 deletions lib/pdk/generate/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def self.invoke(opts = {})

begin
if FileUtils.mv(temp_target_dir, target_dir)
Dir.chdir(target_dir) { PDK::Util::Bundler.ensure_bundle! }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do this regardless of whether or not it's a package install?

Copy link
Contributor Author

@rodjek rodjek Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so (unless anyone can think of a reason why not to), if for no other reason than keeping the behaviour consistent.


PDK.logger.info(_('Module \'%{name}\' generated at path \'%{path}\', from template \'%{template_url}\'.') % { name: opts[:module_name], path: target_dir, template_url: template_url })
PDK.logger.info(_('In your module directory, add classes with the \'pdk new class\' command.'))
end
Expand Down
11 changes: 11 additions & 0 deletions spec/unit/pdk/generate/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
}
end

before(:each) do
allow(PDK::Util::Bundler).to receive(:ensure_bundle!)
allow(Dir).to receive(:chdir).with(target_dir).and_yield
end

context 'when the target module directory already exists' do
before(:each) do
allow(File).to receive(:exist?).with(target_dir).and_return(true)
Expand Down Expand Up @@ -148,6 +153,12 @@
described_class.invoke(invoke_opts)
end

it 'prepares the bundler environment so that it is ready immediately' do
allow(FileUtils).to receive(:mv).with(temp_target_dir, target_dir).and_return(true)
expect(PDK::Util::Bundler).to receive(:ensure_bundle!)
described_class.invoke(invoke_opts)
end

context 'when the move to the target directory fails due to invalid permissions' do
before(:each) do
allow(FileUtils).to receive(:mv).with(temp_target_dir, target_dir).and_raise(Errno::EACCES, 'permission denied')
Expand Down