File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed
Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,13 @@ def self.deep_to_hash(object)
2121 if object . is_a? ( Array )
2222 object . map { |item | deep_to_hash ( item ) }
2323 elsif object . is_a? ( Hash )
24- object .
25- transform_keys { |k | camelize ( k ) } .
26- transform_values { |v | deep_to_hash ( v ) }
24+ object . transform_keys ( &:to_sym ) . transform_values { |v | deep_to_hash ( v ) }
2725 elsif object . instance_variables . empty?
2826 object
2927 else
3028 object . instance_variables . each_with_object ( { } ) do |var , hash |
3129 value = object . instance_variable_get ( var )
32- key = camelize ( var . to_s . delete ( '@' ) ) . to_sym
30+ key = var . to_s . delete ( '@' ) . to_sym
3331 hash [ key ] = deep_to_hash ( value )
3432 end
3533 end
Original file line number Diff line number Diff line change 231231 it "doesn't require bearer token" do
232232 stub_request ( :post , "https://api.line.me/v2/oauth/accessToken" )
233233 . with (
234- body : { "clientId" => "test-client-id" , "clientSecret" => "test-client-secret" , "grantType" => "client_credentials" }
234+ body : { client_id : "test-client-id" , client_secret : "test-client-secret" , grant_type : "client_credentials" }
235235 )
236236 . to_return ( status : response_code , body : response_body , headers : { 'Content-Type' => 'application/json' } )
237237
Original file line number Diff line number Diff line change @@ -71,9 +71,9 @@ def initialize(name)
7171 end
7272
7373 describe '.deep_to_hash' do
74- it 'converts an object with instance variables to a hash with camelCase keys ' do
74+ it 'converts an object with instance variables to a hash' do
7575 input = TestObject . new ( 'John' , 'Doe' )
76- expected_output = { firstName : 'John' , lastName : 'Doe' }
76+ expected_output = { first_name : 'John' , last_name : 'Doe' }
7777 expect ( Line ::Bot ::V2 ::Utils . deep_to_hash ( input ) ) . to eq ( expected_output )
7878 end
7979
You can’t perform that action at this time.
0 commit comments