我想从 minitest 将 xml 发布到控制器。
它在正常模式下的工作方式是这样的:
curl -X POST -H "Content-Type: text/xml" -d "@/Users/boti/Rails/clients/kevin/search_server/db/search.xml" localhost:3000/search
我尝试这样做:
test "search with invalid xml" do
path_to_file = File.join Rails.root.to_s, 'test', 'search_invalid.xml'
xml = File.read( path_to_file )
@request.env['RAW_POST_DATA'] = xml
post "/search/search", xml, {"Content-type" => "text/xml"}
但是这样我得到了这个例外:
NoMethodError: undefined method `symbolize_keys' for #<String:0x007fbd7d863188>