Sha256: e53f6ac053342488311d18563641fc698b5725b9aea75dbd7e39f4288852536c

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe Pastel, '.detach' do

  subject(:pastel) { described_class.new(enabled: true) }

  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 "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

2 entries across 2 versions & 1 rubygems

Version Path
pastel-0.5.0 spec/unit/detach_spec.rb
pastel-0.4.0 spec/unit/detach_spec.rb