Monkeypatching Vagrant Plugin

I want the monkeypatch Vagrant plugin.

Since I'm not a Ruby guy but want to test some behavior, I need help.

I need to override the method chef_provisioner?

there: https://github.com/fgrehm/vagrant-cachier/blob/master/lib/vagrant-cachier/cap/linux/chef_file_cache_path.rb

What I've got so far on top of my Vagrantfile:

module VagrantPlugins
  module Cachier
    module Cap
      module Linux
        module ChefFileCachePath
          def self.chef_provisioner?(machine)
            # patch applies here
          end
        end
      end
    end
  end
end

      

Vagrant does not recognize the patch. What's missing? Is it possible?

+3


source to share


1 answer


I managed to neutralize it like this:



module VagrantPlugins
  module Cachier
    module Cap
      module Linux
        module ChefFileCachePath
          def self.chef_provisioner?(machine)
            # stuff
          end
          def self.chef_file_cache_path(machine)
            # other method stuff
          end
        end
      end
    end
  end
end

VagrantPlugins::Cachier::Plugin.guest_capability 'linux', 'chef_file_cache_path' do
  # load the patched module
  VagrantPlugins::Cachier::Cap::Linux::ChefFileCachePath
end

      

0


source







All Articles