Sha256: 1fd9e118467f159f770e46e75e3713050e70e1c48ac25f1e0d7c8d3d5d1a18e6

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 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"),
               "sample_discover" => File.join(@plugindir, "sample_discover.rb"),
               "sample_buggy" => File.join(@plugindir, "sample_buggy.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

10 entries across 10 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.1.3 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.1.2 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.1.1 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.1.0 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.23 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.22 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.21 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.20 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.19 spec/lib/plugins_spec.rb
zabbix-ruby-client-0.0.18 spec/lib/plugins_spec.rb