mardi 23 août 2016

Accessing key value pairs in a hash within a hash with Ruby

I'm writing a test against a API XML response that I converted to a hash. The hash however is nested so it seems to behave like "Offer" is the key and everything else is the value. (Shown below)

I would like to be able to access the key-value pairs within this hash so I can assert using rspec tests against "Id", "Count" etc. Thanks

{"Offer"=>
  {"href"=>"http://xyz",
   "links"=>nil,
   "Id"=>"1501507",
   "Count"=>"5",
   "Collected"=>"3",
   "Status"=>"INPROGRESS"}}

Aucun commentaire:

Enregistrer un commentaire