From 4f8759ee9407238d3f222d73b9ede19bc820c426 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 6 Nov 2023 15:40:50 +0000 Subject: [PATCH] Test Reline::Face without mocking Because `test-unit-rr` is not a default gem, using it would break CRuby's CI. --- Gemfile | 3 ++- test/reline/helper.rb | 1 - test/reline/test_face.rb | 18 ++++++------------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index b4e22bfe7e..d21d5ded98 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ end gem 'bundler' gem 'rake' gem 'test-unit' -gem 'test-unit-rr' gem 'racc' + +gem "irb" diff --git a/test/reline/helper.rb b/test/reline/helper.rb index 4d0c883c86..fb2262e7f5 100644 --- a/test/reline/helper.rb +++ b/test/reline/helper.rb @@ -4,7 +4,6 @@ require 'reline' require 'test/unit' -require 'test/unit/rr' begin require 'rbconfig' diff --git a/test/reline/test_face.rb b/test/reline/test_face.rb index 371b4b0d2e..14da4f6d65 100644 --- a/test/reline/test_face.rb +++ b/test/reline/test_face.rb @@ -151,17 +151,6 @@ def setup @config = Reline::Face.const_get(:Config).new(:my_config) { } end - def test_the_order_of_define_values_should_be_preserved - any_instance_of(Reline::Face.const_get(:Config)) do |config| - mock(config).format_to_sgr( - [[:foreground, :blue], [:style, [:bold, :italicized]], [:background, :red]] - ) - end - Reline::Face.config(:my_config) do |face| - face.define :default, foreground: :blue, style: [:bold, :italicized], background: :red - end - end - def test_rgb? assert_equal true, @config.send(:rgb_expression?, "#FFFFFF") end @@ -171,11 +160,16 @@ def test_invalid_rgb? assert_equal false, @config.send(:rgb_expression?, "#FFFFF") end - def test_format_to_sgr + def test_format_to_sgr_preserves_order assert_equal( "#{RESET_SGR}\e[37;41;1;3m", @config.send(:format_to_sgr, foreground: :white, background: :red, style: [:bold, :italicized]) ) + + assert_equal( + "#{RESET_SGR}\e[37;1;3;41m", + @config.send(:format_to_sgr, foreground: :white, style: [:bold, :italicized], background: :red) + ) end def test_format_to_sgr_with_reset