- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在做一些条纹集成测试,我想 stub /模拟一些端点。我正在尝试这样做:
Stripe::Charge.stubs(:retrieve).returns({:balance_transaction => 40})
但我得到以下信息:
NoMethodError: undefined method `stubs' for Stripe::Charge:Class
stub 的正确语法是什么? Rails 4、Ruby 2。
编辑:这是我的完整测试方法。本质上,我的 payment_succeeded webhook 命中 strip 以检索费用及其相关的余额交易以记录交易费用。我正在使用 stripe_mock 来模拟 webhook 事件,但我宁愿使用标准 stub 技术来 stub 它们的其余部分。请注意,即使我将其更改为“ stub ”,它也会抛出上面相同的错误(用 stub 代替 stub )。
require 'test_helper'
require 'stripe_mock'
class WebhooksTest < ActionDispatch::IntegrationTest
# called before every single test
def setup
StripeMock.start
end
# called after every single test
def teardown
StripeMock.stop
end
test 'invoice.payment_succeeded' do
Stripe::Charge.stubs(:retrieve).returns({:balance_transaction => 40})
event = StripeMock.mock_webhook_event('invoice.payment_succeeded', { :customer => "stripe_customer1", :id => "abc123" })
post '/stripe-events', id: event.id
assert_equal "200", response.code
assert_equal 1, StripeInvoicePayment.count
assert_equal 'abc123', event.data.object.id
end
end
最佳答案
这里唯一对我来说不正确的是.stubs,而它应该是.stub。 .
关于ruby - ActionDispatch::IntegrationTest 中的 stub 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30882575/
我对基本的 Rails 概念(如 ActiveRecord、路由、迁移等)有相当不错的掌握。我很难理解的一件事是 ActionDispatch。我找不到关于它是什么的简单英语描述(或任何描述)。那是什
我有一个与后端 Rails API 交互的前端 React SPA。在生产中,前端有一个域名 mysecretsite.com,而后端与 mysecretsite.io 相关联 我正在使用 Actio
当我上传文件并请求以下参数时: params[:product][:images_attributes]["0"][:image] 它返回: #> 我用来获取 filename 的 ruby 代码
无论我在我的应用程序中遇到什么错误,我都无法在我的日志中看到错误,我得到以下信息关于我面临的所有错误的消息,所以我无法解决我的错误,有人能帮我解决这个问题吗?? Completed 500 Inter
有没有办法将字符串转换成ActionDispatch::Http::UploadedFile 我需要它能够在 API 请求中传递文件路径以处理将 excel 插入数据库,因为我想使用 rest API
我有 Ruby on Rails 3 的东西 我试试这个简单的代码 def index flash[:notice] = "ok" respond_to do |format|
我试图了解 Rails 如何在 /public 下提供静态文件,如果我理解正确,ActionDispatch::Static 中间件负责此操作。 但是,我注意到它只在开发环境中可用: $ rake m
我正在做一些条纹集成测试,我想 stub /模拟一些端点。我正在尝试这样做: Stripe::Charge.stubs(:retrieve).returns({:balance_transaction
NoMethodError:ActionDispatch::Request:Class 的未定义方法“alias_method_chain” 我在安装 wiselinks gem 后遇到这个问题。 R
我目前正在开发一个 ruby on rails 项目。在项目中我有一个输入文件类型(图像)的表单,我需要将图像转换为base64(项目连接到外部api,所以图像需要在base64中) 到目前为止,
我有一个 Rails 应用程序,我正在解析上传的 CSV。我刚刚发现解析已停止工作并正在调查。 我已经追溯到我调用 .read 的事实。在 ActionDispatch::Http::Uploaded
我在 Rails 4.2.1 之上使用 Grape 为我们的应用程序提供 API。 但是当我今天检查 Newrelic 的性能时,我发现 RackApp Proc#call和 Grape API::R
你如何使用 ActionDispatch::Routing::RouteSet 识别路径? 我想获取 View 的当前路径。 我试过 ">但是得到了“ActionDispatch::Routing::
在我的 Controller 中更改并保存了一些代码后,RailsDevTweaks 似乎忽略了这一事实并且不会重新加载代码。在日志中它说: RailsDevTweaks: Skipping Acti
几天前我注意到我的网站上有一些异常事件,所以我决定查看生产日志。这是我发现的: Started GET "/" for 74.219.112.36 at 2013-01-11 20:25:05 +00
我正在尝试在 Rails 4 中编写 Ember 应用程序,并决定使用 rails-api对于 api Controller ,同时为不属于单页应用程序的几个页面保持应用程序 Controller 完
我正在关注GridFS with Mongoid and CarrierWave实现一个简单的 has_many 多态关系,当我尝试通过嵌套属性分配创建一个带有头像的新用户时,我得到: Cannot
我有一个 Ruby on Rails 应用程序,它在模板中包含以下内容... " method="post"> 当我通过 https 请求页面时,我最终得到一个与原始请求具有完全相同 url 的表单操
我正在尝试在我的 Rails 应用程序上实现 git push,它会发送 PROPFIND 请求,而 Rails 似乎无法验证该请求。当我尝试时: git 推送 http://localhost:30
我正在学习 clickatell 教程,我的代码如下所示。但是我得到了错误 uninitialized constant ActionDispatch::Routing::Routes (NameEr
我是一名优秀的程序员,十分优秀!