rearview 1.0.3.rc.2-jruby → 1.0.3.rc.3-jruby

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,20 @@ describe Rearview::StatsService do
6
6
  Celluloid.boot
7
7
  @service = Rearview::StatsService.new
8
8
  end
9
+ context '#statsd' do
10
+ it "will yield to the block if stats are enabled" do
11
+ Rearview.config.stubs(:stats_enabled?).returns(true)
12
+ block_yielded = false
13
+ @service.statsd { |stats| block_yielded = true }
14
+ expect(block_yielded).to be_true
15
+ end
16
+ it "will not yield to the block if stats are disabled" do
17
+ Rearview.config.stubs(:stats_enabled?).returns(false)
18
+ block_yielded = false
19
+ @service.statsd { |stats| block_yielded = true }
20
+ expect(block_yielded).to be_false
21
+ end
22
+ end
9
23
  context '#startup' do
10
24
  it "can only be started if stopped" do
11
25
  Rearview::StatsTask.stubs(:supervise).returns(mock)
@@ -12,7 +12,7 @@ describe Rearview::StatsTask do
12
12
  it "sets the batch size correctly" do
13
13
  Rearview::StatsTask.any_instance.stubs(:schedule)
14
14
  statsd = mock
15
- statsd.expects(:batch_size=).with(11)
15
+ statsd.expects(:batch_size=).with(12)
16
16
  Rearview::Statsd.stubs(:new).returns(statsd)
17
17
  stats_task = Rearview::StatsTask.new
18
18
  end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Rearview::Statsd do
4
+ before(:all) do
5
+ Rearview.config.statsd_connection = { host: 'myhost', port: 123, namespace: 'mynamespace' }
6
+ end
7
+ let(:statsd) { Rearview::Statsd.new }
4
8
  context '.initialize' do
5
- before(:all) do
6
- Rearview.config.statsd_connection = { host: 'myhost', port: 123, namespace: 'mynamespace' }
7
- end
8
- let(:statsd) { Rearview::Statsd.new }
9
9
  it "sets the port from Rearview::Configuration" do
10
10
  expect(statsd.port).to eq(123)
11
11
  end
@@ -16,5 +16,24 @@ describe Rearview::Statsd do
16
16
  expect(statsd.namespace).to eq('mynamespace')
17
17
  end
18
18
  end
19
-
19
+ context '.statsd' do
20
+ it "returns a shared instance" do
21
+ expect(Rearview::Statsd.statsd).to eq(Rearview::Statsd.statsd)
22
+ expect(Rearview::Statsd.statsd).not_to be_nil
23
+ end
24
+ end
25
+ context '.report' do
26
+ it "will yield to the block if stats are enabled" do
27
+ Rearview.config.stubs(:stats_enabled?).returns(true)
28
+ block_yielded = false
29
+ Rearview::Statsd.report { |stats| block_yielded = true }
30
+ expect(block_yielded).to be_true
31
+ end
32
+ it "will not yield to the block if stats are disabled" do
33
+ Rearview.config.stubs(:stats_enabled?).returns(false)
34
+ block_yielded = false
35
+ Rearview::Statsd.report { |stats| block_yielded = true }
36
+ expect(block_yielded).to be_false
37
+ end
38
+ end
20
39
  end
@@ -56,7 +56,7 @@ describe Rearview::Job do
56
56
  end
57
57
  end
58
58
  end
59
- describe 'reset' do
59
+ describe '#reset' do
60
60
  it "should reset the job" do
61
61
  job = create(:job,:status=>Rearview::Job::Status::SUCCESS)
62
62
  job_data = create(:job_data,:job=>job)
@@ -82,7 +82,7 @@ describe Rearview::Job do
82
82
  expect(job.job_errors.size).to eq(0)
83
83
  end
84
84
  end
85
- describe 'destroy' do
85
+ describe '#destroy' do
86
86
  it "should unschedule the job" do
87
87
  job = create(:job)
88
88
  monitor_service = mock
@@ -91,7 +91,7 @@ describe Rearview::Job do
91
91
  job.destroy
92
92
  end
93
93
  end
94
- describe 'schedulable' do
94
+ describe '.schedulable' do
95
95
  it "should only return jobs eligible for scheduling" do
96
96
  j1 = create(:job,:active=>false)
97
97
  j2 = create(:job,:active=>true)
@@ -100,7 +100,7 @@ describe Rearview::Job do
100
100
  expect(schedulable.first).to eq(j2)
101
101
  end
102
102
  end
103
- describe 'schedule' do
103
+ describe '#schedule' do
104
104
  let(:monitor_service) { mock }
105
105
  let(:job) { create(:job) }
106
106
  it "should invoke the monitoring service to schedule the job" do
@@ -109,7 +109,7 @@ describe Rearview::Job do
109
109
  job.schedule
110
110
  end
111
111
  end
112
- describe 'unschedule' do
112
+ describe '#unschedule' do
113
113
  let(:monitor_service) { mock }
114
114
  let(:job) { create(:job) }
115
115
  it "should invoke the monitoring service to unschedule the job" do
@@ -118,7 +118,7 @@ describe Rearview::Job do
118
118
  job.unschedule
119
119
  end
120
120
  end
121
- describe 'sync_monitor_service' do
121
+ describe '#sync_monitor_service' do
122
122
  let(:monitor_service) { mock }
123
123
  it "should schedule an active job" do
124
124
  Rearview.stubs(:monitor_service).returns(monitor_service)
@@ -133,6 +133,16 @@ describe Rearview::Job do
133
133
  inactive_job.sync_monitor_service
134
134
  end
135
135
  end
136
+ describe '#report_transition' do
137
+ context 'success event' do
138
+ it "should increment monitor.success" do
139
+ end
140
+ end
141
+ context 'failure event' do
142
+ it "should increment monitor.failure" do
143
+ end
144
+ end
145
+ end
136
146
  context 'event' do
137
147
  def mock_creation_event(job,event)
138
148
  event_data = {:job_error=>{:message=>"foo"},:monitor_results=>{:x=>:y}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rearview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3.rc.2
4
+ version: 1.0.3.rc.3
5
5
  platform: jruby
6
6
  authors:
7
7
  - Trent Albright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails