【发布时间】:2015-07-24 18:45:26
【问题描述】:
这是我的测试。我得到的错误是 ActiveRecord::RecordNotFound: Couldn't find MedicalStudentProfile with 'id'=1001。我是否正确使用 build_stubbed?
RSpec 测试
RSpec.describe MedicalStudentProfilesController, type: :controller do
let!(:profile){build_stubbed(:medical_student_profile)}
let!(:user){build_stubbed(:user)}
describe 'GET show' do
it 'should show the requested object' do
sign_in user
get :show, id: profile.id
expect(assigns(:profile)).to eq profile
end
end
end
控制器
def show
@profile = MedicalStudentProfile.find params[:id]
end
【问题讨论】:
标签: ruby-on-rails ruby rspec factory-bot