@@ -100,15 +100,17 @@ describe("validate", function() {
100100 expect ( pass ) . toHaveBeenCalledWithContext ( pass ) ;
101101 } ) ;
102102
103- it ( "calls the validator with the val, opts, key and attributes " , function ( ) {
103+ it ( "calls the validator with the val, opts, key, attributes and global options " , function ( ) {
104104 var options = { someOption : true }
105105 , attributes = { someAttribute : 'some value' }
106- , constraints = { someAttribute : { pass : options } } ;
107- validate . runValidations ( attributes , constraints , { } ) ;
106+ , constraints = { someAttribute : { pass : options } }
107+ , globalOptions = { someOption : 'some value' } ;
108+ validate . runValidations ( attributes , constraints , globalOptions ) ;
108109 expect ( pass ) . toHaveBeenCalledWith ( 'some value' ,
109110 options ,
110111 'someAttribute' ,
111- attributes ) ;
112+ attributes ,
113+ globalOptions ) ;
112114 } ) ;
113115
114116 it ( "returns an array of results" , function ( ) {
@@ -179,7 +181,7 @@ describe("validate", function() {
179181 , globalOptions = { foo : "bar" } ;
180182 validate . runValidations ( attrs , constraints , globalOptions ) ;
181183 expect ( spy ) . toHaveBeenCalledWith ( "Nicklas" , attrs , "name" , globalOptions , constraints ) ;
182- expect ( pass ) . toHaveBeenCalledWith ( "Nicklas" , options . pass , "name" , attrs ) ;
184+ expect ( pass ) . toHaveBeenCalledWith ( "Nicklas" , options . pass , "name" , attrs , globalOptions ) ;
183185 } ) ;
184186
185187 it ( "allows the options for a validator to be a function" , function ( ) {
@@ -190,7 +192,7 @@ describe("validate", function() {
190192 , globalOptions = { foo : "bar" } ;
191193 validate . runValidations ( attrs , constraints , globalOptions ) ;
192194 expect ( spy ) . toHaveBeenCalledWith ( "Nicklas" , attrs , "name" , globalOptions , constraints ) ;
193- expect ( pass ) . toHaveBeenCalledWith ( "Nicklas" , options , "name" , attrs ) ;
195+ expect ( pass ) . toHaveBeenCalledWith ( "Nicklas" , options , "name" , attrs , globalOptions ) ;
194196 } ) ;
195197
196198 it ( "doesnt run the validations if the options are falsy" , function ( ) {
@@ -213,7 +215,8 @@ describe("validate", function() {
213215 "bar" ,
214216 true ,
215217 "foo" ,
216- { foo : "bar" }
218+ { foo : "bar" } ,
219+ { }
217220 ) ;
218221
219222 validate ( $form , constraints ) ;
@@ -222,7 +225,8 @@ describe("validate", function() {
222225 "bar" ,
223226 true ,
224227 "foo" ,
225- { foo : "bar" }
228+ { foo : "bar" } ,
229+ { }
226230 ) ;
227231 } ) ;
228232 } ) ;
0 commit comments