Updated mcollective.init according to OSCI-658
[packages/precise/mcollective.git] / spec / unit / plugins / mcollective / validator / array_validator_spec.rb
diff --git a/spec/unit/plugins/mcollective/validator/array_validator_spec.rb b/spec/unit/plugins/mcollective/validator/array_validator_spec.rb
new file mode 100644 (file)
index 0000000..f32fa6d
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require File.dirname(__FILE__) + '/../../../../../plugins/mcollective/validator/array_validator.rb'
+
+module MCollective
+  module Validator
+    describe "#validate" do
+      it "should raise an exception if a given element is not defined in a given array" do
+        expect{
+          Validator::ArrayValidator.validate("element1",["element0", "element2"])
+        }.to raise_error(ValidatorError, "value should be one of element0, element2")
+      end
+
+      it "should not raise an exception if a given element is defined in a given array" do
+        Validator::ArrayValidator.validate("element1", ["element1", "element2"])
+      end
+    end
+  end
+end