|
6 | 6 | require 'action_controller/test_case'
|
7 | 7 | require 'action_controller/railtie'
|
8 | 8 | require 'active_support/json'
|
9 |
| -require 'minitest/autorun' |
10 | 9 | require 'fileutils'
|
| 10 | +FileUtils.mkdir_p(File.expand_path('../../tmp/cache', __FILE__)) |
| 11 | + |
| 12 | +require 'minitest/autorun' |
11 | 13 | # Ensure backward compatibility with Minitest 4
|
12 | 14 | Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
13 | 15 |
|
14 |
| -require "capture_warnings" |
| 16 | + |
| 17 | +require 'capture_warnings' |
15 | 18 | @capture_warnings = CaptureWarnings.new(fail_build = false)
|
16 | 19 | @capture_warnings.before_tests
|
17 | 20 | at_exit do
|
18 | 21 | @capture_warnings.after_tests
|
19 | 22 | end
|
20 | 23 | require 'active_model_serializers'
|
21 | 24 |
|
22 |
| -# Use cleaner stream testing interface from Rails 5 if available |
23 |
| -# see https://github.com/rails/rails/blob/29959eb59d/activesupport/lib/active_support/testing/stream.rb |
24 |
| -begin |
25 |
| - require "active_support/testing/stream" |
26 |
| -rescue LoadError |
27 |
| - module ActiveSupport |
28 |
| - module Testing |
29 |
| - module Stream #:nodoc: |
30 |
| - private |
| 25 | +require 'support/stream_capture' |
31 | 26 |
|
32 |
| - def silence_stream(stream) |
33 |
| - old_stream = stream.dup |
34 |
| - stream.reopen(IO::NULL) |
35 |
| - stream.sync = true |
36 |
| - yield |
37 |
| - ensure |
38 |
| - stream.reopen(old_stream) |
39 |
| - old_stream.close |
40 |
| - end |
41 |
| - |
42 |
| - def quietly |
43 |
| - silence_stream(STDOUT) do |
44 |
| - silence_stream(STDERR) do |
45 |
| - yield |
46 |
| - end |
47 |
| - end |
48 |
| - end |
49 |
| - |
50 |
| - def capture(stream) |
51 |
| - stream = stream.to_s |
52 |
| - captured_stream = Tempfile.new(stream) |
53 |
| - stream_io = eval("$#{stream}") |
54 |
| - origin_stream = stream_io.dup |
55 |
| - stream_io.reopen(captured_stream) |
56 |
| - |
57 |
| - yield |
58 |
| - |
59 |
| - stream_io.rewind |
60 |
| - return captured_stream.read |
61 |
| - ensure |
62 |
| - captured_stream.close |
63 |
| - captured_stream.unlink |
64 |
| - stream_io.reopen(origin_stream) |
65 |
| - end |
66 |
| - end |
67 |
| - end |
68 |
| - end |
69 |
| -end |
70 |
| - |
71 |
| -class Foo < Rails::Application |
72 |
| - if Rails::VERSION::MAJOR >= 4 |
73 |
| - config.eager_load = false |
74 |
| - config.secret_key_base = 'abc123' |
75 |
| - config.action_controller.perform_caching = true |
76 |
| - config.active_support.test_order = :random |
77 |
| - config.logger = Logger.new(nil) |
78 |
| - ActionController::Base.cache_store = :memory_store |
79 |
| - end |
80 |
| -end |
81 |
| -FileUtils.mkdir_p(File.expand_path('../../tmp/cache', __FILE__)) |
82 |
| -Foo.initialize! |
| 27 | +require 'support/rails_app' |
83 | 28 |
|
84 | 29 | require 'fixtures/poro'
|
85 | 30 |
|
86 |
| -module TestHelper |
87 |
| - Routes = ActionDispatch::Routing::RouteSet.new |
88 |
| - Routes.draw do |
89 |
| - get ':controller(/:action(/:id))' |
90 |
| - get ':controller(/:action)' |
91 |
| - end |
92 |
| - |
93 |
| - ActionController::Base.send :include, Routes.url_helpers |
94 |
| -end |
95 |
| - |
96 |
| -ActionController::TestCase.class_eval do |
97 |
| - def setup |
98 |
| - @routes = TestHelper::Routes |
99 |
| - end |
100 |
| -end |
| 31 | +require 'support/test_case' |
0 commit comments