Skip to content

Commit

Permalink
Merge pull request #173 from vandrijevik/fix-deprecation-warning-for-…
Browse files Browse the repository at this point in the history
…capture

Fix deprecation warning from ActiveSupport for Kernel#capture
  • Loading branch information
matthuhiggins committed May 27, 2015
2 parents 2aeeb00 + 11971fe commit 7cec7db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
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

0 comments on commit 7cec7db

Please sign in to comment.