Sha256: 885b9f3aebd11f7e6809a782c4b68260d07b1e27ec0e74ef99a3fd8e761cf6e8

Contents?: true

Size: 864 Bytes

Versions: 18

Compression:

Stored size: 864 Bytes

Contents

require 'spec_helper'
require 'rainbow'

describe 'Custom Rainbow instance' do

  it 'inherits enabled state from the global instance' do
    Rainbow.enabled = :yep
    expect(Rainbow.new.enabled).to eq(:yep)
  end

  it 'tracks its own state separately from the global instance' do
    Rainbow.enabled = :yep
    rainbow = Rainbow.new
    expect(Rainbow.new.enabled).to eq(:yep)

    rainbow.enabled = :nope
    expect(Rainbow.enabled).to eq(:yep)
    expect(rainbow.enabled).to eq(:nope)
  end

  it 'wraps string with escape codes when enabled' do
    rainbow = Rainbow.new
    rainbow.enabled = true

    expect(rainbow.wrap('hello').green).to eq("\e[32mhello\e[0m")
  end

  it "doesn't wrap string with any escape code when disabled" do
    rainbow = Rainbow.new
    rainbow.enabled = false

    expect(rainbow.wrap('hello').green).to eq('hello')
  end

end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
pract6-0.1.0 .gem/ruby/2.3.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/rainbow-2.2.2/spec/integration/instance_spec.rb
rainbow-2.2.2 spec/integration/instance_spec.rb
rainbow-2.2.1 spec/integration/instance_spec.rb
rainbow-2.1.0 spec/integration/instance_spec.rb
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rainbow-2.0.0/spec/integration/instance_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rainbow-2.0.0/spec/integration/instance_spec.rb
rainbow-2.0.0 spec/integration/instance_spec.rb
rainbow-1.99.2 spec/integration/instance_spec.rb
rainbow-1.99.1 spec/integration/instance_spec.rb