Check regexp validation.

Akinori MUSHA 10 anni fa
parent
commit
f3a63b935f
1 ha cambiato i file con 18 aggiunte e 0 eliminazioni
  1. 18 0
      spec/models/agents/imap_folder_agent_spec.rb

+ 18 - 0
spec/models/agents/imap_folder_agent_spec.rb

@@ -104,6 +104,24 @@ describe Agents::ImapFolderAgent do
104 104
         @checker.options['ssl'] = 'true'
105 105
         @checker.should_not be_valid
106 106
       end
107
+
108
+      it 'should validate regexp conditions' do
109
+        @checker.options['conditions'] = {
110
+          'subject' => '(foo'
111
+        }
112
+        @checker.should_not be_valid
113
+
114
+        @checker.options['conditions'] = {
115
+          'body' => '***'
116
+        }
117
+        @checker.should_not be_valid
118
+
119
+        @checker.options['conditions'] = {
120
+          'subject' => '\ARe:',
121
+          'body' => '(?<foo>http://\S+)'
122
+        }
123
+        @checker.should be_valid
124
+      end
107 125
     end
108 126
 
109 127
     describe '#check' do