Reputation: 4895
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]
Upvotes: 0
Views: 207
Reputation: 4895
I solved this error by adding gem 'rubysl-rexml', '~> 2.0.2'
to my gemfile
Upvotes: 0