hoptoad_handler 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
- source "http://rubygems.org"
1
+ source :rubygems
2
+
3
+ gem "minitest", :platform => :ruby_18
4
+ gem "rake"
2
5
 
3
6
  gemspec
data/README.rdoc CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Report chef exceptions to hoptoad.
4
4
 
5
+ Works fine with chef versions: 0.9.x and 0.10.x
6
+
5
7
  == Usage
6
8
 
7
9
  gem install hoptoad_handler
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency("chef", "~> 0.9.0")
22
+ s.add_dependency("chef", ">= 0.9.0")
23
23
  s.add_dependency("toadhopper")
24
24
 
25
- s.add_development_dependency("test-unit", "~> 2.2.0")
25
+ s.add_development_dependency("mocha")
26
26
  end
@@ -16,12 +16,11 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef"
20
19
  require "chef/handler"
21
20
  require "toadhopper"
22
21
 
23
22
  class HoptoadHandler < Chef::Handler
24
- VERSION = "0.1.2"
23
+ VERSION = "0.1.3"
25
24
 
26
25
  attr_accessor :options, :api_key
27
26
 
@@ -53,7 +52,7 @@ class HoptoadHandler < Chef::Handler
53
52
  end
54
53
 
55
54
  def client
56
- raise "You must specify Hoptoad api key" unless api_key
55
+ raise ArgumentError.new("You must specify Hoptoad api key") unless api_key
57
56
  Toadhopper.new(api_key)
58
57
  end
59
58
  end
data/test/helper.rb CHANGED
@@ -1,7 +1,6 @@
1
- require 'rubygems'
2
- gem 'test-unit'
3
- require 'test/unit'
1
+ require "bundler/setup"
4
2
 
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'hoptoad_handler'
3
+ require "minitest/autorun"
4
+ require "mocha"
5
+
6
+ require "hoptoad_handler"
@@ -1,22 +1,39 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
- class HoptoadHandlerTest < Test::Unit::TestCase
4
- test "raise error when api_key is not specified" do
5
- assert_raise_message("You must specify Hoptoad api key") do
6
- HoptoadHandler.new.client
7
- end
3
+ describe HoptoadHandler do
4
+ before do
5
+ Chef::Log.stubs(:error)
8
6
  end
9
7
 
10
- test "not raise error when api_key is specified" do
11
- assert_nothing_raised do
12
- HoptoadHandler.new(:api_key => "fake").client
8
+ it "should raise error when api_key is not specified" do
9
+ assert_raises ArgumentError do
10
+ HoptoadHandler.new.client
13
11
  end
14
12
  end
15
13
 
16
- test "setting options" do
14
+ it "should setting options" do
17
15
  handler = HoptoadHandler.new(:framework_env => "staging")
18
16
  assert_equal "staging", handler.options[:framework_env]
19
17
  end
20
18
 
21
- # TODO: write more tests
19
+ it "should reporting exception using client" do
20
+ run_status = stub(:failed? => true, :exception => "Exception")
21
+ client = mock
22
+ handler = HoptoadHandler.new(:api_key => "fake")
23
+ handler.stubs(:run_status).returns(run_status)
24
+ handler.stubs(:client).returns(client)
25
+ handler.stubs(:hoptoad_params).returns({})
26
+
27
+ client.expects(:post!).with("Exception", {})
28
+ handler.report
29
+ end
30
+
31
+ it "should returning hoptoad params" do
32
+ node = stub(:name => "node-name", :run_list => "cookbook::recipe")
33
+ run_status = stub(:node => node, :start_time => Time.mktime(2011,1,1),
34
+ :end_time => Time.mktime(2011,1,2), :elapsed_time => Time.mktime(2011,1,3))
35
+ handler = HoptoadHandler.new(:api_key => "fake")
36
+ handler.stubs(:run_status => run_status)
37
+ assert_equal Hash, handler.hoptoad_params.class
38
+ end
22
39
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoptoad_handler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
5
+ version: 0.1.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Adam Jacob
@@ -16,8 +11,7 @@ autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
13
 
19
- date: 2011-03-16 00:00:00 +01:00
20
- default_executable:
14
+ date: 2011-05-06 00:00:00 Z
21
15
  dependencies:
22
16
  - !ruby/object:Gem::Dependency
23
17
  name: chef
@@ -25,13 +19,8 @@ dependencies:
25
19
  requirement: &id001 !ruby/object:Gem::Requirement
26
20
  none: false
27
21
  requirements:
28
- - - ~>
22
+ - - ">="
29
23
  - !ruby/object:Gem::Version
30
- hash: 59
31
- segments:
32
- - 0
33
- - 9
34
- - 0
35
24
  version: 0.9.0
36
25
  type: :runtime
37
26
  version_requirements: *id001
@@ -43,26 +32,18 @@ dependencies:
43
32
  requirements:
44
33
  - - ">="
45
34
  - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
35
  version: "0"
50
36
  type: :runtime
51
37
  version_requirements: *id002
52
38
  - !ruby/object:Gem::Dependency
53
- name: test-unit
39
+ name: mocha
54
40
  prerelease: false
55
41
  requirement: &id003 !ruby/object:Gem::Requirement
56
42
  none: false
57
43
  requirements:
58
- - - ~>
44
+ - - ">="
59
45
  - !ruby/object:Gem::Version
60
- hash: 7
61
- segments:
62
- - 2
63
- - 2
64
- - 0
65
- version: 2.2.0
46
+ version: "0"
66
47
  type: :development
67
48
  version_requirements: *id003
68
49
  description: Chef handler for sending exceptions to Hoptoad
@@ -85,7 +66,6 @@ files:
85
66
  - lib/hoptoad_handler.rb
86
67
  - test/helper.rb
87
68
  - test/hoptoad_notifier_test.rb
88
- has_rdoc: true
89
69
  homepage: https://github.com/morgoth/hoptoad_handler
90
70
  licenses: []
91
71
 
@@ -99,23 +79,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
79
  requirements:
100
80
  - - ">="
101
81
  - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
82
  version: "0"
106
83
  required_rubygems_version: !ruby/object:Gem::Requirement
107
84
  none: false
108
85
  requirements:
109
86
  - - ">="
110
87
  - !ruby/object:Gem::Version
111
- hash: 3
112
- segments:
113
- - 0
114
88
  version: "0"
115
89
  requirements: []
116
90
 
117
91
  rubyforge_project: hoptoad_handler
118
- rubygems_version: 1.6.2
92
+ rubygems_version: 1.8.1
119
93
  signing_key:
120
94
  specification_version: 3
121
95
  summary: Chef handler for sending exceptions to Hoptoad