-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Query::Arguments) to_h unwraps Arguments recursively
- Loading branch information
Showing
2 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
require "spec_helper" | ||
|
||
describe GraphQL::Query::Arguments do | ||
let(:arguments) { GraphQL::Query::Arguments.new({ a: 1, b: 2 }) } | ||
let(:arguments) { GraphQL::Query::Arguments.new({ a: 1, b: 2, c: GraphQL::Query::Arguments.new({ d: 3, e: 4}) }) } | ||
|
||
it 'returns keys as strings' do | ||
assert_equal(['a', 'b'], arguments.keys) | ||
assert_equal(['a', 'b', 'c'], arguments.keys) | ||
end | ||
|
||
it 'delegates values to values hash' do | ||
assert_equal([1, 2], arguments.values) | ||
assert_equal([1, 2, {'d' => 3, 'e' => 4}], arguments.values) | ||
end | ||
|
||
it 'delegates each to values hash' do | ||
pairs = [] | ||
arguments.each do |key, value| | ||
pairs << [key, value] | ||
end | ||
assert_equal([['a', 1], ['b', 2]], pairs) | ||
assert_equal([['a', 1], ['b', 2], ['c', {'d' => 3, 'e' => 4}]], pairs) | ||
end | ||
|
||
it 'returns original Ruby hash values with to_h' do | ||
assert_equal({ a: 1, b: 2 }, arguments.to_h) | ||
assert_equal({ a: 1, b: 2, c: { d: 3, e: 4 } }, arguments.to_h) | ||
end | ||
end |