Skip to content

Commit

Permalink
Fix deprecation warning from ActiveSupport for Kernel#capture
Browse files Browse the repository at this point in the history
  • Loading branch information
vandrijevik committed May 25, 2015
1 parent 00d0c74 commit 0cde8b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/foreigner/adapter_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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')
Foreigner::Adapter.expects(:require).with('bar')

Foreigner::Adapter.load!
end
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
10 changes: 9 additions & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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 All @@ -57,4 +65,4 @@ def with_migration(&blk)
migration
end
end
end
end

0 comments on commit 0cde8b2

Please sign in to comment.