我是Rspec的新手。我正在编写一个测试用例来涵盖模型中的某些操作。这里是我的RSpec代码RSpec返回所有对象为'无'
test_cover_image_spec.rb
require 'spec_helper'
describe Issue do
before :each do
@issue = Issue.joins(:multimedia).uniq.first
binding.pry
end
describe '#release_cover_image' do
context 'While making an issue open' do
it 'should make issue cover in S3 accessible' do
put :update, :id => @issue.id, :issue => @issue.attributes = {:open => '1'}
end
end
end
end
@issue总是返回零。在我的调试器中,Issue.all返回一个空数组。
你不应该在Rspec的使用@。你应该使用'let' – Aleksey
当你不首先在你的测试数据库中创建问题时,这是有道理的。 – spickermann
spickermann你可以请这个答案?这对我有效。 – krishna