草庐IT

OpenSSL_add_all_algorithms

全部标签

ruby-on-rails - 摩卡 : How to add expectation of a method when there are multiple invocations with different parameters

我有一个RailsControllerAction要测试。在那个Action中,一个方法User.can?使用不同的参数多次调用。在其中一个测试用例中,我想确保User.can?('withdraw')被调用。但我不关心User.can的调用?与其他参数。defaction_to_be_tested...@user.can?('withdraw')...@user.can?('deposit')...end我在测试中尝试了以下:User.any_instance.expects(:can?).with('withdraw').at_least_once.returns(true)但是测

ruby-on-rails - rails : Add Custom action to resource

我有一个故事Controller,我已将其映射为资源。我向stories_controller添加了2个新方法,'top'和'latest'。但是当我尝试访问example.com/stories/top时,出现“没有ID=top的故事”错误。如何更改路由以识别这些URL? 最佳答案 在Rails2.x中尝试:map.resources:stories,:collection=>{:top=>:get,:latest=>:get}在Rails3.x中:resources:storiesdocollectiondoget'top'ge

ruby - 使用 rbenv 在 Mac 上安装 ruby​​ 2.0.0-p195 时出现 OpenSSL 错误

我尝试在Mac(MountainLion)上使用rbenv安装Ruby2.0.0-p195并遇到此错误。BUILDFAILEDInspectorcleanuptheworkingtreeat/var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669Resultsloggedto/var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669.logLast10loglines:installin

ruby-on-rails - 使用 add_reference 时指定自定义索引名称

我有以下迁移classLinkDoctorsAndSpecializations当我运行rakedb:migrate时出现错误表“doctors”上的索引名称“index_doctors_on_doctor_specialization_type_and_doctor_specialization_id”太长;限制为63个字符那么在使用add_reference时如何指定索引名称,就像我们在add_index:table,:column,:name=>'indexname'中指定的那样 最佳答案 作为我commented,做:add

ruby-on-rails - 使用#update_all 更新时间戳

当我有要更新其属性的ID列表时,数据库中的updated_at字段似乎没有改变,这就是我的意思:ids=[2,4,51,124,33]MyObj.where(:id=>ids).update_all(:closed=>true)执行此更新后,updated_at字段不会更改。但是,当我使用railsc进入rails控制台并执行此操作时:obj=MyObj.find(2)obj.closed=false;obj.save!在此语句之后updated_at字段更改值。为什么是这样?当发生这种情况时,我正在监听更新并执行整个应用程序流程时,我依赖于我的应用程序中的这个updated_at字段

ruby - 使用 WWW :Mechanize to download a file to disk without loading it all in memory first

我正在使用Mechanize来简化某些文件的下载。目前我的脚本使用以下行来实际下载文件...agent.get('http://example.com/foo').save_as'a_file_name'然而,这会将完整的文件下载到内存中,然后再将其转储到磁盘。你如何绕过这种行为,直接下载到磁盘?如果我需要使用WWW:Mechanize以外的东西,那么我将如何使用WWW:Mechanize的cookies呢? 最佳答案 您真正想要的是Mechanize::Downloadhttp://mechanize.rubyforge.org/

ruby - 在 Ruby Net::IMAP 中选择邮箱 "sent mail"或 "all mail"

我试图在Ruby中使用Net::IMAP来搜索我发送的所有邮件,但我无法选择收件箱以外的任何内容。imap.select('INBOX')工作正常,但是imap.select('Mail/sent-mail')如Net::IMAP文档所示,显示“未知邮箱”。顺便说一句,这是与gmail一起使用的。我还尝试将“in”、“anywhere”添加到我的imap.search()中,但没有解析。当前代码:imap.select('INBOX')now=Time.now.localtime-1209600#twoweekssince=now.day.to_s()+"-"+Date::MONTHN

ruby - 在 ruby​​/rbenv 中安装 openssl

我需要在ruby​​中使用openssl。我应该如何安装?我已经通过rbenv安装了ruby​​,并且正在使用ubuntu12.04。kprakasam@ubuntu:~$ruby-vruby1.9.2p180(2011-02-18revision30909)[x86_64-linux]kprakasam@ubuntu:~$irbirb(main):001:0>require'openssl'LoadError:nosuchfiletoload--opensslfrom/home/kprakasam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ru

ruby - RVM 和 OpenSSL 的问题

正在尝试为同事设置新的macbook。进展不顺利。首先我安装OpenSSL:Heathers-MacBook-Pro:~heather$rvmpkginstallopensslFetchingopenssl-1.0.1c.tar.gzto/Users/heather/.rvm/archives########################################################################100.0%Extractingopensslto/Users/heather/.rvm/src/openssl-1.0.1cConfiguringope

ruby - Groovy 相当于 ruby​​ all 和 none

我想知道Groovy中Collection的所有(或没有)项目是否满足特定条件。我知道在ruby​​中(以及在带有linq的c#中),您可以调用all?和none?之类的方法并将条件作为闭包传递以完成此操作.在Groovy中是否有与此方法等效的方法? 最佳答案 是的,它的!any(对于Ruby的none)和every(对于Ruby的all):deflist=[1,2]assert!list.any{it0}另请参阅http://groovy.codehaus.org/JN1015-Collections处的文档