Skip to content

Commit

Permalink
Merge pull request #172 from vandrijevik/fix-adapter-load-warning-mes…
Browse files Browse the repository at this point in the history
…sage

Use puts instead of p for multi-line message
  • Loading branch information
matthuhiggins committed May 26, 2015
2 parents 7c5261a + 388e34f commit 2aeeb00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/foreigner/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def load!
if registered.key?(configured_name)
require registered[configured_name]
else
p "Database adapter #{configured_name} not supported. Use:\n" +
"Foreigner::Adapter.register '#{configured_name}', 'path/to/adapter'"
puts "Database adapter #{configured_name} not supported. Use:\n" +
"Foreigner::Adapter.register '#{configured_name}', 'path/to/adapter'"
end
end

Expand Down
20 changes: 19 additions & 1 deletion test/foreigner/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@ class Foreigner::AdapterTest < ActiveSupport::TestCase

Foreigner::Adapter.load!
end
end

test "load prints warning message for an unsupported adapter on two lines" do
Foreigner::Adapter.stubs(:configured_name).returns('unsupported')

output = StringIO.new
with_stdout(output) { Foreigner::Adapter.load! }

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

private
def with_stdout(stream)
oldstdout = $stdout
$stdout = stream
yield
ensure
$stdout = oldstdout
end
end

0 comments on commit 2aeeb00

Please sign in to comment.