diff --git a/plugins/provisioners/ansible/cap/guest/pip/pip.rb b/plugins/provisioners/ansible/cap/guest/pip/pip.rb index df22cf181..462131c02 100644 --- a/plugins/provisioners/ansible/cap/guest/pip/pip.rb +++ b/plugins/provisioners/ansible/cap/guest/pip/pip.rb @@ -5,7 +5,7 @@ module VagrantPlugins module Guest module Pip - DEFAULT_PIP_INSTALL_CMD = "curl https://bootstrap.pypa.io/get-pip.py | sudo python" + DEFAULT_PIP_INSTALL_CMD = "curl https://bootstrap.pypa.io/get-pip.py | sudo python".freeze def self.pip_install(machine, package = "", version = "", pip_args = "", upgrade = true) upgrade_arg = "--upgrade" if upgrade @@ -25,10 +25,10 @@ module VagrantPlugins # The objective here is to get pip either by default # or by the argument passed in. The objective is not # to circumvent the pip setup by passing in nothing. - # Thus, we stick with the default on an empty string - # or if it is an UNSET_VALUE. + # Thus, we stick with the default on an empty string. + # Typecast added in the check for safety. - if pip_install_cmd == Vagrant.plugin("2", :config)::UNSET_VALUE || pip_install_cmd.empty? + if pip_install_cmd == pip_install_cmd.to_s.empty? pip_install_cmd=DEFAULT_PIP_INSTALL_CMD end diff --git a/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb b/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb index da4b25460..a4403b7df 100644 --- a/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb +++ b/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb @@ -24,29 +24,29 @@ describe VagrantPlugins::Ansible::Cap::Guest::Pip do describe "#get_pip" do describe 'when no pip_install_command argument is provided' do - it "installs pip using the default command" do - expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") - subject.get_pip(machine) - end + it "installs pip using the default command" do + expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") + subject.get_pip(machine) + end end describe 'when pip_install_command argument is provided' do - it "runs the supplied argument instead of default" do - pip_install_command = "foo" - expect(communicator).to receive(:execute).with(pip_install_command) - subject.get_pip(machine,pip_install_command) - end + it "runs the supplied argument instead of default" do + pip_install_command = "foo" + expect(communicator).to receive(:execute).with(pip_install_command) + subject.get_pip(machine,pip_install_command) + end - it "installs pip using the default command if the argument is empty" do - pip_install_command = "" - expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") - subject.get_pip(machine,pip_install_command) - end + it "installs pip using the default command if the argument is empty" do + pip_install_command = "" + expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") + subject.get_pip(machine,pip_install_command) + end - it "installs pip using the default command if the argument is UNSET_VALUE" do - expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") - subject.get_pip(machine, Vagrant.plugin("2", :config)::UNSET_VALUE) - end + it "installs pip using the default command if the argument is nil" do + expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") + subject.get_pip(machine, nil) + end end end end \ No newline at end of file