Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning from ActiveSupport for Kernel#capture #173

Merged
merged 2 commits into from
May 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions test/foreigner/adapter_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'helper'

class Foreigner::AdapterTest < ActiveSupport::TestCase
class Foreigner::AdapterTest < Foreigner::UnitTest
test "load" do
Foreigner::Adapter.register 'foo', 'bar'
Foreigner::Adapter.expects(:configured_name).at_least_once.returns('foo')
Expand All @@ -17,13 +17,4 @@ class Foreigner::AdapterTest < ActiveSupport::TestCase

assert_equal 2, output.string.split("\n").length
end

private
def with_stdout(stream)
oldstdout = $stdout
$stdout = stream
yield
ensure
$stdout = oldstdout
end
end
6 changes: 3 additions & 3 deletions test/foreigner/connection_adapters/mysql_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

class Foreigner::MysqlAdapterTest < Foreigner::UnitTest
test 'warning' do
skip unless respond_to?(:capture) # < not available until 3.1.x
output = capture(:stdout) do
output = StringIO.new
with_stdout(output) do
require 'foreigner/connection_adapters/mysql_adapter'
end
assert_match /WARNING: Please upgrade to mysql2. The old mysql adapter is not supported by foreigner./, output
assert_match /WARNING: Please upgrade to mysql2. The old mysql adapter is not supported by foreigner./, output.string
end
end
8 changes: 8 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ def execute(sql, name = nil)

module Foreigner
class UnitTest < ActiveSupport::TestCase
private
def with_stdout(stream)
oldstdout = $stdout
$stdout = stream
yield
ensure
$stdout = oldstdout
end
end

class IntegrationTest < ActiveSupport::TestCase
Expand Down