Sha256: ac0ec2682a63c7c344326b97a8c01c02fc0905d767f954573b50d08e845cdc5c

Contents?: true

Size: 959 Bytes

Versions: 3

Compression:

Stored size: 959 Bytes

Contents

module EverythingAsExpected

  def credentials
    unless File.exist? 'credentials.json'
      raise "Please add a credentials.json file to the project directory containing your Imgur app_key, app_secret, access_token and access_token_secret. See credentials.json.example to get started."
    end

    credentials_file_contents = File.open('credentials.json', 'r').read
    credentials_hash = JSON.parse(credentials_file_contents)
    if credentials_hash.keys.count != 4 and credentials_hash.keys & [:app_key, :app_secret, :access_token, :access_token_secret] != [:app_key, :app_secret, :access_token, :access_token_secret]
      raise "Your credentials.json file does contain all the required information. See credentials.json.example for more help."
    end

    credentials_hash.inject({}) do |options, (key, value)|
      options[key.to_sym] = value
      options
    end
  end

end

RSpec.configure do |config|
  config.include(EverythingAsExpected)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
imgurapi-3.2.2 spec/spec_helper.rb
imgurapi-3.2.1 spec/spec_helper.rb
imgurapi-3.1.0 spec/spec_helper.rb