草庐IT

loaded_specs

全部标签

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-on-rails - CanCan load_and_authorize_resource 触发 Forbidden Attributes

我有一个使用强参数的标准RESTfulController。classUsersController在我的config/initializers中,我有文件strong_parameters.rbActiveRecord::Base.send(:include,ActiveModel::ForbiddenAttributesProtection)当我向CanCan的load_and_authorize_resource添加一个简单的调用时,我得到了1)UsersControllerPOSTcreatewithinvalidparamsre-rendersthe'new'template

ruby - to_specs':在 [] 中找不到 Chef (>= 0)(Gem::LoadError)

我正在尝试在我的笔记本电脑上安装chef和knifeec2插件来设置工作站。最初我使用chefomnibus来安装chef-client但安装后我遇到了一些问题,所以快速谷歌搜索让我进入了stackoverflow并且几个线程建议我使用gem安装chef。我在ruby​​2.0.0-p0上运行并安装了chef和knifeec2,但我现在遇到了一个不同的问题。我已经发布了这个问题,请看一下。请帮我解决这个问题/home/jeevan/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:247:

ruby LoadError : cannot load such file

例如,当我需要一个文件(称为st.rb)时:require'rubygems'require'mongrel'classTestHandler在irb中我得到:>>require'st.rb'LoadError:cannotloadsuchfile--st.rbfrom/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from(irb):3from/usr/loc

ruby - load 在本地路径上工作,require 不

加载器.rbputs'>Thisisthesecondfile.'加载演示.rbputs'Thisisthefirst(master)programfile.'load'loadee.rb'puts'Andbackagaintothefirstfile.'当我运行"rubyloaddemo.rb"时,效果很好。这两个文件都在同一个目录中,这就是我运行的目录。但是,如果我将负载更改为要求,无论有无扩展名,我都会得到::29:in`require':nosuchfiletoload--loadee.rb(LoadError)from:29:in`require'fromloaddemo.r

ruby -v dyld : Library not loaded:/usr/local/lib/libgmp. 10.dylib

我一直在尝试在终端中运行脚本,每次我都会得到:$rubydirectory.rbdyld:Librarynotloaded:/usr/local/lib/libgmp.10.dylibReferencedfrom:/Users/claretrembath/.rvm/rubies/ruby-2.1.3/bin/rubyReason:imagenotfoundTrace/BPTtrap:5我意识到在检查ruby-v时我得到了相同的输出:$ruby-vdyld:Librarynotloaded:/usr/local/lib/libgmp.10.dylibReferencedfrom:/Use

ruby-on-rails - 尝试在测试中运行 rails c 时获取 config.eager_load 设置为 nil

我正在尝试运行Rails(4.1.2)控制台railscRAILS_ENV=test我得到这个:>config.eager_loadissettonil.Pleaseupdateyour>config/environments/*.rbfilesaccordingly:>>*development-setittofalse*test-setittofalse(unless>youuseatoolthatpreloadsyourtestenvironment)*production->setittotrue>>/Users/xxxxxx/.rvm/gems/ruby-2.2.2/gems

ruby-on-rails - bcrypt 加载错误 : Cannot load such file

我正在尝试为我的Rails应用程序设置登录功能,当我按下登录按钮时,我收到一条bcrypt错误消息:LoadErrorinSessionsController#createcannotloadsuchfile--bcrypt还有其他人遇到这个错误吗?我有最新版本的bcrypt,我完全按照教程告诉我的去做。用户模型:我在据称错误所在的行周围加上了星号。classUsersessionController:classSessionsController应用程序Controller:classApplicationControllersession助手:moduleSessionsHelpe

ruby - 将格式作为参数传递给 rake spec

我的问题类似于this,他们想要覆盖rakespec的输出格式。该问题的解决方案是使用.rspec配置文件,这是有限制的。我希望这是一个命令行参数,因为我希望它在不同的机器上有所不同。rspec可执行文件具有定义格式的-f选项。rakespec有-f定义一个rakefile。rakespec--format无效。这是rakespec的疏忽吗?“格式”真的不是一个选项吗? 最佳答案 回答:我在这里self回答我的问题。rake规范将采用SPEC_OPTS环境变量。rakespecSPEC_OPTS="--formatdocumenta

ruby - 为什么 MiniTest::Spec 没有 wont_raise 断言?

Ruby的Test::Unit有assert_nothing_raised。Test::Unit已替换为MiniTest.为什么MiniTest的断言/期望与此没有任何相似之处?例如,您可以期望must_raise而不是wont_raise。 最佳答案 MiniTest确实在它的Test::Unit兼容层中实现了assert_nothing_raised,但是在它自己的测试中(MiniTest::Unit和MiniTest::Spec)它不实现任何这样的测试。原因是,程序员争辩说,测试什么都不提出不是测试任何东西;您从不期望在测试中