Skip to content

Commit

Permalink
Address problems with ambient match
Browse files Browse the repository at this point in the history
  • Loading branch information
esigler committed Feb 26, 2016
1 parent 63166b5 commit 5f291c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jirahelper/regex.rb
Expand Up @@ -8,6 +8,6 @@ module Regex
PROJECT_PATTERN = /(?<project>[a-zA-Z0-9]{1,10})/
ISSUE_PATTERN = /(?<issue>#{PROJECT_PATTERN}-[0-9]{1,5}+)/
EMAIL_PATTERN = /(?<email>[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+)/i
AMBIENT_PATTERN = /\s#{ISSUE_PATTERN}/
AMBIENT_PATTERN = /(\s|^)#{ISSUE_PATTERN}/
end
end
5 changes: 4 additions & 1 deletion spec/lita/handlers/jira_spec.rb
Expand Up @@ -189,9 +189,10 @@
end

it 'shows details for a detected issue in a message' do
send_message('XYZ-987')
send_message('foo XYZ-987 bar')
send_message('foo XYZ-987?')
expect(replies.size).to eq(2)
expect(replies.size).to eq(3)
end

it 'does not show details for a detected issue in a command' do
Expand All @@ -200,8 +201,10 @@
end

it 'does not show details for a issue in a URL-ish context' do
send_message('http://www.example.com/XYZ-987')
send_message('http://www.example.com/XYZ-987.html')
send_message('http://www.example.com/someother-XYZ-987.html')
send_message('TIL http://ruby-doc.org/core-2.3.0/Enumerable.html#method-i-each_slice')
expect(replies.size).to eq(0)
end

Expand Down

0 comments on commit 5f291c7

Please sign in to comment.