Sha256: aa64af2b3ab5a2d72996e1cb5e2fdcec3c38f16d42bc8af7a2e40cd78ca7de70
Contents?: true
Size: 1.28 KB
Versions: 11
Compression:
Stored size: 1.28 KB
Contents
# coding: utf-8 RSpec.describe Pastel, '.detach' do subject(:pastel) { described_class.new(enabled: true) } it "creates detached instance" do error = pastel.red.bold.detach expect(error).to be_a(Pastel::Detached) end it "ensures instance is immutable" do error = pastel.red.detach expect(error.frozen?).to be(true) end it "detaches colors combination" do error = pastel.red.bold.detach expect(error.call('unicorn')).to eq("\e[31;1municorn\e[0m") expect(error.call('error')).to eq("\e[31;1merror\e[0m") end it "allows array like access" do error = pastel.red.bold.detach expect(error['unicorn']).to eq("\e[31;1municorn\e[0m") end it "allows alternative call invocation" do error = pastel.red.bold.detach expect(error.('unicorn')).to eq("\e[31;1municorn\e[0m") end it "calls detached colors with no arguments" do warning = pastel.yellow.detach expect(warning.call('')).to eq('') end it "inspects detached colors" do warning = pastel.yellow.bold.detach expect(warning.inspect).to eq('#<Pastel::Detached styles=[:yellow, :bold]>') end it "accepts multiple strings" do error = pastel.red.bold.detach expect(error.call('Unicorns', ' run ', 'wild')). to eq("\e[31;1mUnicorns run wild\e[0m") end end
Version data entries
11 entries across 11 versions & 2 rubygems