Add the outline of an observer by way of the heartbeat observer
This commit is contained in:
parent
3a39633ea7
commit
b95d2ba482
2
.rspec
2
.rspec
|
@ -1 +1 @@
|
|||
--order random --fail-fast --format doc
|
||||
--order random --fail-fast --format doc --color
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
require 'blick/events'
|
||||
|
||||
module Blick
|
||||
module Agent
|
||||
module Observers
|
||||
class Heartbeat
|
||||
#######################################################################
|
||||
### Observer registry/internals
|
||||
#######################################################################
|
||||
def self.name
|
||||
'Blick Internal Heartbeat'
|
||||
end
|
||||
|
||||
def self.description
|
||||
'An observer which emits periodic heartbeats'
|
||||
end
|
||||
|
||||
def self.enabled
|
||||
true
|
||||
end
|
||||
|
||||
# @return [Fixnum] number of seconds to run this observer
|
||||
def self.interval
|
||||
60
|
||||
end
|
||||
|
||||
def self.platforms
|
||||
@platforms ||= [:all]
|
||||
end
|
||||
|
||||
#######################################################################
|
||||
### Observer execution/runtime
|
||||
#######################################################################
|
||||
|
||||
def prepare
|
||||
end
|
||||
|
||||
def execute
|
||||
end
|
||||
|
||||
def cleanup
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
require 'spec_helper'
|
||||
require 'blick/agent/observers/heartbeat'
|
||||
|
||||
describe Blick::Agent::Observers::Heartbeat do
|
||||
it_behaves_like 'an Observer'
|
||||
end
|
|
@ -1,6 +1,10 @@
|
|||
require 'rspec'
|
||||
|
||||
$LOAD_PATH.unshift(File.expand_path(__FILE__) + '/../')
|
||||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
||||
|
||||
Dir[File.expand_path(File.dirname(__FILE__) + '/support/**/*.rb')].each do |f|
|
||||
load f
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
end
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
shared_examples 'an Observer' do
|
||||
context 'class methods' do
|
||||
subject(:observer) { described_class }
|
||||
|
||||
describe '.name' do
|
||||
subject { observer.name }
|
||||
it { should be_instance_of String }
|
||||
end
|
||||
|
||||
describe '.description' do
|
||||
subject { observer.description }
|
||||
it { should be_instance_of String }
|
||||
end
|
||||
|
||||
describe '.interval' do
|
||||
subject { observer.interval }
|
||||
|
||||
it { should be_instance_of Fixnum }
|
||||
it { should be > 0 }
|
||||
end
|
||||
|
||||
it { should respond_to :enabled }
|
||||
|
||||
describe '.platforms' do
|
||||
subject { observer.platforms }
|
||||
it { should be_instance_of Array }
|
||||
end
|
||||
end
|
||||
|
||||
context 'instance methods' do
|
||||
let(:observer) { described_class.new }
|
||||
it { should respond_to :prepare }
|
||||
it { should respond_to :execute }
|
||||
it { should respond_to :cleanup }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue