我在Airborne Ruby中测试样本api时遇到了错误。
Airborne :: InvalidJsonError:Api请求返回无效的json /Users/balamurugan/.rvm/gems/ruby-2.4.0/gems/airborne-0.2.13/lib/airborne/base.rb:73:in 在json_body救援 /Users/balamurugan/.rvm/gems/ruby-2.4.0/gems/airborne-0.2.13/lib/airborne/base.rb:73:in json_body /Users/balamurugan/.rvm/gems/ruby-2.4.0/gems/airborne-0.2.13/lib/airborne/request_expectations.rb:139:in call_with_path /Users/balamurugan/.rvm/gems/ruby-2.4.0/gems/airborne-0.2.13/lib/airborne/request_expectations.rb:18:in expect_json ./postapinew_spec.rb:16:in block(2 levels)在'
-e:1:在'load'
-e:1:在''
---引起:---
JSON :: ParserError:765:'/ Users/balamurugan/.rvm/gems/ruby-2.4.0/gems/json-2.1.0/lib/json/common.rb:156:in中的意外标记 `解析'
require 'rspec'
require 'airborne'
require 'json'
describe 'postapivalidation' do
it 'should validate post api' do
post 'http://localhost:9997/test',
{ 'Content-Type' => 'application/json' , 'Accept' => 'application/json' },
{ 'params' => {'param1' => 'value1' , 'param2' => 'value2' } }
expect_status 200
expect_json(name: 'Alex')
end
end
问题是'except_json
'相关方法不适用于发布 API 。但是我得到了有效的'except_json
'结果来获得api。
如何解决这个问题?