spec/lita/handlers/onewheel_duckduckgo_spec.rb in lita-onewheel-duckduckgo-0.0.1 vs spec/lita/handlers/onewheel_duckduckgo_spec.rb in lita-onewheel-duckduckgo-0.0.2
- old
+ new
@@ -4,21 +4,30 @@
describe Lita::Handlers::OnewheelDuckDuckGo, lita_handler: true do
before(:each) do
end
+ def mock(file)
+ mock_result_json = File.open("spec/fixtures/#{file}.json").read
+ allow(RestClient).to receive(:get).and_return( mock_result_json)
+ end
+
it { is_expected.to route_command('duck something') }
it 'does neat ducky things' do
- mock_result_json = File.open('spec/fixtures/mock_result.json').read
- allow(RestClient).to receive(:get).and_return(JSON.parse mock_result_json)
+ mock('mock_result')
send_command 'duck yo'
expect(replies.last).to include('DuckDuckGo Result: DuckDuckGo is an Internet search engine that emphasizes')
end
it 'uses the url unless the abstract exists' do
- mock_result_json = File.open('spec/fixtures/mock_no_abstract.json').read
- allow(RestClient).to receive(:get).and_return(JSON.parse mock_result_json)
+ mock('mock_no_abstract')
send_command 'duck yo'
expect(replies.last).to include('DuckDuckGo Result: 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')
end
end