存根请求的转义字符

时间:2018-09-20 11:19:35

标签: ruby rspec

我想为20个XML POST请求创建存根请求。 XML标记中只有数据不同。我尝试过:

stub_request(:post, /.*/).
         with(:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
          <payment_transaction>\n  
            <transaction_type>/.*/</transaction_type>\n  
            <transaction_id>/.*/</transaction_id>\n  
            <usage>/.*/</usage>\n  
            <remote_ip>/.*/</remote_ip>\n  
            <return_success_url>/.*/</return_success_url>\n  
            <return_failure_url>/.*/</return_failure_url>\n  
            <amount>/.*/</amount>\n  
            <currency>/.*/</currency>\n  
            <consumer_reference>/.*/</consumer_reference>\n  
            <national_id>/.*/</national_id>\n  
            <customer_email>/.*/</customer_email>\n  
            <customer_phone>/.*/</customer_phone>\n  
            <billing_address>\n    
              <first_name>/.*/</first_name>\n    
              <last_name>/.*/</last_name>\n    
              <address1>/.*/</address1>\n    
              <zip_code>/.*/</zip_code>\n    
              <city>/.*/</city>    \n    
              <country>/.*/</country>\n    
              <state/>\n  
            </billing_address>\n  
            <shipping_address>\n    
              <first_name>/.*/</first_name>\n    
              <last_name>/.*/</last_name>\n    
              <address1>/.*/</address1>\n    
              <zip_code>/.*/</zip_code>\n    
              <city>/.*/</city>\n    
              <country>/.*/</country>\n    
              <state/>\n  
            </shipping_address>\n
          </payment_transaction>\n")
         .to_return(status: 200, body: successful_response_file)
      end

您知道我需要为/.*/设置转义字符吗?当前,任何存根请求都未注册。您能推荐什么?

0 个答案:

没有答案