草庐IT

throw_logic_error

全部标签

ruby-on-rails - Rspec raise_error 测试失败,即使该方法引发错误

我的测试是这样的:它“在通过非订阅或试用成员(member)资格时确实返回错误”期望(helper.description_for_subscription(recurring_plan)).toraise_error(RuntimeError)结束我的方法返回这个:失败“未知订阅模型类型!”然而Rspec返回此失败消息:失败/错误:expect(helper.description_for_subscription(recurring_plan)).toraise_error(RuntimeError)运行时错误:未知的订阅模型类型!这是怎么回事?? 最佳

ruby - 你如何断言另一个 ruby​​ 模块的异常被抛出? (使用 assert_throws)

我正在尝试编写这样的代码:assert_throws(:ExtractionFailed){unit.extract_from('5x2005')}ExtractionFailed是Exception的一个简单子(monad)类,在test/unit下,我试图断言它在我调用unit.extract_from(...坏数据...)我已经将ExtractionFailed移动到SemanticText模块中,所以现在test/unit说:expectedtobethrownbutwasthrown.我尝试编写assert_throws(:SemanticText::ExtractionFa

ruby-on-rails - 目录 : template missing error while rendering JSON

我的Controller中有以下代码:deftljson(result=[])@stat_id=params[:stat_id]@rpm=FedoraRpm.find_by_name(@stat_id)@rpm.ruby_gem.historical_gems.each{|h|resulth.version,:start=>h.build_date}}@rpm.bugs.each{|b|resultb.name+"ViewonBugZilla",:start=>b.bz_id}}@res=result.to_jsonrespond_todo|format|format.json{ren

ruby-on-rails - Faraday::ConnectionFailed,Connection refused - connect(2) for “localhost” port 9200 Error Ruby on Rails

我正在尝试使用RubyonRails在我的应用程序中添加Searchkickgem,但是当我在搜索框中键入一个词时,我的应用程序中出现此错误。我已经根据需要安装了elasticsearch和最新版本的java,但错误仍然是一样的。这是我得到的错误:Faraday::ConnectionFailedinPostsController#searchConnectionrefused-connect(2)for"localhost"port9200这是我的代码:终端显示已安装Elasticsearch:终端Warning:elasticsearch-1.7.3alreadyinstalled

ruby-on-rails - capybara 错误:Selenium::WebDriver::Error::ElementNotVisibleError:元素不可见

我正在使用TrixWYSIWYGeditor在我的应用程序中。对于我的capybara测试:我要填写编辑器。我找到了这篇文章:Howtotestbasecamp'stripeditor...这似乎很有希望。不幸的是,它一直给我这个错误:Selenium::WebDriver::Error::ElementNotVisibleError:elementnotvisible所以看起来Capybara发现元素没问题,但它只是没有与之交互,因为Capybara必须有一些默认设置才能不与隐藏/不可见元素交互。环顾四周后,我发现了这个Stackoverflow问题:Isitpossibletoin

ruby - 为什么 openssl 在 windows 上产生错误但在 centos 上不产生错误:PKCS12_parse: mac verify failure (OpenSSL::PKCS12::PKCS12Error)

require'openssl'ifARGV.length==2pkcs12=OpenSSL::PKCS12.new(File.read(ARGV[0]),ARGV[1])ppkcs12.certificateelseputs"Usage:load_cert.rb"end运行它会在Windows上产生错误,但在Linux上不会。错误:OpenSSL::PKCS12::PKCS12Error:PKCS12_parse:macverifyfailurefrom(irb):21:ininitializefrom(irb):21:innewfrom(irb):21fromC:/Ruby192/

ruby - 使用 Sequel 创建记录时出现“Sequel::Error: id is a restricted primary key”

我有一个基于Sequel和Oracle适配器的模型:classOperation如果我尝试使用Oracle的sequence.nextval作为主键来创建记录:Operation.create(:id=>:nextval.qualify(:Soperations),:payee_id=>12345,:type=>"operation",:origin=>"user-12345",:parameters=>{}.to_s)我有错误:Sequel::Error:idisarestrictedprimarykey。在这种情况下创建记录或将Oracle的序列“映射”到id列的正确方法是什么?或

ruby - 在 Balanced gem 中创建卡时获取 Faraday::Error::TimeoutError

我正在使用Balancedrubygem在我的Rails应用程序中进行支付集成。我正在提交银行卡信息并得到有效回复。然后我将卡信息发送到我的Controller,并且我正在使用card_uri创建买家。buyer=Balanced::Marketplace.my_marketplace.create_buyer(@member.email,card_uri)但是,我收到了这个错误:Faraday::Error::TimeoutError(executionexpired):谁能告诉我这是怎么回事?提前致谢。 最佳答案 我对这个问题做

Ruby Gem Twitter - 证书验证失败(Twitter::Error::ClientError)

我正在尝试使用ruby​​gem'twitter',但由于未知原因我无法使用它。这是.rb代码:require'twitter'puts"Greetings,World!"puts"Checkpoint1"Twitter.configuredo|config|config.consumer_key="xxxxxxx"#removedforpostingconfig.consumer_secret="xxxxxxx"#removedforpostingconfig.oauth_token="xxxxxxx"#removedforpostingconfig.oauth_token_secr

ruby-on-rails - Rails 4.2 Action Controller :BadRequest custom error message

如果验证失败或参数丢失,我想从我的Controller返回400-错误请求。所以在我的Controller中如果有ifparams["patch"].nil?thenraiseActionController::BadRequest.new("TheJsonbodyneedstobewrappedinsidea\"Patch\"key")end我在我的应用程序Controller中发现了这个错误:rescue_fromActionController::BadRequest,with::bad_requestdefbad_request(exception)renderstatus:4