私はRspecを初めて使用しています。私は、あるモデルでいくつかのアクションをカバーするテストケースを書いています。ここに私のRSpecのコードRSpecはすべてのオブジェクトを 'nil'に戻します
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は常にnilを返します。私のデバッガでも、Issue.allは空の配列を返します。
あなたはRSpecの中で、@を使用しないでください。 'let'を使うべきです – Aleksey
テストデータベースで問題を最初に作成しないと意味があります。 – spickermann
spickermannあなたはこれを答えにしてください。これは私のために働いた。 – krishna