Sha256: 10759d3df8ee476c79cf5a22e2b065466c839511b564adaba4d0a3d09a8abc60

Contents?: true

Size: 1.64 KB

Versions: 13

Compression:

Stored size: 1.64 KB

Contents

#encoding: utf-8

require 'riemann/babbler'
require 'riemann/babbler/version'
require 'riemann/babbler/start'
require 'configatron'

opts = Hash.new
opts[:config] = File.expand_path('../config.yml', __FILE__)

babbler = Riemann::Babbler::Starter.new(opts, configatron)

describe Riemann::Babbler do

  it 'Merge config' do
    babbler.merge_config
    configatron.riemann.host.should eq 'hostname_does_not_exists'
  end

  it 'Set logger lvl' do
    babbler.set_logger_config
    babbler.logger.level.should eq 4
  end

  it 'Load plugins' do
    babbler.load_plugins
    Riemann::Babbler.registered_plugins.should include( Riemann::Babbler::Dummy )
  end

  it 'Started plugins' do
    babbler.started_plugins.should include( Riemann::Babbler::Dummy )
  end

  it 'Parent plugins' do
    babbler.started_plugins.should include( Riemann::Babbler::Dummy2 )
  end

  it 'Custom parent plugin start' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    configatron.plugins.dummy2.to_hash.should include(:run => false)
    dummyplugin.plugin.run.should eq false
    dummyplugin.plugin.interval.should eq 2000 
    dummyplugin.run.should eq 0
  end

  it 'Shell helper' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    dummyplugin.shell("echo 'a' | wc -l").to_i.should eq 1
  end

  it 'RestGet helper' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    dummyplugin.rest_get('http://ya.ru').should include 'yandex.ru'
  end

  it 'TcpPortAviable helper' do
    dummyplugin = Riemann::Babbler::Dummy2.new(configatron, nil, nil)
    dummyplugin.tcp_port_aviable?('www.ya.ru', 80).should eq true
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
riemann-babbler-1.4.0 spec/default.rb
riemann-babbler-1.3.9.7 spec/default.rb
riemann-babbler-1.3.9.6 spec/default.rb
riemann-babbler-1.3.9.5 spec/default.rb
riemann-babbler-1.3.9.4 spec/default.rb
riemann-babbler-1.3.9.3 spec/default.rb
riemann-babbler-1.3.9.1 spec/default.rb
riemann-babbler-1.3.9 spec/default.rb
riemann-babbler-1.3.8 spec/default.rb
riemann-babbler-1.3.7 spec/default.rb
riemann-babbler-1.3.6 spec/default.rb
riemann-babbler-1.3.5 spec/default.rb
riemann-babbler-1.3.4 spec/default.rb