Sha256: 67aaddbdb37067fcb8fb9d4c8a2fea7c78d883232de47a71f892797cb229282e

Contents?: true

Size: 1.01 KB

Versions: 36

Compression:

Stored size: 1.01 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

36 entries across 36 versions & 1 rubygems

Version Path
ohai-8.10.0 spec/support/integration_helper.rb
ohai-8.9.0 spec/support/integration_helper.rb
ohai-8.8.1 spec/support/integration_helper.rb
ohai-8.8.0 spec/support/integration_helper.rb
ohai-8.7.0 spec/support/integration_helper.rb
ohai-8.6.0 spec/support/integration_helper.rb
ohai-8.6.0.alpha.1 spec/support/integration_helper.rb
ohai-8.6.0.alpha.0 spec/support/integration_helper.rb
ohai-8.5.0 spec/support/integration_helper.rb
ohai-8.4.0 spec/support/integration_helper.rb
ohai-8.3.0 spec/support/integration_helper.rb
ohai-8.3.0.rc.0 spec/support/integration_helper.rb
ohai-8.2.0 spec/support/integration_helper.rb
ohai-8.1.1 spec/support/integration_helper.rb
ohai-8.1.0 spec/support/integration_helper.rb
ohai-7.4.1 spec/support/integration_helper.rb
ohai-8.0.1 spec/support/integration_helper.rb
ohai-7.6.0.rc.1 spec/support/integration_helper.rb
ohai-7.6.0.rc.0 spec/support/integration_helper.rb
ohai-7.4.0 spec/support/integration_helper.rb