我们的Griddler模型测试工作正常。例如我们可以实例化lib/email_processor.rb并处理它。 我们希望创建一个控制器测试,以完成标准/ email_processor的结尾。无法模拟Rails 4 Griddler gem测试发布到邮件处理器(post params issue)
问题是参数不通过帖子。我们的基本代码是:
@postattr= {to: "[email protected]", subject: "a subject", attachments: [
ActionDispatch::Http::UploadedFile.new({
filename: 'example_virgin_onetransaction.pdf',
type: 'application/pdf',
tempfile: File.new('testfiles/examplefile.pdf")})
]}
post :create, @postattr
expect(response).to be_success
它的工作原理,因为它发布到正确的路线和得到处理,除了email.attachments对象是零。
我们试图
- @ postattr.to_json#给人无效字节顺序UTF-8
- @ postattr.to_s.to_json#作品,但没有通过PARAMS编码
- 通过URI json字符串
似乎没有得到正确处理。我们错过了什么?