require 'spec_helper' describe Hawkei::Config do subject(:config) { Hawkei::Config.new(params) } describe '#initialize' do let(:params) {{ api_key: 'acc_xx', space_name: 'Hawkei', environment_name: 'test' }} it { expect(config.valid!).to be_truthy } %i[api_key environment_name api_host api_version].each do |field| context "validate #{field}" do let(:params) { { api_key: 'acc_xx', space_name: 'Hawkei', environment_name: 'test', api_host: 'host', api_version: 'v1', }.merge(field => '') } it { expect { config.valid! }.to raise_error(Hawkei::ConfigurationError, "#{field} can't be blank") } end end context 'format obfuscated_fields' do let(:params) {{ api_key: 'acc_xx', space_name: 'Hawkei', environment_name: 'test', obfuscated_fields: %i[another_password password_confirmation] }} before { config.valid! } it { expect(config.obfuscated_fields).to match_array(%w[another_password password_confirmation password access_token api_key authenticity_token ccv credit_card_number cvv secret secret_token token]) } end end end