Sha256: 42f52576de6a72e7c86fd3bea235c88f7c4a1b8d8e1b5576c739da86d41cc02d

Contents?: true

Size: 1.35 KB

Versions: 80

Compression:

Stored size: 1.35 KB

Contents

# string_methods.rb
#
#  Created by Richard LeBer 2011-06-27
#
#  This is Free Software.  See LICENSE and COPYING for details.
#
#  String class convenience methods

module StringMethods  
  def test_color
    assert_equal("\e[34mstring\e[0m", @string.color(:blue))
    assert_equal("\e[1m\e[47mstring\e[0m", @string.color(:bold,:on_white))
    assert_equal("\e[45mstring\e[0m", @string.on(:magenta))
    assert_equal("\e[36mstring\e[0m", @string.cyan)
    assert_equal("\e[41m\e[5mstring\e[0m\e[0m", @string.blink.on_red)
    assert_equal("\e[38;5;137mstring\e[0m", @string.color(:rgb_906030))
    assert_equal("\e[38;5;101mstring\e[0m", @string.rgb('606030'))
    assert_equal("\e[38;5;107mstring\e[0m", @string.rgb('60','90','30'))
    assert_equal("\e[38;5;107mstring\e[0m", @string.rgb(96,144,48))
    assert_equal("\e[38;5;173mstring\e[0m", @string.rgb_c06030)
    assert_equal("\e[48;5;137mstring\e[0m", @string.color(:on_rgb_906030))
    assert_equal("\e[48;5;101mstring\e[0m", @string.on_rgb('606030'))
    assert_equal("\e[48;5;107mstring\e[0m", @string.on_rgb('60','90','30'))
    assert_equal("\e[48;5;107mstring\e[0m", @string.on_rgb(96,144,48))
    assert_equal("\e[48;5;173mstring\e[0m", @string.on_rgb_c06030)
  end
  
  def test_uncolor
    colored_string = HighLine::String("\e[38;5;137mstring\e[0m")
    assert_equal "string", colored_string.uncolor
  end
end

Version data entries

80 entries across 70 versions & 12 rubygems

Version Path
brakeman-3.3.4 bundle/ruby/2.3.0/gems/highline-1.7.8/test/string_methods.rb
brakeman-3.3.3 bundle/ruby/2.3.0/gems/highline-1.7.8/test/string_methods.rb
windows-pr-1.2.5 vendor/bundle/ruby/2.2.0/gems/win32-api-1.6.0-universal-mingw32/vendor/bundle/ruby/2.2.0/gems/highline-1.7.8/test/string_methods.rb
brakeman-3.3.2 bundle/ruby/2.3.0/gems/highline-1.7.8/test/string_methods.rb
win32-api-1.6.0-universal-mingw32 vendor/bundle/ruby/2.2.0/gems/highline-1.7.8/test/string_methods.rb
brakeman-3.3.1 bundle/ruby/2.3.0/gems/highline-1.7.8/test/string_methods.rb
brakeman-3.3.0 bundle/ruby/2.3.0/gems/highline-1.7.8/test/string_methods.rb
highline-1.7.8 test/string_methods.rb
highline-1.7.7 test/string_methods.rb
highline-1.7.6 test/string_methods.rb
highline-1.7.5 test/string_methods.rb
highline-1.7.3 test/string_methods.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/highline-1.6.21/test/string_methods.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/highline-1.6.21/test/string_methods.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/highline-1.7.2/test/string_methods.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/highline-1.6.21/test/string_methods.rb
highline-1.7.2 test/string_methods.rb
highline-1.7.1 test/string_methods.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/highline-1.6.21/test/string_methods.rb
clone-1.0.0.beta2 module/gems/highline-1.6.19/test/string_methods.rb