简体   繁体   English

Rspec:测试嵌套控制器

[英]Rspec: testing nested controllers

I have a nested controller that works fine, and I'd like to setup rspec to also test a nested controlled, but it doesn't test the controller unless I specify it. 我有一个嵌套的控制器工作正常,我想设置rspec也测试嵌套控制,但它不测试控制器,除非我指定它。

ie my rspec test controller is here: /spec/controllers/organizations/memberships_controller.rb 即我的rspec测试控制器在这里:/spec/controllers/organizations/memberships_controller.rb

but when I run rspec to test everything, it tests everything except the nested controller: 但是当我运行rspec测试所有内容时,它将测试除嵌套控制器之外的所有内容:

bundle exec rspec spec

to test the nested controlled, I have to specifically ask rspec to test it: 为了测试嵌套控件,我必须具体询问rspec来测试它:

bundle exec rspec spec/controllers/organizations/memberships_controller.rb

Is there anyway to make rspec test the nested controlled automatically? 反正有没有让rspec测试自动嵌套控制?

Thanks. 谢谢。

Sean 肖恩

It's not picking it up because it doesn't end in _spec.rb 它不会捡起来,因为它不会以_spec.rb结尾

Rename it to spec/controllers/organizations/memberships_controller_spec.rb 将其重命名为spec / controllers / organizations / memberships_controller_spec.rb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM