Sha256: ad4d651d44a1bcab5145b09abc16fe5a461328b9bcd7a770cbc107dfccb4fa26
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true RSpec.describe SoapyBing::ParamGuard do describe '#require!' do let(:param_guard) { described_class.new(options, env_namespace: 'MY') } subject { param_guard.require!(:foo) } context 'when option is empty' do let(:options) { {} } context 'and environment variable is empty too' do it 'thows exception' do expect { subject }.to raise_exception SoapyBing::ParamGuard::ParamRequiredError, 'foo have to be passed explicitly or via ENV[\'MY_FOO\']' end end context 'but environment variable is present' do before { allow(ENV).to receive(:[]).with('MY_FOO').and_return('bar_env') } it 'returns environment variable value' do expect(subject).to eq 'bar_env' end end end context 'when option is present' do let(:options) { { foo: 'bar' } } context 'and environment variable is present too' do before { allow(ENV).to receive(:[]).with('MY_FOO').and_return('bar_env') } it 'returns option value' do expect(subject).to eq 'bar' end end context 'but environment variable is empty' do it 'returns option value' do expect(subject).to eq 'bar' end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
soapy_bing-0.1.0 | spec/soapy_bing/param_guard_spec.rb |
soapy_bing-0.0.5 | spec/soapy_bing/param_guard_spec.rb |