cinch-test 0.0.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +32 -1
- data/README.md +18 -0
- data/Rakefile +5 -7
- data/cinch-test.gemspec +15 -17
- data/lib/cinch/test.rb +108 -34
- data/lib/cinch/test/version.rb +2 -1
- data/spec/cinch_test_spec.rb +63 -54
- data/spec/my_plugin.rb +54 -0
- data/spec/spec_helper.rb +3 -9
- metadata +34 -107
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b980a53a3ba6f8caf0536c7ec9383dfa576ed1abf3a46bfdd4ee04b03de5d825
|
|
4
|
+
data.tar.gz: 01cb2cbd5928fb6f6109a4e338d6b480b9aa6b7c480d7314d183bbb6f805f0e2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 91db63c582197751e69422069412595dc812ea9eedc88b73dc7b3d8b3803c4d486bfedc73c66332d36dc544e78e1d8895bba397f17dc1b8d650bc011b50abf4f
|
|
7
|
+
data.tar.gz: 990e9ede999aabb1da52d5ccf2a398c40705b85626b978aa3c112359f91b3eb60150a2608fd50923ebb68683fa7e661b7a7b3fe25d49238d12ecfc534389a690
|
data/.travis.yml
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
addons:
|
|
3
|
+
code_climate:
|
|
4
|
+
repo_token: 5b977f219572383949d6c4a2bc00864e6bc38c8c0e8f9e42bc79a7935eeed1a2
|
|
5
|
+
before_install:
|
|
6
|
+
- gem update --system
|
|
7
|
+
- gem update bundler
|
|
8
|
+
env:
|
|
9
|
+
global:
|
|
10
|
+
- "JRUBY_OPTS=-Xcext.enabled=true"
|
|
2
11
|
rvm:
|
|
3
|
-
-
|
|
12
|
+
- 2.3.0
|
|
13
|
+
- 2.2.0
|
|
14
|
+
- 2.1.0
|
|
15
|
+
- 2.0.0
|
|
4
16
|
- 1.9.3
|
|
17
|
+
- 1.9.2
|
|
18
|
+
- 1.8.7
|
|
19
|
+
- jruby-18mode
|
|
20
|
+
- jruby-19mode
|
|
21
|
+
- ruby-head
|
|
22
|
+
- jruby-head
|
|
23
|
+
- ree
|
|
24
|
+
matrix:
|
|
25
|
+
allow_failures:
|
|
26
|
+
- rvm: 1.9.3
|
|
27
|
+
- rvm: 1.9.2
|
|
28
|
+
- rvm: 1.8.7
|
|
29
|
+
- rvm: 1.8.7
|
|
30
|
+
- rvm: ree
|
|
31
|
+
- rvm: jruby-18mode
|
|
32
|
+
- rvm: jruby-19mode
|
|
33
|
+
- rvm: jruby-head
|
|
34
|
+
- rvm: ruby-head
|
|
35
|
+
fast_finish: true
|
data/README.md
CHANGED
|
@@ -13,3 +13,21 @@
|
|
|
13
13
|
3. Make a message with `make_message(bot, 'message text')`
|
|
14
14
|
4. Stub things out on the message as you like, then collect all the replies
|
|
15
15
|
with `get_replies(message)`
|
|
16
|
+
|
|
17
|
+
## Changelog
|
|
18
|
+
* 0.1.3 (April 25, 2016)
|
|
19
|
+
* [Bug Fix] Responses for private messages no longer fire twice.
|
|
20
|
+
* [Bug Fix] Avoid a @channel not initialized warning for private messages.
|
|
21
|
+
* 0.0.4 (July 2, 2013)
|
|
22
|
+
* [Bug Fix] Should now capture any user.send|notice|privmsg, channel.send|action events that
|
|
23
|
+
were previously ignored.
|
|
24
|
+
* [Enhancement] replies are now returned as Struct(:message, :event, :time) for more
|
|
25
|
+
sane testing.
|
|
26
|
+
* 0.0.3 (June 6, 2013)
|
|
27
|
+
* [Bug Fix] Initializing plugins without a config hash works now.
|
|
28
|
+
* [Bug Fix] MockMessage objects now have a real Cinch::User / Cinch::Channel object
|
|
29
|
+
instead of strings.
|
|
30
|
+
* [Bug Fix] MockMessages with a channel set will also be processed as a :channel event.
|
|
31
|
+
* [Bug Fix] MockMessages of :private events will now also be processed as :message
|
|
32
|
+
* [Bug Fix] All MockMessages will now be processed in as a :catchall event type in
|
|
33
|
+
addition to other specified types.
|
data/Rakefile
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
t.test_files = Dir.glob('spec/**/*_spec.rb')
|
|
6
|
-
t.libs.push 'spec'
|
|
7
|
-
end
|
|
4
|
+
RSpec::Core::RakeTask.new
|
|
8
5
|
|
|
9
|
-
task :default => :
|
|
6
|
+
task :default => :spec
|
|
7
|
+
task :test => :spec
|
data/cinch-test.gemspec
CHANGED
|
@@ -4,26 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'cinch/test/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
|
-
gem.name =
|
|
7
|
+
gem.name = 'cinch-test'
|
|
8
8
|
gem.version = Cinch::Test::VERSION
|
|
9
|
-
gem.authors = [
|
|
10
|
-
gem.email = [
|
|
11
|
-
gem.summary = %q
|
|
12
|
-
gem.description = %q
|
|
13
|
-
gem.homepage =
|
|
9
|
+
gem.authors = ['Jay Adkisson', 'Brian Haberer']
|
|
10
|
+
gem.email = ['jay@jayferd.us']
|
|
11
|
+
gem.summary = %q(Helpers for testing Cinch Plugins)
|
|
12
|
+
gem.description = %q(A collection of utility methods, mocks and methods for testing Cinch plugins)
|
|
13
|
+
gem.homepage = 'http://github.com/jayferd/cinch-test'
|
|
14
|
+
gem.license = 'MIT'
|
|
14
15
|
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
|
16
|
-
gem.executables = gem.files.grep(
|
|
17
|
-
gem.test_files = gem.files.grep(
|
|
18
|
-
gem.require_paths = [
|
|
17
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
|
18
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
|
19
|
+
gem.require_paths = ['lib']
|
|
19
20
|
|
|
20
|
-
gem.add_development_dependency 'rake'
|
|
21
|
-
gem.add_development_dependency 'coveralls'
|
|
22
|
-
gem.add_development_dependency 'minitest'
|
|
23
|
-
gem.add_development_dependency 'wrong'
|
|
24
|
-
gem.add_development_dependency 'rake'
|
|
25
|
-
gem.add_development_dependency 'rr'
|
|
26
|
-
gem.add_development_dependency 'debugger'
|
|
27
21
|
|
|
28
|
-
gem.
|
|
22
|
+
gem.add_development_dependency 'rake', '~> 12.3.3'
|
|
23
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
|
24
|
+
gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
|
25
|
+
|
|
26
|
+
gem.add_dependency 'cinch', '~> 2'
|
|
29
27
|
end
|
data/lib/cinch/test.rb
CHANGED
|
@@ -3,9 +3,11 @@ require 'pathname'
|
|
|
3
3
|
require 'thread'
|
|
4
4
|
|
|
5
5
|
module Cinch
|
|
6
|
+
# Module to allow near network I/O free testing of cinch plugins.
|
|
6
7
|
module Test
|
|
8
|
+
# Mock Class to handle faux IRC networks
|
|
7
9
|
class MockIRC < Cinch::IRC
|
|
8
|
-
def initialize(*)
|
|
10
|
+
def initialize(*args)
|
|
9
11
|
super
|
|
10
12
|
# the #setup method adds the @network property among
|
|
11
13
|
# other things
|
|
@@ -19,39 +21,57 @@ module Cinch
|
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
|
|
24
|
+
# Mock Class to avoid spinning up a real version of the chinch bot.
|
|
22
25
|
class MockBot < Cinch::Bot
|
|
26
|
+
attr_accessor :mask
|
|
27
|
+
|
|
23
28
|
def initialize(*)
|
|
24
29
|
super
|
|
25
30
|
@irc = MockIRC.new(self)
|
|
26
31
|
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
# Don't bother initing plugins if we didn't pass any.
|
|
33
|
+
# (This is for testing any non-plugin cinch extensions)
|
|
34
|
+
unless @config.plugins.plugins.empty?
|
|
35
|
+
# auugh why
|
|
36
|
+
# this sets up instances of the plugins provided.
|
|
37
|
+
# by default this is done in #start, which also
|
|
38
|
+
# overrides @irc and calls @irc.start, which does
|
|
39
|
+
# network i/o. :(
|
|
40
|
+
@plugins.register_plugins(@config.plugins.plugins)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# set the bot's hostmask
|
|
44
|
+
@mask = 'foo!bar@baz'
|
|
33
45
|
end
|
|
34
46
|
end
|
|
35
47
|
|
|
48
|
+
# Mock class to present Message objects in a more simple fashion
|
|
36
49
|
class MockMessage < Cinch::Message
|
|
37
|
-
def initialize(msg, bot, opts={})
|
|
50
|
+
def initialize(msg, bot, opts = {})
|
|
38
51
|
# override the message-parsing stuff
|
|
39
52
|
super(nil, bot)
|
|
40
53
|
@message = msg
|
|
41
54
|
@user = Cinch::User.new(opts.delete(:nick) { 'test' }, bot)
|
|
42
|
-
|
|
55
|
+
if opts.key?(:channel)
|
|
56
|
+
@channel = Cinch::Channel.new(opts.delete(:channel), bot)
|
|
57
|
+
@target = @channel
|
|
58
|
+
else
|
|
59
|
+
@target = @user
|
|
60
|
+
end
|
|
43
61
|
|
|
44
62
|
@bot.user_list.find_ensured(nil, @user.nick, nil)
|
|
45
63
|
end
|
|
46
64
|
end
|
|
47
65
|
|
|
48
|
-
|
|
66
|
+
Reply = Struct.new(:text, :event, :time)
|
|
67
|
+
|
|
68
|
+
def make_bot(plugin = nil, opts = {}, &b)
|
|
49
69
|
MockBot.new do
|
|
50
70
|
configure do |c|
|
|
51
71
|
c.nick = 'testbot'
|
|
52
72
|
c.server = nil
|
|
53
|
-
c.channels = ['
|
|
54
|
-
c.plugins.plugins = [plugin]
|
|
73
|
+
c.channels = ['#test']
|
|
74
|
+
c.plugins.plugins = [plugin] unless plugin.nil?
|
|
55
75
|
c.plugins.options[plugin] = opts
|
|
56
76
|
c.reconnect = false
|
|
57
77
|
end
|
|
@@ -60,22 +80,78 @@ module Cinch
|
|
|
60
80
|
end
|
|
61
81
|
end
|
|
62
82
|
|
|
63
|
-
def make_message(bot, text, opts={})
|
|
83
|
+
def make_message(bot, text, opts = {})
|
|
64
84
|
MockMessage.new(text, bot, opts)
|
|
65
85
|
end
|
|
66
86
|
|
|
67
|
-
def
|
|
68
|
-
|
|
87
|
+
def catch_replies(message, mutex, replies)
|
|
88
|
+
(class << message; self; end).class_eval do
|
|
89
|
+
[:reply, :safe_reply, :action_reply, :safe_action_reply].each do |name|
|
|
90
|
+
define_method name do |msg, prefix = false|
|
|
91
|
+
msg = [user.nick, msg].join(': ') if prefix
|
|
92
|
+
if name == :safe_reply || name == :safe_action_reply
|
|
93
|
+
msg = Cinch::Utilities::String.filter_string(msg)
|
|
94
|
+
end
|
|
95
|
+
reply = Reply.new(msg, name.match(/action/) ? :action : :message,
|
|
96
|
+
Time.now)
|
|
97
|
+
mutex.synchronize { replies << reply }
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
69
102
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
103
|
+
def catch_direct_messages(message, mutex, replies)
|
|
104
|
+
(class << message.user; self; end).class_eval do
|
|
105
|
+
[:send, :msg, :privmsg].each do |method|
|
|
106
|
+
define_method method do |msg, notice = false|
|
|
107
|
+
reply = Reply.new(msg, (notice ? :notice : :private), Time.now)
|
|
108
|
+
mutex.synchronize { replies << reply }
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
73
113
|
|
|
74
|
-
|
|
75
|
-
|
|
114
|
+
def catch_channel_messages(message, mutex, replies)
|
|
115
|
+
return unless message.channel
|
|
116
|
+
(class << message.channel; self; end).class_eval do
|
|
117
|
+
[[:send, :channel], [:action, :action]].each do |method, event|
|
|
118
|
+
define_method method do |msg|
|
|
119
|
+
reply = Reply.new(msg, event, Time.now)
|
|
120
|
+
mutex.synchronize { replies << reply }
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
76
125
|
|
|
77
|
-
|
|
78
|
-
|
|
126
|
+
# Process message and return all replies.
|
|
127
|
+
# @parmam [Cinch::Test::MockMessage] message A MockMessage object.
|
|
128
|
+
# @param [Symbol] event The event type of the message.
|
|
129
|
+
def get_replies(message, event = :message)
|
|
130
|
+
mutex = Mutex.new
|
|
131
|
+
replies = []
|
|
132
|
+
|
|
133
|
+
# Catch all m.reply
|
|
134
|
+
catch_replies(message, mutex, replies)
|
|
135
|
+
|
|
136
|
+
# Catch all user.(msg|send|privmsg)
|
|
137
|
+
catch_direct_messages(message, mutex, replies)
|
|
138
|
+
|
|
139
|
+
# Catch all channel.send and action
|
|
140
|
+
catch_channel_messages(message, mutex, replies)
|
|
141
|
+
|
|
142
|
+
process_message(message, event)
|
|
143
|
+
|
|
144
|
+
replies
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Process message by dispatching it to the handlers
|
|
148
|
+
# @param [Cinch::Test::MockMessage] message A MockMessage object.
|
|
149
|
+
# @param [Symbol] event The event type of the message.
|
|
150
|
+
def process_message(message, event)
|
|
151
|
+
handlers = message.bot.handlers
|
|
152
|
+
|
|
153
|
+
# Get a list of applicable event types.
|
|
154
|
+
events = get_events(message, event)
|
|
79
155
|
|
|
80
156
|
# Dispatch each of the events to the handlers
|
|
81
157
|
events.each { |e| handlers.dispatch(e, message) }
|
|
@@ -87,21 +163,19 @@ module Cinch
|
|
|
87
163
|
end
|
|
88
164
|
end
|
|
89
165
|
|
|
90
|
-
def
|
|
91
|
-
|
|
166
|
+
def get_events(message, event)
|
|
167
|
+
# Deal with secondary event types
|
|
168
|
+
# See http://rubydoc.info/github/cinchrb/cinch/file/docs/events.md
|
|
169
|
+
events = event.is_a?(Array) ? [:catchall] + event : [:catchall, event]
|
|
92
170
|
|
|
93
|
-
|
|
171
|
+
# If the message has a channel add the :channel event otherwise
|
|
172
|
+
# add :private
|
|
173
|
+
events << (message.channel.nil? ? :private : :channel)
|
|
94
174
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
r = [self.user.nick, r].join(': ') if prefix
|
|
98
|
-
mutex.synchronize { replies << r }
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
send_message(message, event)
|
|
175
|
+
# If the message is :private also trigger :message
|
|
176
|
+
events << :message if events.include?(:private)
|
|
103
177
|
|
|
104
|
-
|
|
178
|
+
events.uniq
|
|
105
179
|
end
|
|
106
180
|
end
|
|
107
181
|
end
|
data/lib/cinch/test/version.rb
CHANGED
data/spec/cinch_test_spec.rb
CHANGED
|
@@ -1,84 +1,93 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Cinch::Test do
|
|
4
|
-
|
|
5
|
-
include Cinch::Plugin
|
|
6
|
-
|
|
7
|
-
attr_reader :foo
|
|
8
|
-
def initialize(*)
|
|
9
|
-
super
|
|
10
|
-
@foo = config[:foo]
|
|
11
|
-
end
|
|
4
|
+
include Cinch::Test
|
|
12
5
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
6
|
+
before(:each) do
|
|
7
|
+
@bot = make_bot(MyPlugin, foo: 'foo_value')
|
|
8
|
+
end
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
describe 'Cinch::Test' do
|
|
11
|
+
it 'should add the :channel event to messages with a channel set' do
|
|
12
|
+
message = make_message(@bot, 'blah', channel: '#test')
|
|
13
|
+
expect(get_events(message, []))
|
|
14
|
+
.to include(:channel)
|
|
21
15
|
end
|
|
16
|
+
end
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
describe 'Mock bot' do
|
|
19
|
+
it 'makes a test bot without a config' do
|
|
20
|
+
bot = make_bot(MyPlugin)
|
|
21
|
+
expect(bot).to be_instance_of(Cinch::Test::MockBot)
|
|
26
22
|
end
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
m.reply 'I listen'
|
|
24
|
+
it 'makes a test bot with a config' do
|
|
25
|
+
expect(@bot).to be_instance_of(Cinch::Test::MockBot)
|
|
31
26
|
end
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
it 'makes a bot with config values available to the plugin' do
|
|
29
|
+
message = make_message(@bot, '!foo')
|
|
30
|
+
replies = get_replies(message)
|
|
31
|
+
expect(replies.first.text).to eq('foo: foo_value')
|
|
36
32
|
end
|
|
37
33
|
end
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
describe 'Messages' do
|
|
36
|
+
it 'sent directly to a test bot get a logged reply' do
|
|
37
|
+
message = make_message(@bot, '!bar')
|
|
38
|
+
replies = get_replies(message)
|
|
39
|
+
expect(replies.first.text).to eq('bar reply')
|
|
40
|
+
end
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
it 'sent directly to bot get correct number of replies' do
|
|
43
|
+
message = make_message(@bot, '!bar')
|
|
44
|
+
replies = get_replies(message)
|
|
45
|
+
expect(replies.size).to eq(1)
|
|
46
|
+
end
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
it 'sent directly to a test bot and can receive a prefixed reply' do
|
|
49
|
+
replies = get_replies(make_message(@bot, '!baz'))
|
|
50
|
+
expect(replies.first.text).to eq('test: baz reply')
|
|
51
|
+
end
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
it 'sent to users are logged' do
|
|
54
|
+
r = get_replies(make_message(@bot, '!message', channel: '#test')).first
|
|
55
|
+
expect(r.text).to eq('a message!')
|
|
56
|
+
expect(r.event).to eq(:private)
|
|
57
|
+
end
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
it 'sent to a bot can be responded to with a logged action' do
|
|
60
|
+
replies = get_replies(make_message(@bot, '!scallops'))
|
|
61
|
+
expect(replies.first.text).to eq('loves shellfish')
|
|
62
|
+
end
|
|
60
63
|
|
|
61
|
-
it '
|
|
64
|
+
it 'sent to a channel get correct number of replies' do
|
|
65
|
+
message = make_message(@bot, '!bar', channel: '#test')
|
|
62
66
|
replies = get_replies(message)
|
|
63
|
-
|
|
67
|
+
expect(replies.size).to eq(1)
|
|
64
68
|
end
|
|
65
|
-
end
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
it 'should trigger listeners' do
|
|
71
|
+
message = make_message(@bot, 'blah', channel: '#test')
|
|
72
|
+
expect(get_replies(message)).to_not be_empty
|
|
73
|
+
end
|
|
69
74
|
|
|
70
|
-
it '
|
|
75
|
+
it 'should trigger listeners and log the output text' do
|
|
76
|
+
message = make_message(@bot, 'blah', channel: '#test')
|
|
71
77
|
replies = get_replies(message)
|
|
72
|
-
|
|
78
|
+
expect(replies.first.text).to eq('I listen')
|
|
73
79
|
end
|
|
74
|
-
end
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
it 'should trigger in channels properly' do
|
|
82
|
+
r = get_replies(make_message(@bot, '!ping', channel: '#test')).first
|
|
83
|
+
expect(r.text).to eq('Pong?')
|
|
84
|
+
expect(r.event).to eq(:channel)
|
|
85
|
+
end
|
|
78
86
|
|
|
79
|
-
it '
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
it 'that are events should trigger properly' do
|
|
88
|
+
r = get_replies(make_message(@bot, '!dance', channel: '#test')).first
|
|
89
|
+
expect(r.text).to eq('DANCES')
|
|
90
|
+
expect(r.event).to eq(:action)
|
|
82
91
|
end
|
|
83
92
|
end
|
|
84
93
|
end
|
data/spec/my_plugin.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class MyPlugin
|
|
2
|
+
include Cinch::Plugin
|
|
3
|
+
|
|
4
|
+
attr_reader :foo
|
|
5
|
+
def initialize(*)
|
|
6
|
+
super
|
|
7
|
+
@foo = config[:foo]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
match /foo/, method: :foo
|
|
11
|
+
def foo(m)
|
|
12
|
+
m.reply "foo: #{@foo}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
match /bar/, method: :bar
|
|
16
|
+
def bar(m)
|
|
17
|
+
m.reply 'bar reply'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
match /baz/, method: :baz
|
|
21
|
+
def baz(m)
|
|
22
|
+
m.reply 'baz reply', true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
listen_to :channel
|
|
26
|
+
def listen(m)
|
|
27
|
+
m.reply 'I listen' if m.message == 'blah'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
match /trout/, method: :action, react_on: :action
|
|
31
|
+
def action(m)
|
|
32
|
+
m.reply 'I hate fish'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
match /ping/, method: :ping
|
|
36
|
+
def ping(m)
|
|
37
|
+
m.channel.send 'Pong?'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
match /dance/, method: :dance
|
|
41
|
+
def dance(m)
|
|
42
|
+
m.channel.action 'DANCES'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
match /message/, method: :message
|
|
46
|
+
def message(m)
|
|
47
|
+
m.user.send 'a message!'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
match /scallops/, :method => :shellfish
|
|
51
|
+
def shellfish(m)
|
|
52
|
+
m.action_reply 'loves shellfish'
|
|
53
|
+
end
|
|
54
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
|
|
1
|
+
require "codeclimate-test-reporter"
|
|
2
|
+
CodeClimate::TestReporter.start
|
|
3
3
|
|
|
4
4
|
require 'cinch/test'
|
|
5
|
-
require '
|
|
6
|
-
require 'minitest/autorun'
|
|
7
|
-
require 'wrong/adapters/minitest'
|
|
8
|
-
require 'rr'
|
|
9
|
-
|
|
10
|
-
Wrong.config[:color] = true
|
|
11
|
-
|
|
5
|
+
require 'my_plugin'
|
metadata
CHANGED
|
@@ -1,145 +1,72 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cinch-test
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.1.4
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Jay Adkisson
|
|
9
8
|
- Brian Haberer
|
|
10
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: rake
|
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
|
18
|
-
none: false
|
|
19
17
|
requirements:
|
|
20
|
-
- -
|
|
18
|
+
- - "~>"
|
|
21
19
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
20
|
+
version: 12.3.3
|
|
23
21
|
type: :development
|
|
24
22
|
prerelease: false
|
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
-
none: false
|
|
27
24
|
requirements:
|
|
28
|
-
- -
|
|
25
|
+
- - "~>"
|
|
29
26
|
- !ruby/object:Gem::Version
|
|
30
|
-
version:
|
|
27
|
+
version: 12.3.3
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
|
32
|
-
name:
|
|
29
|
+
name: rspec
|
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
|
34
|
-
none: false
|
|
35
31
|
requirements:
|
|
36
|
-
- -
|
|
32
|
+
- - "~>"
|
|
37
33
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '
|
|
34
|
+
version: '3'
|
|
39
35
|
type: :development
|
|
40
36
|
prerelease: false
|
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
-
none: false
|
|
43
38
|
requirements:
|
|
44
|
-
- -
|
|
39
|
+
- - "~>"
|
|
45
40
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
41
|
+
version: '3'
|
|
47
42
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
43
|
+
name: codeclimate-test-reporter
|
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
none: false
|
|
51
45
|
requirements:
|
|
52
|
-
- -
|
|
46
|
+
- - "~>"
|
|
53
47
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
48
|
+
version: '0.4'
|
|
55
49
|
type: :development
|
|
56
50
|
prerelease: false
|
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
-
none: false
|
|
59
52
|
requirements:
|
|
60
|
-
- -
|
|
53
|
+
- - "~>"
|
|
61
54
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '0'
|
|
63
|
-
- !ruby/object:Gem::Dependency
|
|
64
|
-
name: wrong
|
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
|
66
|
-
none: false
|
|
67
|
-
requirements:
|
|
68
|
-
- - ! '>='
|
|
69
|
-
- !ruby/object:Gem::Version
|
|
70
|
-
version: '0'
|
|
71
|
-
type: :development
|
|
72
|
-
prerelease: false
|
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
74
|
-
none: false
|
|
75
|
-
requirements:
|
|
76
|
-
- - ! '>='
|
|
77
|
-
- !ruby/object:Gem::Version
|
|
78
|
-
version: '0'
|
|
79
|
-
- !ruby/object:Gem::Dependency
|
|
80
|
-
name: rake
|
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
|
82
|
-
none: false
|
|
83
|
-
requirements:
|
|
84
|
-
- - ! '>='
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: '0'
|
|
87
|
-
type: :development
|
|
88
|
-
prerelease: false
|
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
90
|
-
none: false
|
|
91
|
-
requirements:
|
|
92
|
-
- - ! '>='
|
|
93
|
-
- !ruby/object:Gem::Version
|
|
94
|
-
version: '0'
|
|
95
|
-
- !ruby/object:Gem::Dependency
|
|
96
|
-
name: rr
|
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
|
98
|
-
none: false
|
|
99
|
-
requirements:
|
|
100
|
-
- - ! '>='
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0'
|
|
103
|
-
type: :development
|
|
104
|
-
prerelease: false
|
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
-
none: false
|
|
107
|
-
requirements:
|
|
108
|
-
- - ! '>='
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: debugger
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
none: false
|
|
115
|
-
requirements:
|
|
116
|
-
- - ! '>='
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
version: '0'
|
|
119
|
-
type: :development
|
|
120
|
-
prerelease: false
|
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
-
none: false
|
|
123
|
-
requirements:
|
|
124
|
-
- - ! '>='
|
|
125
|
-
- !ruby/object:Gem::Version
|
|
126
|
-
version: '0'
|
|
55
|
+
version: '0.4'
|
|
127
56
|
- !ruby/object:Gem::Dependency
|
|
128
57
|
name: cinch
|
|
129
58
|
requirement: !ruby/object:Gem::Requirement
|
|
130
|
-
none: false
|
|
131
59
|
requirements:
|
|
132
|
-
- - ~>
|
|
60
|
+
- - "~>"
|
|
133
61
|
- !ruby/object:Gem::Version
|
|
134
|
-
version: 2
|
|
62
|
+
version: '2'
|
|
135
63
|
type: :runtime
|
|
136
64
|
prerelease: false
|
|
137
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
138
|
-
none: false
|
|
139
66
|
requirements:
|
|
140
|
-
- - ~>
|
|
67
|
+
- - "~>"
|
|
141
68
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: 2
|
|
69
|
+
version: '2'
|
|
143
70
|
description: A collection of utility methods, mocks and methods for testing Cinch
|
|
144
71
|
plugins
|
|
145
72
|
email:
|
|
@@ -148,8 +75,8 @@ executables: []
|
|
|
148
75
|
extensions: []
|
|
149
76
|
extra_rdoc_files: []
|
|
150
77
|
files:
|
|
151
|
-
- .gitignore
|
|
152
|
-
- .travis.yml
|
|
78
|
+
- ".gitignore"
|
|
79
|
+
- ".travis.yml"
|
|
153
80
|
- Gemfile
|
|
154
81
|
- README.md
|
|
155
82
|
- Rakefile
|
|
@@ -157,32 +84,32 @@ files:
|
|
|
157
84
|
- lib/cinch/test.rb
|
|
158
85
|
- lib/cinch/test/version.rb
|
|
159
86
|
- spec/cinch_test_spec.rb
|
|
87
|
+
- spec/my_plugin.rb
|
|
160
88
|
- spec/spec_helper.rb
|
|
161
89
|
homepage: http://github.com/jayferd/cinch-test
|
|
162
|
-
licenses:
|
|
163
|
-
|
|
90
|
+
licenses:
|
|
91
|
+
- MIT
|
|
92
|
+
metadata: {}
|
|
93
|
+
post_install_message:
|
|
164
94
|
rdoc_options: []
|
|
165
95
|
require_paths:
|
|
166
96
|
- lib
|
|
167
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
|
-
none: false
|
|
169
98
|
requirements:
|
|
170
|
-
- -
|
|
99
|
+
- - ">="
|
|
171
100
|
- !ruby/object:Gem::Version
|
|
172
101
|
version: '0'
|
|
173
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
|
-
none: false
|
|
175
103
|
requirements:
|
|
176
|
-
- -
|
|
104
|
+
- - ">="
|
|
177
105
|
- !ruby/object:Gem::Version
|
|
178
106
|
version: '0'
|
|
179
107
|
requirements: []
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
specification_version: 3
|
|
108
|
+
rubygems_version: 3.2.6
|
|
109
|
+
signing_key:
|
|
110
|
+
specification_version: 4
|
|
184
111
|
summary: Helpers for testing Cinch Plugins
|
|
185
112
|
test_files:
|
|
186
113
|
- spec/cinch_test_spec.rb
|
|
114
|
+
- spec/my_plugin.rb
|
|
187
115
|
- spec/spec_helper.rb
|
|
188
|
-
has_rdoc:
|