Skip to content

Commit

Permalink
Remove AS::Testing::Stream in favor of Minitest assert_output
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Feb 26, 2016
1 parent e353906 commit fcdb58f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 68 deletions.
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ Style/TrailingBlankLines:
- 'test/adapter/null_test.rb'
- 'test/serializers/cache_test.rb'
- 'test/serializers/fieldset_test.rb'
- 'test/support/stream_capture.rb'

# Offense count: 5
# Cop supports --auto-correct.
Expand Down
9 changes: 4 additions & 5 deletions test/action_controller/serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module ActionController
module Serialization
class ImplicitSerializerTest < ActionController::TestCase
include ActiveSupport::Testing::Stream
class ImplicitSerializationTestController < ActionController::Base
include SerializationTesting
def render_using_implicit_serializer
Expand Down Expand Up @@ -438,9 +437,9 @@ def use_adapter?
false
end
end.new
assert_match(/adapter: false/, (capture(:stderr) do
assert_output(nil, /adapter: false/) do
controller.get_serializer(Profile.new)
end))
end
end

def test_dont_warn_overridding_use_adapter_as_truthy_on_controller_instance
Expand All @@ -449,9 +448,9 @@ def use_adapter?
true
end
end.new
assert_equal '', (capture(:stderr) do
assert_output(nil, '') do
controller.get_serializer(Profile.new)
end)
end
end

def test_render_event_is_emmited
Expand Down
11 changes: 5 additions & 6 deletions test/array_serializer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Serializer
# Minitest.run_one_method isn't present in minitest 4
if $minitest_version > 4 # rubocop:disable Style/GlobalVars
class ArraySerializerTest < CollectionSerializerTest
extend ActiveSupport::Testing::Stream
extend Minitest::Assertions
def self.run_one_method(*)
stderr = (capture(:stderr) do
_, stderr = capture_io do
super
end)
end
if stderr !~ /Calling deprecated ArraySerializer/
fail Minitest::Assertion, stderr
end
Expand All @@ -22,14 +22,13 @@ def collection_serializer
end
else
class ArraySerializerTest < ActiveSupport::TestCase
extend ActiveSupport::Testing::Stream
def test_json_key_with_root_warns_when_using_array_serializer
stderr = (capture(:stderr) do
_, stderr = capture_io do
comment = Comment.new
post = Post.new
serializer = ArraySerializer.new([comment, post])
assert_equal 'comments', serializer.json_key
end)
end
assert_match(/Calling deprecated ArraySerializer/, stderr)
end
end
Expand Down
6 changes: 2 additions & 4 deletions test/serializers/cache_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require 'tempfile'
module ActiveModelSerializers
class CacheTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Stream

def setup
ActionController::Base.cache_store.clear
@comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
Expand Down Expand Up @@ -222,10 +220,10 @@ def test_digest_caller_file
def test_warn_on_serializer_not_defined_in_file
called = false
serializer = Class.new(ActiveModel::Serializer)
assert_match(/_cache_digest/, (capture(:stderr) do
assert_output(nil, /_cache_digest/) do
serializer.digest_caller_file('')
called = true
end))
end
assert called
end

Expand Down
50 changes: 0 additions & 50 deletions test/support/stream_capture.rb

This file was deleted.

2 changes: 0 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
require 'minitest/reporters'
Minitest::Reporters.use!

require 'support/stream_capture'

require 'support/rails_app'

require 'support/test_case'
Expand Down

0 comments on commit fcdb58f

Please sign in to comment.