Sha256: 652eae8ec964b64f1735aae7abefb837d5d4034399a26924bd1ff4926c5a8f56

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

require 'spec_helper'
require "zabbix-ruby-client/plugins"

describe ZabbixRubyClient::Plugins do

  before :all do
    @plugindir = File.expand_path("../../files/plugins", __FILE__)
  end

  before :each do
    ZabbixRubyClient::Plugins.scan_dirs([@plugindir])
  end

  after :each do
    ZabbixRubyClient::Plugins.reset
  end

  it "loading dirs works" do
    result = {"sample" => File.join(@plugindir, "sample.rb") }
    expect(ZabbixRubyClient::Plugins.instance_variable_get(:@available)).to eq result 
  end

  it "registering a new plugin loads it" do
    ZabbixRubyClient::Plugins.register("sample",Object)
    result = { "sample" => Object }
    expect(ZabbixRubyClient::Plugins.instance_variable_get(:@loaded)).to eq result
  end

  it "loading a plugin adds plugin in loaded list" do
    ZabbixRubyClient::Plugins.load("sample")
    expect(Sample).to be_kind_of Module
  end

  it "do not load a plugin already loaded" do
    ZabbixRubyClient::Plugins.load("sample")
    ZabbixRubyClient::Plugins.load("sample")
    result = { "sample" => Sample }
    expect(ZabbixRubyClient::Plugins.instance_variable_get(:@loaded)).to eq result
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.0.17 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.16 spec/lib/plugins_spec.rb