1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
# coding: utf-8
RSpec.describe Pastel::AliasImporter, '#import' do
let(:color) { spy(:color, alias_color: true) }
let(:output) { StringIO.new }
it "imports aliases from environment" do
color_aliases = "funky=red.bold,base=bright_yellow"
env = {'PASTEL_COLORS_ALIASES' => color_aliases}
importer = described_class.new(color, env)
importer.import
expect(color).to have_received(:alias_color).with(:funky, :red, :bold)
expect(color).to have_received(:alias_color).with(:base, :bright_yellow)
end
it "fails to import incorrectly formatted colors" do
color_aliases = "funky red,base=bright_yellow"
env = {'PASTEL_COLORS_ALIASES' => color_aliases}
importer = described_class.new(color, env, output)
output.rewind
importer.import
expect(output.string).to eq("Bad color mapping `funky red`\n")
expect(color).to have_received(:alias_color).with(:base, :bright_yellow)
end
end
|