Skip to content

Commit

Permalink
revert PR 35 (#42)
Browse files Browse the repository at this point in the history
Revert changes made in #35.

Fixes #36. A key arg will no longer satisfy a contract specifying keyrest args.
  • Loading branch information
cosimaradu authored Apr 12, 2024
1 parent ee8d43e commit 4941616
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 1 addition & 1 deletion lib/sinject/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def validate_contract(dependency_class, contract_class)
def match?(contract, dependency)
return true if contract[:type] == dependency[:type]
return true if contract[:type] == :req && dependency[:type] == :opt
return true if [:keyreq, :keyrest].include?(contract[:type]) && dependency[:type] == :key
return true if contract[:type] == :keyreq && dependency[:type] == :key

false
end
Expand Down
3 changes: 0 additions & 3 deletions spec/sinject/container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,6 @@ def with_kwrest_args(foo, bar:, kwargs:); end

context 'and the class specifies an optional keyword param of the same name' do
it 'raises DependencyContractInvalidParametersException' do
pending('Bug: If the contract specifies keyrest params, '\
'the class should pass validation only if it also specifies keyrest args')

klass = Class.new do
def with_kwrest_args(foo, bar:, kwargs: nil); end
end
Expand Down

0 comments on commit 4941616

Please sign in to comment.