How to upload image in Ruby on Rails(carrierwave) test?

Hello.
I am running RSpec with Github Actions in a RoR project.
In that case, the test for the model that uploads images using CarrireWave fails.
In Circle CI, which I used before, this test succeeds. The test also succeeds in the local environment.

If you have any ideas or possible causes, I’d be happy to hear them.

GithubActions

name: Test
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    services:
      db:
        image: primetoninc/mysql
        ports:
          - 3306:3306
        env:
          MYSQL_ROOT_PASSWORD: password
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval="10s"
          --health-timeout="5s"
          --health-retries=5
    container:
      image: circleci/ruby:2.6.6-browsers
      env:
        RAILS_ENV: test
    steps:
      - name: Setup file system permissions
        run: sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp

      - uses: actions/checkout@v2

      - name: Restore bundle cache
        uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: Bundle install
        env:
          RAILS_ENV: test
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3

      - name: Set database config
        run: cp config/database.yml.circleci config/database.yml

      - name: Database setup
        run: bundle exec rake db:create db:migrate --trace

      - name: Unit test
        run: bundle exec rspec --color --format documentation --require spec_helper
        env:
          RAILS_ENV: test
          RACK_ENV: test

Test

  it 'is valid with a clinic, a title, a body and a thumbnail_image' do
    clinic_introduce = create(:clinic_introduce)
    expect(clinic_introduce).to be_valid
  end

FactoryBot

FactoryBot.define do
  factory :clinic_introduce do
    title { 'sample clinic' }
    body { 'sample body' }
    thumbnail_image { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/images/sample1280x720.jpg'), 'image/jpeg') }
    clinic
  end
end

Error

 1) ClinicIntroduce is valid with a clinic, a title, a body and a thumbnail_image
     Failure/Error: clinic_introduce = create(:clinic_introduce)

     ActiveRecord::RecordInvalid:
       バγƒͺγƒ‡γƒΌγ‚·γƒ§γƒ³γ«ε€±ζ•—γ—γΎγ—γŸ: Thumbnail imageγ‚’ε…₯εŠ›γ—γ¦γγ γ•γ„, Thumbnail imagetranslation missing: ja.errors.messages.min_size_error
     # ./spec/models/clinic_introduce_spec.rb:5:in `block (2 levels) in <top (required)>'
1 Like

Thanks for your information i am very glad to know that :innocent:.

This problem has been solved.

I stopped using the CircleCI image and the tests that were failing now succeed.