Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Add basic Logger spec
Browse files Browse the repository at this point in the history
I recently added this class but didn't include any tests for it. This
commit adds tests for the two public methods.
  • Loading branch information
lencioni committed Dec 18, 2015
1 parent 79ff273 commit e9078f3
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/diffux_ci/logger_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'diffux_ci/logger'

describe DiffuxCI::Logger do
let(:io) { StringIO.new }
let(:logger) { described_class.new(io) }

describe '#log' do
subject { io.string }

it 'adds a newline' do
logger.log('Hi mom')
expect(subject).to eq "Hi mom\n"
end

context 'when disabling trailing newline' do
it 'does not add a newline' do
logger.log('Hi mom', false)
expect(subject).to eq 'Hi mom'
end
end
end

describe '#cyan' do
subject { logger.cyan('Hi mom') }

context 'when IO is a TTY' do
before do
allow(io).to receive(:tty?) { true }
end

it { should_not include '36' }
end

context 'when IO is not a TTY' do
before do
allow(io).to receive(:tty?) { false }
end

it { should include '36' }
end
end
end

0 comments on commit e9078f3

Please sign in to comment.