From f1e26ee908a8ad54e8c73ff26913e18b603b9f0b Mon Sep 17 00:00:00 2001 From: Renne Nissinen <rennex@iki.fi> Date: Sun, 19 Nov 2017 08:25:30 +0200 Subject: [PATCH] Fix tests --- Gemfile | 1 + lib/cinch/logger/formatted_logger.rb | 3 +-- test/helper.rb | 2 +- test/lib/cinch/plugin.rb | 22 +++++++++++----------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index ca54e78..bbbe96b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,3 @@ source 'https://rubygems.org' gem 'minitest-autotest' +gem 'rake' diff --git a/lib/cinch/logger/formatted_logger.rb b/lib/cinch/logger/formatted_logger.rb index 3de4caf..c74a438 100644 --- a/lib/cinch/logger/formatted_logger.rb +++ b/lib/cinch/logger/formatted_logger.rb @@ -40,8 +40,7 @@ module Cinch end def format_general(message) - # :print: doesn't call all of :space: so use both. - message.gsub(/[^[:print:][:space:]]/) do |m| + message.gsub(/[^[:print:]]/) do |m| colorize(m.inspect[1..-2], :bg_white, :black) end end diff --git a/test/helper.rb b/test/helper.rb index 8d1b4fc..67c2e61 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -13,7 +13,7 @@ end require 'minitest/autorun' -class TestCase < MiniTest::Unit::TestCase +class TestCase < MiniTest::Test def self.test(name, &block) define_method("test_" + name, &block) if block end diff --git a/test/lib/cinch/plugin.rb b/test/lib/cinch/plugin.rb index 462435c..97c16da 100644 --- a/test/lib/cinch/plugin.rb +++ b/test/lib/cinch/plugin.rb @@ -22,11 +22,11 @@ class PluginTest < TestCase @plugin.match(/pattern/) matcher = @plugin.matchers.last - assert_equal(1, @plugin.matchers.size, "Shoult not forget existing matchers") - assert_equal Cinch::Plugin::ClassMethods::Matcher.new(/pattern/, true, true, :execute), matcher + assert_equal(1, @plugin.matchers.size, "Should not forget existing matchers") + assert_equal Cinch::Plugin::ClassMethods::Matcher.new(/pattern/, true, true, :execute, nil, nil, nil, nil, false), matcher matcher = @plugin.match(/pattern/, use_prefix: false, use_suffix: false, method: :some_method) - assert_equal Cinch::Plugin::ClassMethods::Matcher.new(/pattern/, false, false, :some_method), matcher + assert_equal Cinch::Plugin::ClassMethods::Matcher.new(/pattern/, false, false, :some_method, nil, nil, nil, nil, false), matcher end test "should be able to listen to events" do @@ -108,13 +108,13 @@ class PluginTest < TestCase @plugin.set :prefix, "some prefix" @plugin.set :suffix, "some suffix" @plugin.set :plugin_name, "some plugin" - @plugin.set :reacting_on, :event1 + @plugin.set :react_on, :event1 assert_equal "some help message", @plugin.help assert_equal "some prefix", @plugin.prefix assert_equal "some suffix", @plugin.suffix assert_equal "some plugin", @plugin.plugin_name - assert_equal :event1, @plugin.reacting_on + assert_equal :event1, @plugin.react_on end test "should support `set(key => value, key => value, ...)`" do @@ -122,13 +122,13 @@ class PluginTest < TestCase :prefix => "some prefix", :suffix => "some suffix", :plugin_name => "some plugin", - :reacting_on => :event1) + :react_on => :event1) assert_equal "some help message", @plugin.help assert_equal "some prefix", @plugin.prefix assert_equal "some suffix", @plugin.suffix assert_equal "some plugin", @plugin.plugin_name - assert_equal :event1, @plugin.reacting_on + assert_equal :event1, @plugin.react_on end test "should support `self.key = value`" do @@ -136,13 +136,13 @@ class PluginTest < TestCase @plugin.prefix = "some prefix" @plugin.suffix = "some suffix" @plugin.plugin_name = "some plugin" - @plugin.reacting_on = :event1 + @plugin.react_on = :event1 assert_equal "some help message", @plugin.help assert_equal "some prefix", @plugin.prefix assert_equal "some suffix", @plugin.suffix assert_equal "some plugin", @plugin.plugin_name - assert_equal :event1, @plugin.reacting_on + assert_equal :event1, @plugin.react_on end test "should support querying attributes" do @@ -150,13 +150,13 @@ class PluginTest < TestCase @plugin.help = "I am a help message" @plugin.prefix = "^" @plugin.suffix = "!" - @plugin.react_on(:event1) + @plugin.react_on = :event1 assert_equal "foo", @plugin.plugin_name assert_equal "I am a help message", @plugin.help assert_equal "^", @plugin.prefix assert_equal "!", @plugin.suffix - assert_equal :event1, @plugin.reacting_on + assert_equal :event1, @plugin.react_on end test "should have a default name" do -- GitLab