-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi there,
I stumbled upon this issue while developing some specs for my project. I wanted to mock a HalClient::Representation by providing the parsed_json option to the constructor.
If the parsed_json hash keys are symbols instead of strings, things don't work quite like they should.
I'll leave a sample interaction for you to validate if this is something you'd like to see patched or not. Let me know !
[6] pry(main)> json = {
:plan => {
:id => "fake_plan_id",
:name =>"Awesome Name",
:amount => 0
},
:counter => 250
}
=> {:plan=>{:id=>"fake_plan_id", :name=>"Awesome Name", :amount=>0}, :counter=>250}
[7] pry(main)> resp = HalClient::Representation.new(parsed_json: json)
=> #<HalClient::Representation:0x75d402d4 @hal_client=nil, @href=nil, @raw={:plan=>{:id=>"fake_plan_id", :name=>"Awesome Name", :amount=>0}, :counter=>250}>
[8] pry(main)> resp.property(:plan)
KeyError: key not found: :plan
[9] pry(main)> resp.property('plan')
KeyError: key not found: :plan
[10] pry(main)> json = {
'plan' => {
'id' => "fake_plan_id",
'name' => "Awesome Name",
'amount' => 0
},
'counter' => 250
}
=> {"plan"=>{"id"=>"fake_plan_id", "name"=>"Awesome Name", "amount"=>0}, "counter"=>250}
[11] pry(main)> resp = HalClient::Representation.new(parsed_json: json)
=> #<HalClient::Representation:0x3d42b756 @hal_client=nil, @href=nil, @raw={"plan"=>{"id"=>"fake_plan_id", "name"=>"Awesome Name", "amount"=>0}, "counter"=>250}>
[12] pry(main)> resp.property('plan')
=> {"id"=>"fake_plan_id", "name"=>"Awesome Name", "amount"=>0}
[13] pry(main)> resp.property(:plan)
=> {"id"=>"fake_plan_id", "name"=>"Awesome Name", "amount"=>0}ivoanjo and masterpass78
Metadata
Metadata
Assignees
Labels
No labels