Sha256: 5f555ddd002a5c80b692c1bbee951b5147bece8532e0167a596521fcf49aeaf7

Contents?: true

Size: 862 Bytes

Versions: 28

Compression:

Stored size: 862 Bytes

Contents

require "fileutils"
require "securerandom"

module ConfigHelpers
  # Returns a Brightbox::BBConfig based on the String as its contents
  #
  # It's like a fake configuration - IN A CAN!
  #
  def config_from_contents(contents)
    # Create it (with a non existing file)
    config = Brightbox::BBConfig.new

    # Load the contents into the expected location
    FileUtils.mkdir_p config.config_directory
    File.open(config.config_filename, "w") do |f|
      f.write contents
    end

    config = Brightbox::BBConfig.new

    # Subvert the global
    Brightbox.config = config

    config
  end

  def remove_config
    config = Brightbox::BBConfig.new
    FileUtils.rm_rf config.config_filename
  end

  # Returns the file contents of a config
  #
  def config_file_contents
    config = Brightbox::BBConfig.new
    IO.read(config.config_filename)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 spec/support/config_helpers.rb
brightbox-cli-3.2.0 spec/support/config_helpers.rb
brightbox-cli-3.1.0 spec/support/config_helpers.rb
brightbox-cli-3.0.1 spec/support/config_helpers.rb
brightbox-cli-3.0.0 spec/support/config_helpers.rb
brightbox-cli-2.12.0 spec/support/config_helpers.rb
brightbox-cli-2.11.2 spec/support/config_helpers.rb
brightbox-cli-2.11.1 spec/support/config_helpers.rb
brightbox-cli-2.11.0 spec/support/config_helpers.rb
brightbox-cli-2.10.0 spec/support/config_helpers.rb
brightbox-cli-2.9.3 spec/support/config_helpers.rb
brightbox-cli-2.9.2 spec/support/config_helpers.rb
brightbox-cli-2.9.1 spec/support/config_helpers.rb
brightbox-cli-2.9.0 spec/support/config_helpers.rb
brightbox-cli-2.8.2 spec/support/config_helpers.rb
brightbox-cli-2.8.1 spec/support/config_helpers.rb
brightbox-cli-2.8.0 spec/support/config_helpers.rb
brightbox-cli-2.7.1 spec/support/config_helpers.rb
brightbox-cli-2.7.0 spec/support/config_helpers.rb
brightbox-cli-2.6.0 spec/support/config_helpers.rb