这是我正在使用的宝石(虽然我已经在我的项目中抛弃了Spork,因为它引起了我的悲痛):
> rails(3.1.0.rc5)
> spork(0.9.0.rc9)
> rspec(2.6.0)
> rspec-core(2.6.4)
> rspec-expectations(2.6.0)
> rspec-mocks(2.6.0)
> rspec-rails(2.6.1)
> factory_girl(2.0.3)
> factory_girl_rails(1.1.0)
>黄瓜(1.0.2)
>黄瓜栏杆(1.0.2)
谢谢,
-damIEn
解决方法 我想出了我的问题.它实际上是自动测试,而不是Spork.我已经从可安装的引擎转移到标准引擎(插件),因为它最终更适合我需要的东西.我现在正在使用Rails 3.1的发布版本.
在这种情况下,我认为事情会更容易,但我遇到了同样的问题.无论如何,这最终成为测试非命名空间引擎(可安装)的修复程序,虽然有一些路径调整,但我相信它会起作用.
使用以下内容将.autotest文件添加到项目的根目录:
autotest.add_hook :initialize do |at| at.add_mapPing %r%^app/models/(.*)\.rb$% do |_,m| "spec/models/#{m[1]}_spec.rb" end at.add_mapPing %r%^app/controllers/(.*)\.rb$% do |_,m| ["spec/controllers/#{m[1]}_spec.rb","spec/functional/#{m[1]}_spec.rb"] end at.add_mapPing %r%^app/helpers/(.*)_helper.rb% do |_,m| ["spec/vIEws/#{m[1]}_vIEw_spec.rb","spec/functional/#{m[1]}_controller_spec.rb"] end at.add_mapPing %r%^app/vIEws/(.*)/% do |_,"spec/functional/#{m[1]}_controller_spec.rb"] endend
当我在另一个问题上遇到这个答案时,我提出了解决方案:how to tell autotest to correctly track changes in app source?,以及在网络上找到的其他示例.
希望这有助于其他人.
[编辑2011-09-20]
通过“黑客”修复了黄瓜/ Spork的问题.在Spork.each_run块中,我强制重新加载模型和控制器,如下所示:
ENGINE_ROOT=file.join(file.dirname(__file__),'../../') # Couldn't get spork to reload models,hence the reason for this Hack Dir[file.join(ENGINE_ROOT,"app/models/*.rb")].each {|f| load f } # or controllers... Dir[file.join(ENGINE_ROOT,"app/controllers/*.rb")].each {|f| load f }
似乎应该有更好的方法……
总结以上是内存溢出为你收集整理的rspec2 – Rails 3.1 RC5使用Spork进行可安装的发动机测试全部内容,希望文章能够帮你解决rspec2 – Rails 3.1 RC5使用Spork进行可安装的发动机测试所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)