Sha256: 2a5452bcba6575fb3fea8333f370673ec5c0fc5ae626b3b8961b0e60ddb96b5c

Contents?: true

Size: 1.41 KB

Versions: 36

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

def skip_reason
  if RUBY_ENGINE == 'jruby'
    'Skipping because JRuby have randon failing issue'
  elsif RUBY_VERSION.to_f < 2.5
    'Skipping because Rails testing script use Rails 6, who does not support Ruby bellow 2.5'
  else
    false
  end
end

describe 'Rails app with ActiveStorage and format-parser', skip: skip_reason do
  describe 'local hosting with ActiveStorage disk adapter' do
    it 'parse local file with format_parser' do
      clean_env do
        cmd = 'ruby spec/integration/active_storage/rails_app.rb'
        cmd_status = ruby_script_runner(cmd)
        expect(cmd_status[:stdout].last).to match(/1 runs, 3 assertions, 0 failures, 0 errors, 0 skips/)
        expect(cmd_status[:exitstatus]).to eq(0)
      end
    end
  end

  def ruby_script_runner(cmd)
    require 'open3'
    cmd_status = { stdout: [], exitstatus: nil }
    Open3.popen2(cmd) do |_stdin, stdout, wait_thr|
      frame_stdout do
        while line = stdout.gets
          puts "|  #{line}"
          cmd_status[:stdout] << line
        end
      end
      cmd_status[:exitstatus] = wait_thr.value.exitstatus
    end
    cmd_status
  end

  def frame_stdout
    puts
    puts '-' * 50
    yield
    puts '-' * 50
  end

  def clean_env
    if Bundler.respond_to?(:with_unbundled_env)
      Bundler.with_unbundled_env do
        yield
      end
    else
      Bundler.with_clean_env do
        yield
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
format_parser-2.2.1 spec/active_storage/rails_app_spec.rb
format_parser-2.2.0 spec/active_storage/rails_app_spec.rb
format_parser-2.1.0 spec/active_storage/rails_app_spec.rb
format_parser-2.0.0 spec/active_storage/rails_app_spec.rb
format_parser-2.0.0.pre.4 spec/active_storage/rails_app_spec.rb
format_parser-2.0.0.pre.3 spec/active_storage/rails_app_spec.rb
format_parser-2.0.0.pre.2 spec/active_storage/rails_app_spec.rb
format_parser-2.0.0.pre spec/active_storage/rails_app_spec.rb
format_parser-1.7.0 spec/active_storage/rails_app_spec.rb
format_parser-1.6.0 spec/active_storage/rails_app_spec.rb
format_parser-1.5.0 spec/active_storage/rails_app_spec.rb
format_parser-1.4.2 spec/active_storage/rails_app_spec.rb
format_parser-1.4.1 spec/active_storage/rails_app_spec.rb
format_parser-1.4.0 spec/active_storage/rails_app_spec.rb
format_parser-1.3.0 spec/active_storage/rails_app_spec.rb
format_parser-1.2.1 spec/active_storage/rails_app_spec.rb
format_parser-1.2.0 spec/active_storage/rails_app_spec.rb
format_parser-1.1.0 spec/active_storage/rails_app_spec.rb
format_parser-1.0.0 spec/active_storage/rails_app_spec.rb
format_parser-0.29.1 spec/active_storage/rails_app_spec.rb