如何编写SOAP请求的模型测试

时间:2015-09-20 11:25:46

标签: ruby-on-rails ruby unit-testing ruby-on-rails-4 soap

我已经编写了一种模型方法,可以使用欧盟的VIES系统(How to use SOAP service with xml in Rails (EU VAT number check))检查增值税号码的有效性。这在开发中有效。

现在我尝试编写model test来查看模型方法是否能够从该系统获得响应:

test "test check_valid" do
  @organization.number = "TESTVATNUMBER"    # In def setup, @organization receives all the other relevant variables
  @organization.save
  @organization.check_vat # Calls upon the model method
  assert ???              # How to test that the previous line/method has indeed returned the value 'false' to the controller?
end

如何完成此测试?也就是说,如何测试check_vat是否正常工作并返回值' false'到控制器方法?

以下这些尝试产生了错误undefined method 'assert_response' for #<OrganizationTest:0x00000007686918>

@organization.check_validity_vat_nr
assert_response :success

assert_response 'false' do
  @organization.check_validity_vat_nr
end

0 个答案:

没有答案