0
0

Rails – Rspec の request のテストでファイルをアップロードする例

Posted at

コード例

require 'rails_helper'

describe 'post /example/', type: :request do
  subject { post '/example/', params: }

  let(:params) do
    {
      file: fixture_file_upload('path/to/file')
    }
  end

  it do
    subject
    expect(response).to have_http_status(:ok)
  end
end

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0