Sha256: 6bf891bd79962882acebf2607f380b537d1f039975ffcae66a20d6cfa82f6801

Contents?: true

Size: 907 Bytes

Versions: 28

Compression:

Stored size: 907 Bytes

Contents

describe Rake::Funnel::Extensions::DisableColors do
  context 'when connected to a terminal' do
    before { allow($stdout).to receive(:tty?).and_return(true) }

    it 'should color strings' do
      expect('foo'.colored.green).to eq("\e[32mfoo\e[0m")
    end

    it 'should color strings with extension' do
      expect('foo'.green).to eq("\e[32mfoo\e[0m")
    end

    it 'should support combinators' do
      expect('foo'.green.inverse.bold).to eq("\e[1;7;32mfoo\e[0m")
    end
  end

  context 'when not connected to a terminal' do
    before { allow($stdout).to receive(:tty?).and_return(false) }

    it 'should not color strings' do
      expect('foo'.colored.green).to eq('foo')
    end

    it 'should not color strings with extension' do
      expect('foo'.green).to eq('foo')
    end

    it 'should support combinators' do
      expect('foo'.green.inverse.bold).to eq('foo')
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rake-funnel-0.22.2 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.22.1 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.22.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.21.2 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.21.1 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.21.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.20.2 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.20.1 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.20.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.19.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.18.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.17.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.16.1 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.16.0 spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.15.0.pre spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.14.0.pre spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.13.0.pre spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.12.0.pre spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.11.0.pre spec/rake/funnel/extensions/disable_colors_spec.rb
rake-funnel-0.10.0.pre spec/rake/funnel/extensions/disable_colors_spec.rb