cognition 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06462dac8c1c3f92692619d523bc9f1a58fc4de4
4
- data.tar.gz: db097768b8ff030201e53fb93f3aaf1efb8c997d
3
+ metadata.gz: 1b37fef34af5c88fc16e34dd5855d50d6c214ec4
4
+ data.tar.gz: aab660a7e21a9324369638de7fd663d39c32efda
5
5
  SHA512:
6
- metadata.gz: c9a2814d94865711e1605188d017ccd865a416c714b9e6d21b15dba5691862119b6d425cc0696f9fbe1fed932744e3e1bbb4dda8c760d3614181b1471aa2a483
7
- data.tar.gz: e8ab955d9bbe0862248e6b233c0e7dd2212db532ba342a145cb8d4264ceca1f5657ce9f00a3ff321bca53732f30652cee37161a7c10f0129e06bb8f90ed81794
6
+ metadata.gz: 5b34e06406f19030648972a5b1fa157b33fde810306d11a948f74ae8f306edb5a99552d06df855387f327b96f49b91ea8464ca1769c0596abbbe7380a8cf1943
7
+ data.tar.gz: 793bab140adef11717fba95d70d6cc625b6c20ea5f2d89b0628931288d231b8fab91a80892116615300d77a8815b2b5e17ebb946fc0ca4f6fd1710f2ac0747a2
@@ -24,6 +24,8 @@ module Cognition
24
24
 
25
25
  def run(msg)
26
26
  @response = action.call(msg, match_data)
27
+ rescue => e
28
+ @response = "'#{msg.command}' found, but raised #{e.inspect}"
27
29
  end
28
30
 
29
31
  def matches?(msg)
@@ -1,3 +1,3 @@
1
1
  module Cognition
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require 'tilt/haml'
2
- require 'tilt/erubis'
2
+ require 'tilt/erb'
3
3
  require 'haml'
4
4
  class Hello < Cognition::Plugins::Base
5
5
  match 'hello', :hello, help: {
@@ -7,12 +7,12 @@ class DefaultPluginTest < Minitest::Test
7
7
  end
8
8
 
9
9
  def test_returns_help
10
- help = "ping - Test if the endpoint is responding. Returns PONG.\nhelp - Lists all commands with help\nhelp <command> - Lists help for <command>\n"
10
+ help = "ping - Test if the endpoint is responding. Returns PONG.\nhelp - Lists all commands with help\nhelp <command> - Lists help for <command>"
11
11
  assert_equal help, @bot.process("help")
12
12
  end
13
13
 
14
14
  def test_returns_filtered_help
15
- help = "ping - Test if the endpoint is responding. Returns PONG.\n"
15
+ help = "ping - Test if the endpoint is responding. Returns PONG."
16
16
  assert_equal help, @bot.process("help ping")
17
17
  end
18
18
  end
data/test/test_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'webmock/test_unit'
1
+ require 'webmock/minitest'
2
2
 
3
3
  class Minitest::Test
4
4
  include WebMock::API
data/test/test_matcher.rb CHANGED
@@ -74,8 +74,18 @@ class MatcherTest < Minitest::Test
74
74
  matcher_with_help = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {help: {'hello' => 'says hello'}}, &Proc.new(&method(:dummy_method)))
75
75
  assert_equal ['hello - says hello'], matcher_with_help.help
76
76
  end
77
+
78
+ def test_returns_error_if_method_returns_an_error
79
+ msg = Cognition::Message.new('error')
80
+ matcher_with_error = Cognition::Matcher.new(/error/, &Proc.new(&method(:error_method)))
81
+ assert matcher_with_error.attempt(msg).match("'error' found, but raised")
82
+ end
77
83
  end
78
84
 
79
85
  def dummy_method(msg, match_data)
80
86
  "Hello #{match_data['name']}"
81
87
  end
88
+
89
+ def error_method(*)
90
+ foobarcall
91
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cognition
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty