airbrake-statsd 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@ module Airbrake
32
32
 
33
33
  def increment
34
34
  return unless configured?
35
- client.increment('exceptions')
35
+ client.increment(config.bucket)
36
36
  end
37
37
 
38
38
  end # << self
@@ -14,6 +14,11 @@ module Airbrake
14
14
  end
15
15
  attr_writer :port
16
16
 
17
+ def bucket
18
+ @bucket ||= 'exceptions'
19
+ end
20
+ attr_writer :bucket
21
+
17
22
  end # Configuration
18
23
  end # Statsd
19
24
  end # Airbrake
@@ -1,5 +1,5 @@
1
1
  module Airbrake
2
2
  module Statsd
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -37,6 +37,17 @@ module Airbrake
37
37
  end
38
38
  end
39
39
 
40
+ describe '`bucket` option' do
41
+ it 'defaults to "exceptions"' do
42
+ subject.bucket.should == 'exceptions'
43
+ end
44
+
45
+ it 'can be set' do
46
+ subject.bucket = 'errors'
47
+ subject.bucket.should == 'errors'
48
+ end
49
+ end
50
+
40
51
  end
41
52
  end
42
53
  end
@@ -6,11 +6,26 @@ module Airbrake
6
6
  subject { Statsd }
7
7
 
8
8
  before do
9
- subject.instance_variable_set('@configured', nil)
10
- subject.instance_variable_set('@config', nil)
11
- subject.instance_variable_set('@client', nil)
9
+ ['@configured', '@config', '@client'].each do |var_name|
10
+ subject.instance_variable_set(var_name, nil)
11
+ end
12
12
  end
13
13
 
14
+ describe '#configure' do
15
+ it 'sets @configured to true' do
16
+ subject.instance_variable_get('@configured').should_not be_true
17
+ subject.configure
18
+ subject.instance_variable_get('@configured').should be_true
19
+ end
20
+
21
+ context 'when block is passed' do
22
+ it 'passes #config to block' do
23
+ block = Proc.new { |conf| conf.should be_a(Statsd::Configuration) }
24
+ subject.configure(&block)
25
+ end
26
+ end # block passed
27
+ end # configure
28
+
14
29
  describe '#configured?' do
15
30
  context 'when #configure has been called' do
16
31
  it 'returns true' do
@@ -30,7 +45,7 @@ module Airbrake
30
45
  it 'creates new Configuration instance if not set' do
31
46
  subject.config.should be_a(Statsd::Configuration)
32
47
  end
33
- end
48
+ end # config
34
49
 
35
50
  describe '#client' do
36
51
  it 'creates a new ::Statsd client instance if not set' do
@@ -49,23 +64,36 @@ module Airbrake
49
64
  ::Statsd.any_instance.should_receive(:namespace=).with('test').once
50
65
  subject.client
51
66
  end
52
- end
53
- end
67
+ end # namespace is set
68
+ end # client
54
69
 
55
70
  describe '#increment' do
56
71
  context 'when #configure has been called' do
57
72
  before { subject.configure }
58
73
 
59
- it 'calls #increment on #client instance' do
60
- subject.client.should_receive(:increment).once
74
+ it 'calls #increment on #client' do
75
+ subject.client.should_receive(:increment).with('exceptions').once
61
76
  subject.increment
62
77
  end
63
78
 
64
- it 'default bucket name used is "exceptions"' do
65
- subject.client.should_receive(:increment).with('exceptions').once
79
+ context 'when bucket option has been customized' do
80
+ before do
81
+ subject.configure { |config| config.bucket = 'errors' }
82
+ end
83
+
84
+ it 'calls #increment on #client with custom bucket' do
85
+ subject.client.should_receive(:increment).with('errors').once
86
+ subject.increment
87
+ end
88
+ end # bucket option customized
89
+ end # configure called
90
+
91
+ context 'when #configure has not been called' do
92
+ it 'does not call #increment on #client' do
93
+ subject.client.should_not_receive(:increment)
66
94
  subject.increment
67
95
  end
68
- end # configure called
96
+ end # configure not called
69
97
  end # increment
70
98
 
71
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70264029721400 !ruby/object:Gem::Requirement
16
+ requirement: &70244425362220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70264029721400
24
+ version_requirements: *70244425362220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70264029719960 !ruby/object:Gem::Requirement
27
+ requirement: &70244425360740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70264029719960
35
+ version_requirements: *70244425360740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: simplecov
38
- requirement: &70264029719260 !ruby/object:Gem::Requirement
38
+ requirement: &70244425359980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70264029719260
46
+ version_requirements: *70244425359980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: airbrake
49
- requirement: &70264029718620 !ruby/object:Gem::Requirement
49
+ requirement: &70244425359340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70264029718620
57
+ version_requirements: *70244425359340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: statsd-ruby
60
- requirement: &70264029717780 !ruby/object:Gem::Requirement
60
+ requirement: &70244425358600 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70264029717780
68
+ version_requirements: *70244425358600
69
69
  description: Increment an exception counter in StatsD whenever the Airbrake gem reports
70
70
  and exception.
71
71
  email:
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  segments:
104
104
  - 0
105
- hash: 2958165307938427188
105
+ hash: -2772850285584878905
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: 2958165307938427188
114
+ hash: -2772850285584878905
115
115
  requirements: []
116
116
  rubyforge_project:
117
117
  rubygems_version: 1.8.11