Sha256: 4af12b7ca7c75b3e4512660b93b33e1107bd3a93bef2542792786e0d6e6a683d

Contents?: true

Size: 769 Bytes

Versions: 7

Compression:

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

7 entries across 7 versions & 1 rubygems

Version Path
brightbox-cli-1.2.2 spec/support/config_helpers.rb
brightbox-cli-1.2.1 spec/support/config_helpers.rb
brightbox-cli-1.2.0 spec/support/config_helpers.rb
brightbox-cli-1.1.0 spec/support/config_helpers.rb
brightbox-cli-1.0.0 spec/support/config_helpers.rb
brightbox-cli-1.0.0.rc2 spec/support/config_helpers.rb
brightbox-cli-1.0.0.rc1 spec/support/config_helpers.rb