Skip to content

Commit d89b87b

Browse files
committed
Test: introduce webmock
1 parent a341dc6 commit d89b87b

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

sensu-plugins-trello.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
2424
spec.add_development_dependency 'rake', '~> 10.0'
2525
spec.add_development_dependency 'rspec', '~> 3.7'
2626
spec.add_development_dependency 'rubocop', '~> 0.54'
27+
spec.add_development_dependency 'webmock', '~> 3.3'
2728
end
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1+
require 'webmock/rspec'
2+
13
require_relative './plugin_stub.rb'
24
require_relative '../bin/check-trello-incidents.rb'
35

46
describe CheckTrelloIncidents do
57
it 'should run' do
8+
stub_request(
9+
:get,
10+
'https://api.trello.com//1/lists/abcde/cards/?key=12345&token=12345'
11+
).to_return(body: '[]', status: 200)
12+
613
check = CheckTrelloIncidents.new
714
check.config[:api_key] = '12345'
815
check.config[:api_token] = '12345'
916
check.config[:list] = 'abcde'
10-
expect(-> { check.run }).to raise_error Net::HTTPServerException
17+
18+
expect(check).to receive(:output).with('No new incidents')
19+
expect(-> { check.run }).to raise_error SystemExit
1120
end
1221
end

0 commit comments

Comments
 (0)