Skip to content

Commit

Permalink
Valvat::Options#check_uk_key: Fixed missing silence variable
Browse files Browse the repository at this point in the history
* Added spec
* Better deprecation warning message
Issue #141
  • Loading branch information
yolk committed Dec 19, 2024
1 parent f27b7f6 commit 0bf6125
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/valvat/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(options, silence: false)
end
end

check_uk_key
check_uk_key(silence)
end

def [](key)
Expand All @@ -32,11 +32,11 @@ def dig(*keys)

private

def check_uk_key
def check_uk_key(silence)
return if @options[:uk] != true || silence

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

Expand Down
11 changes: 11 additions & 0 deletions spec/valvat/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,16 @@
end.to output("DEPRECATED: The option :savon is deprecated. Use :http instead.\n").to_stdout
end
end

context 'when options contains deprecated key uk set to true' do
it 'prints deprecation warning' do
expect do
described_class.new({ uk: true })
end.to output(
'DEPRECATED: The option :uk is not allowed to be set to `true` anymore. ' \
"Instead it needs to be set to your HMRC API authentication credentials.\n"
).to_stdout
end
end
end
end

0 comments on commit 0bf6125

Please sign in to comment.