1#!/usr/bin/env rspec 2 3require 'spec_helper' 4require File.expand_path(File.join(File.dirname(__FILE__), "../../validator/puppet_tags_validator.rb")) 5 6module MCollective 7 module Validator 8 describe Puppet_tagsValidator do 9 it "should expect strings" do 10 Validator.expects(:typecheck).with(1, :string).raises("not a string") 11 expect { Puppet_tagsValidator.validate(1) }.to raise_error("not a string") 12 end 13 14 it "should expect shellsafe strings" do 15 Validator.expects(:typecheck).with(1, :string) 16 Validator.expects(:validate).with(1, :shellsafe).raises("not shellsafe") 17 18 expect { Puppet_tagsValidator.validate(1) }.to raise_error("not shellsafe") 19 end 20 21 it "should validate each supplied part as a valid variable" do 22 Validator.stubs(:typecheck) 23 Validator.stubs(:validate) 24 Validator.expects(:validate).with("one", :puppet_variable) 25 Validator.expects(:validate).with("two", :puppet_variable) 26 Validator.expects(:validate).with("three", :puppet_variable) 27 28 Puppet_tagsValidator.validate("one,two::three") 29 end 30 end 31 end 32end 33