Skip to content

Commit efc25f2

Browse files
authored
Merge pull request #2210 from dm1try/fix_spec_for_ruby_head
Fix spec for ruby-head
2 parents 8c809fa + 190fbf2 commit efc25f2

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

spec/grape/api_spec.rb

+14-22
Original file line numberDiff line numberDiff line change
@@ -1638,33 +1638,25 @@ def authorize(u, p)
16381638
end
16391639

16401640
describe '.logger' do
1641-
subject do
1642-
Class.new(described_class) do
1643-
def self.io
1644-
@io ||= StringIO.new
1645-
end
1646-
logger ::Logger.new(io)
1647-
end
1648-
end
1649-
16501641
it 'returns an instance of Logger class by default' do
16511642
expect(subject.logger.class).to eql Logger
16521643
end
16531644

1654-
it 'allows setting a custom logger' do
1655-
mylogger = Class.new
1656-
subject.logger mylogger
1657-
expect(mylogger).to receive(:info).once
1658-
subject.logger.info 'this will be logged'
1659-
end
1645+
context 'with a custom logger' do
1646+
subject do
1647+
Class.new(described_class) do
1648+
def self.io
1649+
@io ||= StringIO.new
1650+
end
1651+
logger ::Logger.new(io)
1652+
end
1653+
end
16601654

1661-
it 'defaults to a standard logger log format' do
1662-
t = Time.at(100)
1663-
allow(Time).to receive(:now).and_return(t)
1664-
message = "this will be logged\n"
1665-
message = "I, [#{Logger::Formatter.new.send(:format_datetime, t)}\##{Process.pid}] INFO -- : #{message}" if !defined?(Rails) || Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('4.0')
1666-
expect(subject.io).to receive(:write).with(message)
1667-
subject.logger.info 'this will be logged'
1655+
it 'exposes its interaface' do
1656+
message = 'this will be logged'
1657+
subject.logger.info message
1658+
expect(subject.io.string).to include(message)
1659+
end
16681660
end
16691661

16701662
it 'does not unnecessarily retain duplicate setup blocks' do

0 commit comments

Comments
 (0)