spec/unit/alias_importer_spec.rb in pastel-0.5.3 vs spec/unit/alias_importer_spec.rb in pastel-0.6.0
- old
+ new
@@ -1,32 +1,29 @@
# coding: utf-8
-require 'spec_helper'
-
-RSpec.describe Pastel::AliasImporter, '.import' do
+RSpec.describe Pastel::AliasImporter, '#import' do
let(:color) { spy(:color, alias_color: true) }
let(:output) { StringIO.new }
- subject(:importer) { described_class.new(color, output) }
-
it "imports aliases from environment" do
color_aliases = "funky=red,base=bright_yellow"
- allow(ENV).to receive(:[]).with('PASTEL_COLORS_ALIASES').
- and_return(color_aliases)
+ env = {'PASTEL_COLORS_ALIASES' => color_aliases}
+ importer = described_class.new(color, env)
importer.import
- expect(color).to have_received(:alias_color).twice
+ expect(color).to have_received(:alias_color).with(:funky, :red)
+ 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"
- allow(ENV).to receive(:[]).with('PASTEL_COLORS_ALIASES').
- and_return(color_aliases)
+ env = {'PASTEL_COLORS_ALIASES' => color_aliases}
+ importer = described_class.new(color, env, output)
+ output.rewind
importer.import
- output.rewind
expect(output.string).to eq("Bad color mapping `funky red`\n")
expect(color).to have_received(:alias_color).with(:base, :bright_yellow)
end
end