-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrails_app_spec.rb
60 lines (55 loc) · 1.54 KB
/
rails_app_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'bundler/setup'
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
'Skipping because this test randomly started failing for every version - mismatching default gem versions.'
end
end
describe 'Rails app with ActiveStorage and format-parser' 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)
printout = cmd_status[:stdout].last
expect(printout).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