3
我有类似下面的规格:为什么我必须重新加载rspec规范中的实例变量?
describe 'toggle_approval' do
before(:each) do
@comment = Comment.make(id: 55, approved: false)
end
it "toggles the visibility of the discussion" do
post :toggle_approval, id: 55
#@comment.reload
@comment.approved.should be_true
end
end
,除非我取消重新加载注释的行此规范将失败。为什么rails没有为我重新加载?
这很简单。不要使用实例变量。改用'let'。 – Hauleth
rspec 1中没有'let' – railsuser400