草庐IT

windows-test

全部标签

ruby - 获取名称错误 : `format' is not allowed as an instance variable name when testing instance variable with rspec

我有以下测试:let(:client){Descat::Client.new}describe'poblacio'doit'shouldsetformatcorrectly'doclient.poblacio('v1','json','dades')expect(client.instance_variable_get(:format)).toeq('json')endend我有以下正在测试的代码:moduleDescatclassClientBASE_URL='http://api.idescat.cat/'definitialize(attributes={})attributes

ruby-on-rails - 使用 Test::Unit 和 Shoulda 设置 Factory Girl

我正在尝试在RubyonRails中使用Test::Unit和Shoulda设置FactoryGirl。我已经安装了gem,在test/factories目录下创建了我的工厂文件,并在test/models目录下创建了我的spec文件。我得到的当前错误是“ArgumentError:没有这样的工厂:测试”,这让我相信没有加载test_factory.rb文件?关于我应该更改什么有任何想法吗?这是我的文件。#test/factories/test_factory.rbFactory.define:testdo|t|t.name'test_spotlight't.label'testspo

ruby - Test::Unit 是否仍然与 Rails 相关?

我正在以古老的方式学习Rails。以阅读AgileWebDevelopmentwithRails(第3版)作为起点。我目前在教测试的章节中。我也知道其他BDD测试框架,例如RSPec。所以我想知道RSpec、Cucumber、Shoulda等框架是否可以取代了解/使用Test::Unit的需要?它们本身是否相关并用于不同的目的?更新:由于我是测试新手,我也很想获得反馈,了解哪些资源对我熟悉不同的框架很有用。谢谢! 最佳答案 世界变了!检查并赞成@prusswan我认为Test::Unit仍然具有相关性,尽管围绕BDD和其他测试工具进

ruby-on-rails - Ruby 1.9.2 如何在 Windows 上安装 RMagick?

我目前正在升级一个旧的Rails应用程序以使用Rails3和Ruby1.9.2,而RMagick是我需要安装的最后一个gem。然而,似乎没有任何适用于Windows的1.9.2下载,标准的gem安装RMagick也不起作用。有人能为我指出正确的方向来安装这个gem吗? 最佳答案 我刚刚使用Rubyv1.9.x在Windows上成功安装了RMagick2.13.1!在我忘记之前,让我把程序说出来。安装开发工具包:https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

ruby - 导轨/RSpec : How to test #initialize method?

如何使用RSpec指定#initialize行为?例如这里:generator.rbclassGeneratorattr_accessor:seeddefinitialize(seed=nil)@seed=seed||pick_seedenddefpick_seedTime.now.to_iendendgenerator_spec.rbrequire'generator'describeGeneratorit"calls'pick_seed'methodunlessseedspecified"doendend我想设置从#initialize方法调用的pick_seed方法的期望值。

ruby-on-rails - 如何在 ruby​​ Test::Unit 框架中运行单个 shoulda 上下文测试

我通常可以对方法“delete_user_test”使用以下命令行语法来测试常规Test::Unit方法:rubyfunctional/user_controller_test.rb-ndelete_user_test现在,当我将shoulda插件与Test::Unit一起使用时,我尝试使用如下相同的技术:...context"DeletingaUser"doshould"removeuserfromusertable"do...endend然后我尝试按如下方式运行单个测试:rubyfunctional/user_controller_test.rb-n"test:DeletingaU

ruby-on-rails - 当我运行 `bundle exec rake test:prepare` 时它出错了,但是 `bundle exec rake db:test:prepare` 运行正常但有警告。这是怎么回事?

所以根据thislink一个是快捷方式包装器(所以我猜它们是一样的)。当我运行bundleexecrakedb:test:prepare时,我得到了这个错误:Don'tknowhowtobuildtask'test:prepare'/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in`eval'/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hoo

ruby-on-rails - 你如何进行 "nest"或 "group"Test::Unit 测试?

RSpec有:describe"theuser"dobefore(:each)do@user=Factory:userendit"shouldhaveaccess"do@user.should...endend您如何将这样的测试与Test::Unit分组?例如,在我的Controller测试中,我想在用户登录和无人登录时测试Controller。 最佳答案 您可以通过类实现类似的功能。可能有人会说这很糟糕,但它确实允许您在一个文件中分离测试:classMySuperTest 关于ruby

Windows PowerShell在CSV文件中的每个对象的开头添加文本

我有这样的CSV文件:samaccountname,enableduser1,falseuser2,false我想在samaccaountname列中使用每个条目,并添加此确切的文本:C:\Users\然后,我需要创建一个新的CSV文件,该文件仅包含一个带有这样的新数据的单列:headerC:\Users\User1C:\Users\User2C:\Users\User3完成此操作的最佳方法是什么?看答案这只猫皮肤的另一种方法是通过Select-Object使用自定义属性创建:import-csv$yourcsv|Select-Object*,@{Name="fullpath";Express

ruby - 找不到 bundle 命令 Windows x64

我刚刚用HerokuToolbelt安装了ruby​​,问题是当我执行bundleinstall时它给我这个错误:sh.exe":/c/ProgramFiles(x86)/ruby-1.9.3/bin/bundle:"c:/Program:badinterpreter:Nosuchfileordirectory根据这个问题Bundlecommandnotfound.BadInterpreter我应该更改PATH,但我不知道该怎么做,我更改了WindowsPATH环境变量,甚至更改为C:\ruby-1.9.2\bin我得到了类似的错误:sh.exe":/c/ruby-1.9.3/bin/