- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我的测试有问题。
我有这个规范:
context 'when no section is supplied' do
it 'raises an ArgumentError regarding the missing section_id argument' do
expect do
described_class.with_section
end.to raise_error(ArgumentError)
.with_message /wrong number of arguments \(given 0\, expected 1\)/
end
end
在某些环境中,消息是:
ArgumentError: wrong number of arguments (0 for 1)
在其他环境中,消息是:
ArgumentError: wrong number of arguments (given 0, expected 1)
所以我有一个测试在我的 Mac 上通过但在另一台计算机上失败。
我该如何解决这个问题?
最佳答案
差异似乎是由于运行测试的 Ruby 版本所致。 Ruby 2.2 和更早的版本使用类似
的消息报告此错误"ArgumentError: wrong number of arguments (0 for 1)"
Ruby 2.3 报告此错误的消息如下
"ArgumentError: wrong number of arguments (given 0, expected 1)"
(这更容易理解)。
对于大多数应用程序来说,解决此问题的正确方法是在您开发和/或部署程序的所有机器上运行相同版本的 Ruby。让一个应用程序在多个主要版本的 Ruby 上运行意味着在这些版本上测试它,这意味着在每台开发人员机器上都有所有支持的版本,这比在一个版本上解决更多的工作。这也意味着放弃新版本 Ruby 中的好东西。
如果你确实需要你的程序兼容多个版本的Ruby,你可以测试RUBY_VERSION
常量:
context 'when no section is supplied' do
it 'raises an ArgumentError regarding the missing section_id argument' do
message = RUBY_VERSION.start_with? '2.3' \
? "wrong number of arguments (given 0, expected 1)" \
: "wrong number of arguments (0 for 1)"
expect { described_class.with_section }.to raise_error(ArgumentError).
with_message /#{Regexp.escape message}/
end
end
关于ruby - "wrong number of arguments"错误的 RSpec 测试在某些环境中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35872676/
这个问题在这里已经有了答案: java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped t
我无法让我的 WebRTC 代码正常工作。我相信我所做的一切都是正确的,但它仍然无法正常工作。为什么 ontrack 这么早就被调用有些奇怪,也许它应该是那样的。 该网站使用 javascript 代
使用 Mac OSX 优胜美地 (10.10.4): rails -v => Rails 4.2.3 ruby -v => ruby 2.2.2p95 遵循这些说明的组合: https://www
您好,我正在尝试使用(缓存的)已编译的 lambda 表达式来访问属性,与使用 PropertyInfo.GetValue()/SetValue() 方法调用相比,我确实得到了更好(即更快)的结果。然
我编写此代码是为了获取学生的字母成绩并计算他们的 GPA。当我运行该程序时,我可以正确获取学生的姓名和科目,但无法显示成绩或 GPA。 示例输入: Sally 1 A N 示例输出: Enter St
我一直在编写这段代码,根据这本书应该可以做到这一点: Write a script that creates and calls a stored procedure named test. This
我真的很难创建一个具有以下基本格式的有效多维 JavaScript 数组: var countries = [ { "country": "UK", "properties": {
我有一个小型 Python OOP 程序,其中 2 个类 Flan 和 Outil 继承自父类(super class) Part。 我的问题是,当我调用 Flan 时一切正常,但是当我调用 Outi
我目前正在尝试使用通用监听器来编写事件系统。 所有监听器都应添加到单个 EventSource 对象,该对象将为特定事件调用其 receiveEvent() 方法。 事件源: public class
我正在通过我的 PHP 应用程序发送电子邮件。但是,它们被 Gmail 标记为垃圾邮件。这是我发送电子邮件的方式(PHP): $headers = "From: test@bookmytakeout.
我已经正式走到了穷途末路的地步。我找不到我做错了什么。我完成的这个程序几乎与我几天前编写的另一个程序一模一样,但我在编译时遇到了问题。我不知道为什么输出线上出现错误。请帮忙: 这是正在运行的文件: p
---编辑:我不允许使用任何包或预置方法。不用担心,我不想让你做我的“作业”,我只需要一点提示!---我发现these interesting Algorithms 。我想使用按位添加方法。我的问题是
我制作了一个小程序,尝试使用 conn.getOutputStream(); 检索 URLConnection 对象输出流。当我尝试执行此操作时,我的小程序抛出异常 java.net.UnknownS
每当我尝试在 SVN 中合并时,我都会遇到成堆的树冲突。好吧,就此示例脚本而言,只有一个,但仍然如此。 #!/bin/bash svnadmin create repo svn checkout fi
我开始为 Scala 中的 X500PrincipalBuilder 类编写单元测试。这是我的测试代码: import org.junit.runner.RunWith import org.scal
我正在用 python 编写我的第一个程序,它必须模拟粒子(两种气体)的混合。我不知道我这个功能做错了什么。我不希望颗粒离开某些区域,即容器的壁。我使用 VPython。 def poruszanie
我正在尝试求解三角方程组,但我认为 Python 没有生成正确的解。我试图解决的方程: 1 − 2cosθ1 + 2cosθ2 − 2cosθ3 = −0.8 1 − 2cos5θ1 + 2cos5θ
这个问题已经有答案了: TypeError: worker() takes 0 positional arguments but 1 was given [duplicate] (11 个回答) 已关
大家好,我正在努力解决这个问题 编写一个 C 程序,计算弹丸在撞击地面之前行进的距离(即射程)、弹丸撞击地面所需的时间以及弹丸飞行中的最大高度(给定角度)它被射向空中,以及发射时的初始速度(速度)。我
我编写了代码来计算 QuickSort 中完成的比较次数。 每当对长度为 m 的数组执行快速排序时,该算法都会将比较次数增加 m-1(因为主元将与除自身以外的所有内容进行比较)。 枢轴的选择始终是数组
我是一名优秀的程序员,十分优秀!