1

我正在创建一个应用程序,我使用继承的资源控制器,如上面的:

class MyResourceController < InheritedResource::Base
  respond_to :xml
  action :create
end

在我的黄瓜测试中,顺便说一下,我使用的是水豚,我在上面写了一个步骤定义:

Given 'Sending a step definition' do
  page.driver.post(
    "/path_to_resource.xml",
<<EOF
<resource>
  <attr1>value1</attr1>
  <attr2>value2</attr2>
</resource>
EOF 
  page.status_code.should == 201
end

但是当测试运行时,我检查了我得到的测试日志:

Started POST "/resource.xml" for 127.0.0.1 at 2011-10-26 22:03:45 -0300
Processing by MyResourceController#create as XML
AREL (0.2ms)  INSERT INTO "resource" ("created_at", "updated_at", "attr1", "attr2") VALUES ('2011-10-27 01:03:45.763663', '2011-10-27 01:03:45.763663', NULL, NULL)
Completed 201 Created in 96ms (Views: 32.5ms | ActiveRecord: 0.0ms)

不幸的是,自上周以来,我一直在尝试解决这个问题,但没有成功。所以我的问题是:我是用错误的参数调用 capybara 帖子还是将错误的 xml 发布到控制器?

4

0 回答 0