pagerduty_cli 0.0.4 → 0.0.5

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: 63d63600cb5729742bd2b47280d77c66074c1712
4
- data.tar.gz: 57b142a6854618ea24381a83f8cb078e5678d397
3
+ metadata.gz: 220d49ae420dba05e82c0470f3347e1e80fac11b
4
+ data.tar.gz: 50c4e17385bd93995d916faedda383689f10e093
5
5
  SHA512:
6
- metadata.gz: cd3fc0f5c1f2d26e58fd3c9884ebd9a96991b4cbd217419cc81f9fea8b36b23150d85e84238bac2333cf5ec3f0dd72f2adda3622e129ee53cd96e79001e0280a
7
- data.tar.gz: e174205d5a89d92e2dbac67176c7eecb1371965cffa8c1b1d906c2d0276a9666495600ab107020e728041d802ba9111b452395f8ed7bb16852908d4b0f28ebb8
6
+ metadata.gz: b94437c151683aa608e2ca42c755a68f6d4738a14f34159a80b179b29f664429341a9a070b9f385428cd9616f84eb380c9e7c8ef48c749ae2e66834733b50dbe
7
+ data.tar.gz: d72ca04f4baf7c74dcfeee72effbc615d9a245dbe0e9d1a69d8116da67feb8847cc328b33fff352f5fbe445e5e7ccc525c44f3c77629997b16094648ccc2daf3
@@ -57,5 +57,11 @@ module PagerdutyCli
57
57
  end
58
58
  end
59
59
  # rubocop:enable MethodLength
60
+
61
+ # croak if required options are not present
62
+ def require_event
63
+ return if @options[:event]
64
+ croak('Error: event option is required. Run with -h to see usage.')
65
+ end
60
66
  end
61
67
  end
@@ -5,6 +5,7 @@ module PagerdutyCli
5
5
  def initialize(args)
6
6
  @me = 'pagerduty_resolve'
7
7
  parse_opts(args)
8
+ require_event
8
9
  load_data
9
10
  end
10
11
 
@@ -13,6 +13,7 @@ module PagerdutyCli
13
13
  def initialize(args)
14
14
  @me = 'pagerduty_trigger'
15
15
  parse_opts(args)
16
+ require_event
16
17
  load_data
17
18
  return unless @options[:force] || !incident_is_too_fresh?
18
19
  touch_incident_file unless @options[:no_touch]
@@ -1,4 +1,4 @@
1
1
  # PagerDuty CLI
2
2
  module PagerdutyCli
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
@@ -81,6 +81,18 @@ describe PagerdutyCli do
81
81
  expect(stub_actor.options[:event]).to eq('foo')
82
82
  end
83
83
 
84
+ it 'returns an error when no event is specified' do
85
+ args = []
86
+ stub_actor = StubPagerdutyCliActor.new
87
+ stub_actor.options[:event] = nil
88
+ allow($stderr).to receive(:puts)
89
+ stub_optionparser = OptionParser.new
90
+ stub_actor.parse_common_options(stub_optionparser)
91
+ stub_optionparser.parse!(args)
92
+ expect { stub_actor.require_event }.to raise_error(SystemExit)
93
+ expect($stderr).to have_received(:puts)
94
+ end
95
+
84
96
  it 'prints help and exits with -h' do
85
97
  args = %w(-h)
86
98
  stub_actor = StubPagerdutyCliActor.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagerduty_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Dossey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-07 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pagerduty