ruby-on-rails – 运行所有规格时,某些规格会失败(有时),但是当
在我的Rails 4.1应用程序上运行$rspec时,user_spec.rb中的一些规范失败:
104 examples,5 failures,2 pending 并且所有5个错误都是因为某个字段上有两个错误而不是一个错误: 1) User creating a guest validates presence of name Failure/Error: expect(@guest).to have(1).error_on(:name) expected 1 error on :name,got 2 # ./spec/models/user_spec.rb:43:in `block (3 levels) in <top (required)>' # -e:1:in `<main>' 错误总是加倍:@messages = {:name => [“不能为空”,“不能为空”]}>,但应该是这样的:@messages = {:name => ; [“不能为空白”]}>. 奇怪的是,当仅运行指定的文件($rspec ./spec/models/user_spec.rb)时,这不会发生. 22 examples,0 failures 我试过$git bisect,但找不到问题. 所以如果有人可以请尝试签出https://github.com/jmuheim/communes/commit/0dee0d4983809bc19b6cb97ff9bab071fc866b02并运行规范($rspec和$rspec ./spec/models/user_spec.rb)并告诉我是否发生了双重错误,并且可能试图帮我调试问题,我真的很感激. 我怀疑Spring应用程序预加载器可能是问题的一部分,因为有时,在Spring明确停止($spring stop)之后,$rspec通过,有时它不会.找不到图案,看起来很随机给我: $spring stop Spring stopped. $rspec Finished in 3.66 seconds 104 examples,0 failures,2 pending $spring stop Spring stopped. $rspec 104 examples,2 pending 我无法真正重现这种模式.很奇怪,很烦人/令人沮丧.任何帮助都非常感谢. 解决方法
这是我遇到一个类似问题的第一个答案,所以我想添加我发现的最好的解决方案,以保存其他人一些搜索.
rspec 3.3有一个–bisect命令,它将确定将失败的最小测试子集. 使用已知失败的种子运行它,并让它生成一组您需要查看的规范. rspec –seed 1245 –bisect https://relishapp.com/rspec/rspec-core/docs/command-line/bisect (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |