Building hash from xml, error in rspec test



I've been trying for some time now to build hash from xml response, but i keep getting this error




Failure/Error: expect(Hash.from_xml(resp_body)).to eq({
SyntaxError:
~/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rexml/functions.rb:393:


syntax error, unexpected keyword_end, expecting end-of-input



response.body is


"<?xml version=\"1.0\" encoding=\"UTF-8\"?><response> <txn_id>123</txn_id> <result>0</result> <comment>OK</comment> <filial>1</filial> <prv_txn type=\"integer\">1</prv_txn></response>"


rspec itself:



require 'rails_helper'

require 'active_support/core_ext/hash/conversions'

describe TestController do

it 'should invoke pay_action' do

do_pay_request

resp_body = response.body.gsub /\n/, ''

expect(Hash.from_xml(resp_body)).to eq({

response: {

txn_id: '123456789101',

prv_txn: '111',

result: '0',

comment: 'OK',

filial: '1'

}.stringify_keys

}.stringify_keys)



end


end



I'm using rvm with ruby ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]


No comments:

Post a Comment