如何在Integration test中将XML文件作为参数传递?

时间:2011-05-18 06:09:16

标签: ruby-on-rails testing integration-testing functional-testing

我在rails中编写集成测试,因为我必须将XML文件作为参数传递,我尝试了以下方式

 test "integration" do
    @controller = ApiController.new
    file = "xxx/yyy.xml"
    post "register_user",file
    assert_true "something", @response.body
 end

但显示如下错误,

NoMethodError:未定义的方法`symbolize_keys'代表“/xxx/yyy.xml":String

任何人请帮帮我......

1 个答案:

答案 0 :(得分:0)

您也可以像这样传递xml:

test "integration" do
    @controller = ApiController.new
    entry = <<-EOF
      <atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
          xmlns:gd='http://schemas.google.com/g/2005'>
      </atom:entry>
    EOF

    url = URI.parse('http://www.example.com/todo.cgi')
    req = Net::HTTP::Post.new(register_user, entry)
 end