草庐IT

javascript - 禁用 Jasmine 期望,例如 xdescribe 或 xit?

全部标签

ruby - 在 Active Admin 中禁用 CSV 下载

我正在使用ActiveAdmingem,我想隐藏或删除每个模型索引页面上的链接,允许用户以CSV、XML或JSON格式下载数据。有什么办法吗? 最佳答案 index方法上现在有一个选项:download_links,因此您可以根据需要省略下载链接。例如:ActiveAdmin.registerPostdoindex:download_links=>falsedo#whateverendend 关于ruby-在ActiveAdmin中禁用CSV下载,我们在StackOverflow上找到一

ruby - 我可以告诉 Ruby 方法期望特定的参数类型吗?

defdoSomething(value)if(value.is_a?(Integer))printvalue*2elseprint"Error:Expectedintegervalue"exitendend我可以告诉Ruby方法某个参数应该是一个整数,否则会崩溃吗?像Java。 最佳答案 不,你不能。您只能做您已经在做的事情:自己检查类型。 关于ruby-我可以告诉Ruby方法期望特定的参数类型吗?,我们在StackOverflow上找到一个类似的问题: h

ruby - Rails 3 的 API 错误自定义,例如 Github api v3

我在Rails3应用程序上添加了一个API,它运行良好。但我在http://developer.github.com/v3/看到了以下Githubapiv3HTTP/1.1422UnprocessableEntityContent-Length:149{"message":"ValidationFailed","errors":[{"resource":"Issue","field":"title","code":"missing_field"}]}我喜欢错误消息结构。但无法让它重现。我怎样才能使我的api做出类似的响应? 最佳答案

ruby-on-rails - 尽管安装了 therubyracer 和 nodejs,但找不到 JavaScript 运行时

我尝试在CentOS5上运行Rails应用程序并不断收到thiserror:CouldnotfindaJavaScriptruntime.Seehttps://github.com/sstephenson/execjsforalistofavailableruntimes.(ExecJS::RuntimeUnavailable)我同时安装了NodeJS(v0.8.15)和therubyracer(libv8)。这是我的gemlist:***LOCALGEMS***actionmailer(3.2.9,3.2.8)actionpack(3.2.9,3.2.8)activemodel(3.

ruby-on-rails - RSpec load_missing_constant,期望 X 定义 Y(确实如此)

当我们运行时bundleexecrake规范尝试加载环境时出现错误:...gems/activesupport-3.2.8/lib/active_support/dependencies.rb:503:in`load_missing_constant':Expected...app/models/links/category.rbtodefineLinks::Category(LoadError)文件app/models/links/Category.rb确实定义了Links::Category。更奇怪的是,在guard和spork下运行时不会发生错误(我们运行测试的标准方式):bun

ruby - 我如何获得 RSpec 的共享示例,例如 Ruby Test::Unit 中的行为?

在RSpecforTest::Unittests中是否有类似于shared_examples的插件/扩展? 最佳答案 如果您正在使用rails(或只是active_support),请使用Concern.require'active_support/concern'moduleSharedTestsextendActiveSupport::Concernincludeddo#Thisway,testnamecanbeastring:)test'bananabananabanana'doasserttrueendendend如果您不使

ruby - 如何禁用来自 ruby​​gems 的安装后消息?

在安装gems之后,我已经厌倦了看到这样愚蠢的消息:Post-installmessagefromhttparty:WhenyouHTTParty,youmustpartyhard!快速浏览RubyGemsGuides我找不到禁用安装后消息的选项。我希望能够在我的~/.gemrc中配置它。 最佳答案 要忽略所有项目中的所有安装后消息:bundleconfig--globalignore_messagestrue文档:ignore_messages(BUNDLE_IGNORE_MESSAGES):Whenset,nopostinsta

ruby-on-rails - Rails 语法错误 : unexpected keyword_ensure, 期望输入结束

我是Rails的新手,我尝试根据教程创建一个论坛应用程序。这是我的论坛页面,但我一直收到错误消息:syntaxerror,unexpectedkeyword_ensure,expectingend-of-inputExtractedsource(aroundline#33):3031这是抛出错误的论坛索引页面:ForumLastPosttopicsagobynoposts-->'Areyousure?',:method=>:delete%> 最佳答案 -->这是在做什么?一个html注释的ERB标签仍然会评估。去掉它。如果您想评论r

ruby-on-rails - RSpec 期望接收带有数组的方法,但顺序无关紧要

假设我有方法#sum,它接受一个数组并计算所有元素的总和。我正在stub:beforedoexpect(calculation_service).toreceive(:sum?).with([1,2,3]){6}end不幸的是,我的测试服以随机顺序传递数组。由于引发了该错误:Failure/Error:subject{do_crazy_stuff!}#received:sum?withunexpectedargumentsexpected:([1,2,3])got:([3,2,1])是否可以忽略数组元素的顺序对方法调用进行stub?array_including(1,2,3)无法确保数

ruby - 期望创建一个新对象

我需要编写一个期望,即在支付系统中创建一个新对象。order.rb和order_spec.rb中包含的代码(Order类是here):#order.rbdefconfirm_order(method_of_payment)ifcredit_card_but_products_out_stock?(method_of_payment)raise"Cannotmakecreditcardpaymentnow,assomeproductsareoutofstock"endorder_totalPayment.new(method_of_payment,self.total)end#order