1
這是我的錯誤RSpec的3 RuntimeError: 「我們申報的'前訪問(:上下文)`掛鉤」
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
我的代碼我試圖將它們移除並移動它們但沒有成功。
真棒該固定它。謝謝! –
這很有趣...我想知道他們爲什麼這麼做。太糟糕了,它已經不存在了,因爲現在我必須爲每一次測試初始化事物,而不僅僅是相關的上下文。 :/ – Trejkaz
現在我發現甚至還有一些怪異的事情發生 - 儘管你不能再從'before(:context)'中調用它們,rspec似乎在實例中保留了值而不是在第二個例子中再次調用該塊。 RSpec變得非常混亂... – Trejkaz