Add specs for :matchers validation.

Akinori MUSHA 11 years ago
parent
commit
7428af37ef
1 changed files with 21 additions and 0 deletions
  1. 21 0
      spec/models/agents/event_formatting_agent_spec.rb

+ 21 - 0
spec/models/agents/event_formatting_agent_spec.rb

@@ -125,6 +125,27 @@ describe Agents::EventFormattingAgent do
125 125
       @checker.should_not be_valid
126 126
     end
127 127
 
128
+    it "should validate type of matchers" do
129
+      @checker.options[:matchers] = ""
130
+      @checker.should_not be_valid
131
+      @checker.options[:matchers] = {}
132
+      @checker.should_not be_valid
133
+    end
134
+
135
+    it "should validate the contents of matchers" do
136
+      @checker.options[:matchers] = [
137
+        {}
138
+      ]
139
+      @checker.options[:matchers] = [
140
+        { :regexp => "(not closed", :path => "text" }
141
+      ]
142
+      @checker.should_not be_valid
143
+      @checker.options[:matchers] = [
144
+        { :regexp => "(closed)", :path => "text", :to => "foo" }
145
+      ]
146
+      @checker.should be_valid
147
+    end
148
+
128 149
     it "should validate presence of mode" do
129 150
       @checker.options[:mode] = ""
130 151
       @checker.should_not be_valid