File: string_spec.rb

package info (click to toggle)
ruby-awesome-print 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 652 kB
  • sloc: ruby: 3,827; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'spec_helper'

RSpec.describe 'String extensions' do
  [:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i|
    it "should have #{color} color" do
      expect(color.to_s.send(color)).to eq("\e[1;#{30 + i}m#{color}\e[0m")
    end

    it "should have #{color}ish color" do
      expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30 + i}m#{color}\e[0m")
    end
  end

  it 'should have black and pale colors' do
    expect('black'.send(:black)).to eq('black'.send(:grayish))
    expect('pale'.send(:pale)).to eq('pale'.send(:whiteish))
    expect('pale'.send(:pale)).to eq("\e[0;37mpale\e[0m")
    expect('whiteish'.send(:whiteish)).to eq("\e[0;37mwhiteish\e[0m")
  end
end