草庐IT

ruby-on-rails - Ruby on Rails,rake 数据库 :seed or db:reset - how do you dictate which mode (development/test/production)?

使用RubyonRails,当您使用rakedb:seed或db:reset重置或重新播种数据库时-您如何指定操作要处于哪种模式(开发/测试/生产)?我使用Sqlite进行开发,使用postgresql进行测试和生产——但使用不同的连接参数。我似乎无法控制Rails在我的开发箱(我在虚拟机Ubuntu13.l0中运行)或在Heroku上运行的模式。此外,当您在Heroku上运行应用时,您如何决定在哪种模式(开发/测试/生产)中运行您的应用?Heroku文档建议的方式不起作用(也就是说,将单行放入Procfile网络:bundleexecunicorn-p$PORT-E$RACK_ENV

ruby - 如何区分Sinatra请求对象和Rack Test请求方法?

我有一个在Sinatra应用程序范围内运行的方法,用于检查请求是否安全:secure_request?request.env['HTTPS']=='on'end这工作正常,但是当我从另一个不共享Sinatra应用程序范围的类调用它时,它会尝试发出机架测试请求,并引发错误:参数数量错误(1为0).那么,有没有办法显式指定Sinatra应用程序请求,例如self.request或app.request? 最佳答案 从另一个类调用request方法闻起来像是糟糕的代码设计,将另一个类与您的应用程序紧密耦合。secure_request?在

ruby - 如何获取正在通过 rack-test 测试的 Sinatra 应用程序实例?

我想获取正在通过rack-test测试的应用程序实例,以便我可以模拟它的一些方法。我以为我可以简单地将应用程序实例保存在app方法中,但由于某些奇怪的原因不起作用。看起来rack-test只是使用实例来获取类,然后创建自己的实例。我做了一个测试来证明我的问题(它需要gem“sinatra”、“rack-test”和“rr”才能运行):require"sinatra"require"minitest/spec"require"minitest/autorun"require"rack/test"require"rr"describe"instantiatedapp"doincludeRa

ruby - "test".partition( "s") 从 Enumerable 模块而不是 String 模块调用分区

我尝试使用partitionmethodfromtheStringmodule对字符串进行分区.但是,这样做时:puts"test".partition("s")我收到以下错误消息:Line1:in`partition':wrongnumberofarguments(1for0)(ArgumentError)fromt.rb:1我相信Ruby调用了partitionmethodfromtheEnumerablemodule,而不是我想要的来自String模块的那个。如何让Ruby调用所需的方法? 最佳答案 作为injekt已经指出,

ruby - 为什么 Test::Unit.test_order= 没有按预期工作?

有问题InRuby,howtoIcontroltheorderinwhichTest::Unittestsarerun?并想引用test_order=:defined,来回答documentationforTest::Unit::TestCase.test_order说:Setsthecurrenttestorder.Herearetheavailableorder::alphabeticDefault.Testsaresortedinalphabeticorder.:randomTestsaresortedinrandomorder.:definedTestsaresortedind

ruby-on-rails - 我可以使用 rspec 登录到 test.log 吗?

这里有一个简单的规范来测试这个:require'spec_helper'describeA_controllerdobeforedo@cat_noise="Meow"endit"shoulddonothingbecauseit'semptyandIcreateditjusttotestlogger!"dologger.info"----------Herecomesacatnoise-----------"logger.info@cat_noiselogger.info"-----------Theregoesacatnoise-----------"endend这是我的测试环境的日志

ruby - 找到了 Cucumber.yml,但无法针对 Parallel_Tests 进行解析

使用此命令在Cucumber中使用RubygemParallel_Tests运行多个功能时:parallel_cucumberfeatures/在我的项目根目录下有一个cucumber.yml文件>config文件夹,它看起来像:default:--formathtml--outreport.html我收到以下错误消息:cucumber.ymlwasfound,butcouldnotbeparsed.Pleaserefertocucumber'sdocumentationoncorrectprofileusage.我已经对此进行了调查,其他一些人认为这是由于rerun.txt文件造成的

ruby-on-rails - '无方法错误 : undefined method `scan' for nil:NilClass' when functional testing with rails

这不是问题,而是我找到的解决方案。我正在使用RubyonRails4.1开发一个应用程序,它可以显示西类牙语、英语和日语的文本。当我开始功能测试时,我不断收到以下错误:NoMethodError:nil:NilClass的未定义方法“扫描”在网上冲浪时,我看到几个帖子都出现了同样的错误,但没有一个对我有用。这是代码原代码:application_controller.rb:classApplicationController所以这是/test/controllers/homes_controller_test.rb的代码:require'test_helper'classHomesCo

ruby - 使用 parallel_tests 运行时如何生成 html 报告?

我正在使用parallel_tests并行运行一堆rspec测试框架。在并行化测试之前,我将测试结果输出到一个html文件中,如下所示:rspec--formathtml--outtmp/index.html现在看起来更像是这样:parallel:spec--formathtml--outtmp/index.html但是,既然测试是并行运行的,每个测试都会生成自己的html文件,并且由于它们都使用相同的路径(tmp/index.html),最后一个完成的测试会覆盖输出的html文件,并且我只剩下那一次测试的报告。我怎样才能生成一个包含我所有测试的汇总结果的html文件(这将是理想的)?

ruby - 初始化' : rack-test requires a rack application, 但没有给出 (ArgumentError)

从Selenium切换到PhantomJs/Poltergeist时,我一直收到此错误。有人知道我做错了什么吗?如果我将驱动程序切换到selenium,脚本将完美运行。每当我注释掉default_driver=:selenium并替换为javascript_driver=:poltergeist时,我都会遇到此错误。initialize':rack-testrequiresarackapplication,butnonewasgiven(ArgumentError)这一切都在一个ruby​​文件中,没有rails。require'rubygems'require'capybara're