Skip to content

Commit

Permalink
Update pedicel to use ruby 2.7 (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: Bror Winther <[email protected]>
  • Loading branch information
brorbw and Bror Winther authored Sep 8, 2022
1 parent 72f759b commit 7671706
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
ruby: [2.5]
ruby: [2.7]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
Expand Down
2 changes: 2 additions & 0 deletions lib/pedicel/ec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Pedicel
class EC < Base
def ephemeral_public_key
@token[:header].transform_keys!(&:to_sym)

Base64.decode64(@token[:header][:ephemeralPublicKey])
end

Expand Down
313 changes: 225 additions & 88 deletions lib/pedicel/validator.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/pedicel/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Pedicel
VERSION = '0.1.0'.freeze
VERSION = '1.0.0'.freeze
end
7 changes: 5 additions & 2 deletions pedicel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ Gem::Specification.new do |s|

s.files = Dir.glob("lib/**/*.rb")

s.add_runtime_dependency 'dry-validation', '~> 0.11.1'
s.add_runtime_dependency 'dry-validation', '1.8'
s.add_runtime_dependency 'dry-schema', '~> 1.9'
s.add_runtime_dependency 'dry-logic', '~> 1.0'

s.required_ruby_version = '~> 2.5.5'
s.required_ruby_version = '~> 2.7.4'

s.add_development_dependency 'rake', '~> 12.3'
s.add_development_dependency 'rspec', '~> 3.7'
s.add_development_dependency 'pedicel-pay', '~> 0.0'
s.add_development_dependency 'pry', '~> 0.0'
end
34 changes: 12 additions & 22 deletions spec/expectations/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

failure_message do |actual|
<<~EOM
#{actual}
expected that the given hash satisfy the schema, but:
#{@check.messages}
#{@check.errors.to_h}
EOM
end
end
Expand All @@ -19,32 +20,21 @@
check = expected.call(actual)

@mismatches = mismatches
@errors = check.errors

@errors = check.errors.to_h

return false if check.success?

return true unless mismatches

return false unless check.errors.keys.sort == mismatches.keys.sort

check.errors.sort.zip(mismatches.sort).each do |error, mismatch|
# Check key
return false unless error.first == mismatch.first

# Check messages
next unless mismatch.last.is_a?(Array)
return false if error.last.length > mismatch.last.length

error.last.zip(mismatch.last).each do |error_message, mismatch_message|
case mismatch_message
when String
return false unless error_message == mismatch_message
when Regexp
return false unless error_message =~ mismatch_message
else
fail "unknown match type for '#{mismatch_message}'"
end
end
return false unless @errors.keys.include? mismatches.keys.first

@errors.values.each do |error|
return false unless mismatches.values.include? error
end

mismatches.values.each do |mismatch|
return false unless @errors.values.include? mismatch
end

true
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pedicel/validator/errors_formatted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def validator(data)

expect(validator(invalid_data).errors_formatted).to eq [
'transactionAmount must be an integer',
'when paymentDataType is 3DSecure, onlinePaymentCryptogram must be filled'
]
'paymentDataType when paymentDataType is 3DSecure, onlinePaymentCryptogram must be filled'
].sort
end
end
259 changes: 0 additions & 259 deletions spec/lib/pedicel/validator/predicates_spec.rb

This file was deleted.

Loading

0 comments on commit 7671706

Please sign in to comment.