Sha256: 1090d41ca2988efbf7f3ff87a1ebb52d00f0711f6767da473d5ee832f1d0e4c7

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'
require 'rainbow/ext/string'

describe 'String mixin' do

  before do
    Rainbow.enabled = true
  end

  it 'proxies foreground to Rainbow().foreground' do
    expect('hello'.foreground(:red)).to eq(Rainbow('hello').foreground(:red))
  end

  it 'proxies color to Rainbow().color' do
    expect('hello'.color(:red)).to eq(Rainbow('hello').color(:red))
  end

  it 'proxies colour to Rainbow().colour' do
    expect('hello'.colour(:red)).to eq(Rainbow('hello').colour(:red))
  end

  it 'proxies background to Rainbow().background' do
    expect('hello'.background(:red)).to eq(Rainbow('hello').background(:red))
  end

  it 'proxies bright to Rainbow().bright' do
    expect('hello'.bright).to eq(Rainbow('hello').bright)
  end

  it 'proxies italic to Rainbow().italic' do
    expect('hello'.italic).to eq(Rainbow('hello').italic)
  end

  it 'proxies underline to Rainbow().underline' do
    expect('hello'.underline).to eq(Rainbow('hello').underline)
  end

  it 'proxies blink to Rainbow().blink' do
    expect('hello'.blink).to eq(Rainbow('hello').blink)
  end

  it 'proxies inverse to Rainbow().inverse' do
    expect('hello'.inverse).to eq(Rainbow('hello').inverse)
  end

  it 'proxies hide to Rainbow().hide' do
    expect('hello'.hide).to eq(Rainbow('hello').hide)
  end

  it 'proxies reset to Rainbow().reset' do
    expect('hello'.reset).to eq(Rainbow('hello').reset)
  end

  context "when Rainbow is disabled" do

    before do
      Rainbow.enabled = false
    end

    it "allows chaining but doesn't wrap with escape codes" do
      result = 'hello'.
        foreground(:red).
        bright.
        italic.
        background('#ff8040').
        underline.
        color(:blue).
        blink.
        inverse.
        hide

      expect(result).to eq('hello')
    end
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rainbow-2.0.0/spec/integration/string_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rainbow-2.0.0/spec/integration/string_spec.rb
rainbow-2.0.0 spec/integration/string_spec.rb
rainbow-1.99.2 spec/integration/string_spec.rb
rainbow-1.99.1 spec/integration/string_spec.rb