Skip to content

Commit

Permalink
Simplified result
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Sep 13, 2018
1 parent 5e3e3c4 commit 0dfbe84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/lita/handlers/onewheel_duckduckgo.rb
Expand Up @@ -13,11 +13,10 @@ def search(response)
Lita.logger.debug "Querying for #{query}"
result = get_result(query)
Lita.logger.debug "Result: #{result}"
reply = 'DuckDuckGo Result: '
if result['Abstract'].empty?
reply += result['AbstractURL']
reply = result['AbstractURL']
else
reply += result['Abstract'][0..250]
reply = result['Abstract'][0..250]
end
Lita.logger.debug "Reply: #{reply}"
response.reply reply
Expand Down
2 changes: 1 addition & 1 deletion lita-onewheel-duckduckgo.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'lita-onewheel-duckduckgo'
spec.version = '0.0.4'
spec.version = '0.0.5'
spec.authors = ['Andrew Kreps']
spec.email = ['andrew.kreps@gmail.com']
spec.description = 'Lita handler for Duck Duck Go\'s answers engine.'
Expand Down
6 changes: 3 additions & 3 deletions spec/lita/handlers/onewheel_duckduckgo_spec.rb
Expand Up @@ -18,18 +18,18 @@ def mock(file)
it 'does neat ducky things' do
mock('mock_result')
send_command 'duck yo'
expect(replies.last).to include('DuckDuckGo Result: DuckDuckGo is an Internet search engine that emphasizes')
expect(replies.last).to include('DuckDuckGo is an Internet search engine that emphasizes')
end

it 'uses the url unless the abstract exists' do
mock('mock_no_abstract')
send_command 'duck yo'
expect(replies.last).to include('DuckDuckGo Result: https://en.wikipedia.org/wiki/Duck_(disambiguation)')
expect(replies.last).to include('https://en.wikipedia.org/wiki/Duck_(disambiguation)')
end

it 'checks for go' do
mock('mock_go')
send_command 'duck go'
expect(replies.last).to include('DuckDuckGo Result: https://en.wikipedia.org/wiki/Go')
expect(replies.last).to include('https://en.wikipedia.org/wiki/Go')
end
end

0 comments on commit 0dfbe84

Please sign in to comment.