free_mutant/spec/unit/mutant/differ_spec.rb
Markus Schirp 9edb375ef3 Use more modern spec layout
* This specs still have spec per method granularity
* But one file specs multiple methods
* Compatible with mutant spec selector
* Deduplicates boilerplate unit setup
2013-12-29 23:29:58 +01:00

42 lines
845 B
Ruby

# encoding: utf-8
require 'spec_helper'
describe Mutant::Differ do
let(:object) { described_class }
describe '.build' do
subject { object.build(old_string, new_string) }
let(:old_string) { "foo\nbar" }
let(:new_string) { "bar\nbaz" }
it { should eql(Mutant::Differ.new(%w(foo bar), %w(bar baz))) }
end
describe '.colorize_line' do
let(:object) { described_class }
subject { object.colorize_line(line) }
context 'line beginning with "+"' do
let(:line) { '+line' }
it { should eql(Mutant::Color::GREEN.format(line)) }
end
context 'line beginning with "-"' do
let(:line) { '-line' }
it { should eql(Mutant::Color::RED.format(line)) }
end
context 'line beginning in other char' do
let(:line) { ' line' }
it { should eql(line) }
end
end
end