Sha256: 5e28fd28147363463d8ef1710e4f1e809f361aece5d6d6ed4c088ef4da23e0e7

Contents?: true

Size: 1 KB

Versions: 12

Compression:

Stored size: 1 KB

Contents

require "tmpdir"

module IntegrationSupport
  def when_plugins_directory(description, &block)
    context "When the plugins directory #{description}" do

      before(:each) do
        @plugins_directory = Dir.mktmpdir("ohai-plugins")
      end

      after(:each) do
        if @plugins_directory
          begin
            FileUtils.remove_entry_secure(@plugins_directory)
          ensure
            @plugins_directory = nil
          end
        end
      end

      def with_plugin(plugin_path, contents)
        filename = path_to(plugin_path)
        dir = File.dirname(filename)
        FileUtils.mkdir_p(dir) unless dir == "."
        File.open(filename, "w") do |file|
          file.write(contents)
        end
      end

      def path_to(plugin_path)
        File.expand_path(plugin_path, @plugins_directory)
      end

      def self.with_plugin(plugin_path, contents)
        before :each do
          with_plugin(plugin_path, contents)
        end
      end

      instance_eval(&block)
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ohai-8.19.2 spec/support/integration_helper.rb
ohai-8.19.0 spec/support/integration_helper.rb
ohai-8.18.0 spec/support/integration_helper.rb
ohai-8.17.1 spec/support/integration_helper.rb
ohai-8.17.0 spec/support/integration_helper.rb
ohai-8.16.0 spec/support/integration_helper.rb
ohai-8.15.0 spec/support/integration_helper.rb
ohai-8.14.0 spec/support/integration_helper.rb
ohai-8.13.0 spec/support/integration_helper.rb
ohai-8.12.1 spec/support/integration_helper.rb
ohai-8.12.0 spec/support/integration_helper.rb
ohai-8.11.1 spec/support/integration_helper.rb