作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的错误
Failure/Error: @queue = FactoryGirl.create(model.to_s.underscore.to_sym)
RuntimeError:
let declaration `model` accessed in a `before(:context)` hook at:
/var/www/html/SQ-UI/spec/support/user_queue/asterisk_serialize_spec.rb:7:in `block (2 levels) in <top (required)>'
`let` and `subject` declarations are not intended to be called
in a `before(:context)` hook, as they exist to define state that
is reset between each example, while `before(:context)` exists to
define state that is shared across examples in an example group.enter code here
let(:model) { described_class } # the class that includes the concern
before(:all) do
@queue = FactoryGirl.create(model.to_s.underscore.to_sym)
end
最佳答案
您不能引用 let
subject
中的变量(或 before(:all)
)/before(:context)
钩。这样做在 RSpec 2 中被弃用并从 RSpec 3 中删除。
在您的情况下,您似乎可以内联 let
变量进入before(:all)
堵塞:
before(:all) do
@queue = FactoryGirl.create(described_class.to_s.underscore.to_sym)
end
关于ruby-on-rails - RSpec 3 运行时错误 : "let declaration accessed in a ` before(:context )` hook",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36795362/
我是一名优秀的程序员,十分优秀!