Skip to content

Commit 0bf6125

Browse files
committed
Valvat::Options#check_uk_key: Fixed missing silence variable
* Added spec * Better deprecation warning message Issue #141
1 parent f27b7f6 commit 0bf6125

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/valvat/options.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(options, silence: false)
1919
end
2020
end
2121

22-
check_uk_key
22+
check_uk_key(silence)
2323
end
2424

2525
def [](key)
@@ -32,11 +32,11 @@ def dig(*keys)
3232

3333
private
3434

35-
def check_uk_key
35+
def check_uk_key(silence)
3636
return if @options[:uk] != true || silence
3737

3838
puts 'DEPRECATED: The option :uk is not allowed to be set to `true` anymore. ' \
39-
'Using the HMRC API requires authentication credentials.'
39+
'Instead it needs to be set to your HMRC API authentication credentials.'
4040
end
4141
end
4242

spec/valvat/options_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,16 @@
4646
end.to output("DEPRECATED: The option :savon is deprecated. Use :http instead.\n").to_stdout
4747
end
4848
end
49+
50+
context 'when options contains deprecated key uk set to true' do
51+
it 'prints deprecation warning' do
52+
expect do
53+
described_class.new({ uk: true })
54+
end.to output(
55+
'DEPRECATED: The option :uk is not allowed to be set to `true` anymore. ' \
56+
"Instead it needs to be set to your HMRC API authentication credentials.\n"
57+
).to_stdout
58+
end
59+
end
4960
end
5061
end

0 commit comments

Comments
 (0)