Sha256: fc2bd8a3d87f7f9f5ead76ecfa66331293627663dee38090e5e79183d04708cd

Contents?: true

Size: 620 Bytes

Versions: 7

Compression:

Stored size: 620 Bytes

Contents

require "fauxhai"
require "omnibus/ohai"

module Omnibus
  module RSpec
    module OhaiHelpers
      #
      # Stub Ohai with the given data.
      #
      def stub_ohai(options = {}, &block)
        ohai = Mash.from_hash(Fauxhai.mock(options, &block).data)
        allow(Ohai).to receive(:ohai).and_return(ohai)

        # If we asked for Windows, we should also specify that magical
        # +File::ALT_SEPARATOR+ variable
        if options[:platform] && options[:platform] == "windows"
          stub_const("File::ALT_SEPARATOR", '\\') # rubocop:disable Style/StringLiterals
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
omnibus-9.0.24 spec/support/ohai_helpers.rb
omnibus-9.0.23 spec/support/ohai_helpers.rb
omnibus-9.0.22 spec/support/ohai_helpers.rb
omnibus-9.0.17 spec/support/ohai_helpers.rb
omnibus-9.0.12 spec/support/ohai_helpers.rb
omnibus-9.0.11 spec/support/ohai_helpers.rb
omnibus-9.0.8 spec/support/ohai_helpers.rb