mv-mysql 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6734508bbd406ea2b3098a8a4c7616b5fc671ac
4
+ data.tar.gz: 2739c21e946bec792a83c1b2304e82666894162d
5
+ SHA512:
6
+ metadata.gz: 7ffdff553b0935411404f0b07006cd962c64734dd9024224fe9b2518a94ca12adcb45bd3e3f2cb7ce22502d3b64873086aedce4fcdf9e7400298df0de293b353
7
+ data.tar.gz: c41929b80547e334441ba0c3e1c95b31c218ffeca93017bfc443b8db88927b713e9ce422fa787f9ff63e02199820f6e28b2d1b430172c50f7d8bcd52ccf43ed8
@@ -98,5 +98,6 @@ module MigrationValidators
98
98
  end
99
99
 
100
100
  MigrationValidators.register_adapter! "mysql", Mysql
101
+ MigrationValidators.register_adapter! "mysql2", Mysql
101
102
  end
102
103
  end
metadata CHANGED
@@ -1,122 +1,91 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mv-mysql
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Valeriy Prokopchuk
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-03-22 00:00:00 +02:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: mysql
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mysql2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
24
20
  type: :runtime
25
21
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
28
  name: mv-core
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
45
40
  version: 1.0.0
46
- type: :development
47
- prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
41
+ - !ruby/object:Gem::Dependency
50
42
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 1.5.2
57
- type: :development
58
- prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rcov
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
68
48
  type: :development
69
49
  prerelease: false
70
- version_requirements: *id005
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
71
55
  description: Migration Validators project mysql driver
72
56
  email: vprokopchuk@gmail.com
73
57
  executables: []
74
-
75
58
  extensions: []
76
-
77
- extra_rdoc_files:
59
+ extra_rdoc_files:
78
60
  - LICENSE.txt
79
61
  - README.rdoc
80
- files:
62
+ files:
81
63
  - lib/migration_validators/adapters/mysql.rb
82
64
  - lib/mv-mysql.rb
83
65
  - LICENSE.txt
84
66
  - README.rdoc
85
- - spec/migration_validators/adapters/mysql_spec.rb
86
- - spec/mv-mysql_spec.rb
87
- - spec/spec_helper.rb
88
- has_rdoc: true
89
67
  homepage: http://github.com/vprokopchuk256/mv-mysql
90
- licenses:
68
+ licenses:
91
69
  - MIT
70
+ metadata: {}
92
71
  post_install_message:
93
72
  rdoc_options: []
94
-
95
- require_paths:
73
+ require_paths:
96
74
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: -586620678866749772
103
- segments:
104
- - 0
105
- version: "0"
106
- required_rubygems_version: !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: "0"
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
112
85
  requirements: []
113
-
114
86
  rubyforge_project:
115
- rubygems_version: 1.6.2
87
+ rubygems_version: 2.1.10
116
88
  signing_key:
117
- specification_version: 3
89
+ specification_version: 4
118
90
  summary: Migration Validators project mysql driver
119
- test_files:
120
- - spec/migration_validators/adapters/mysql_spec.rb
121
- - spec/mv-mysql_spec.rb
122
- - spec/spec_helper.rb
91
+ test_files: []
@@ -1,926 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe MigrationValidators::Adapters::Mysql, :type => :mv_test do
4
- before :all do
5
- Driver = Class.new(MigrationValidators::Adapters::Base)
6
- use_db :adapter => "mysql",
7
- :pool => 5,
8
- :timeout => 5000,
9
- :database => "validation_migration_test_db",
10
- :host => "localhost",
11
- :username => "root",
12
- :password => "root",
13
- :socket => "/tmp/mysql.sock"
14
-
15
- db.initialize_schema_migrations_table
16
- ::ActiveRecord::Migration.verbose = false
17
- end
18
-
19
- before :each do
20
- MigrationValidators::Core::DbValidator.clear_all
21
- end
22
-
23
- for_test_table do
24
-
25
- #integer
26
- for_integer_column do
27
- with_validator :presense do
28
- with_option :as => :trigger do
29
- it { should allow(5) }
30
- it { should deny(nil).with_initial(5) }
31
- end
32
-
33
- with_option :allow_blank => true do
34
- it { should allow(nil) }
35
- end
36
-
37
- with_option :allow_nil => true do
38
- it { should allow(nil) }
39
- end
40
-
41
- with_option :on => :update do
42
- it { should allow.insert(nil) }
43
- end
44
-
45
- with_option :on => :create do
46
- it { should allow.update(nil).with_initial(5) }
47
- end
48
- end
49
-
50
- with_validator :inclusion do
51
- with_option :as => :trigger do
52
- #closed integer interval
53
- with_options :in => 1..9 do
54
- it { should allow(1,4,9) }
55
- it { should deny(0, 10).with_initial(1) }
56
- end
57
-
58
- #open integer interval
59
- with_options :in => 1...9 do
60
- it { should allow(1,4) }
61
- it { should deny(0, 9, 10).with_initial(1) }
62
- end
63
-
64
- #single value
65
- with_options :in => 9 do
66
- it { should allow(9) }
67
- it { should deny(8, 10).with_initial(9) }
68
- end
69
-
70
- #array
71
- with_options :in => [1, 9] do
72
- it { should allow(1, 9) }
73
- it { should deny(0, 3, 10).with_initial(1) }
74
- end
75
-
76
- with_options :in => 9, :message => "Some error message" do
77
- it { should deny(8, 10).with_initial(9).and_message(/Some error message/) }
78
-
79
- with_option :on => :update do
80
- it { should allow.insert(8, 10) }
81
- end
82
-
83
- with_option :on => :create do
84
- it { should allow.update(8, 10).with_initial(9) }
85
- end
86
- end
87
- end
88
- end
89
-
90
- with_validator :exclusion do
91
- with_option :as => :trigger do
92
- #closed integer interval
93
- with_options :in => 1..9 do
94
- it { should allow(0, 10) }
95
- it { should deny(1,4,9).with_initial(0) }
96
- end
97
-
98
- #open integer intervalw
99
- with_options :in => 1...9 do
100
- it { should allow(0, 9, 10) }
101
- it { should deny(1,4).with_initial(0) }
102
- end
103
-
104
- #single value
105
- with_options :in => 9 do
106
- it { should allow(8, 10) }
107
- it { should deny(9).with_initial(0) }
108
- end
109
-
110
- #array
111
- with_options :in => [1, 9] do
112
- it { should allow(0, 3, 10) }
113
- it { should deny(1, 9).with_initial(0) }
114
- end
115
-
116
- with_options :in => 9, :message => "Some error message" do
117
- it { should deny(9).with_initial(8).and_message(/Some error message/) }
118
-
119
- with_option :on => :update do
120
- it { should allow.insert(9) }
121
- end
122
-
123
- with_option :on => :create do
124
- it { should allow.update(9).with_initial(8) }
125
- end
126
- end
127
-
128
- end
129
- end
130
-
131
- with_validator :uniqueness do
132
- with_option :as => :trigger do
133
- it { should deny.insert.at_least_one(1,1)}
134
- it { should deny.update(1).with_initial(1,2)}
135
- it { should allow.insert(1,2,3) }
136
-
137
- with_option :message => "Some error message" do
138
- it { should deny.at_least_one(1,1).with_initial(1).and_message(/Some error message/) }
139
- end
140
- end
141
-
142
- with_option :as => :index do
143
- it { should deny.insert.at_least_one(1,1).with_message(/Duplicate entry/) }
144
- it { should deny.update(1).with_initial(1,2).and_message(/Duplicate entry/) }
145
- it { should allow.insert(1,2,3) }
146
- it { should allow.update(1).with_initial(2) }
147
- end
148
- end
149
- end
150
-
151
- for_integer_column :validates => {:uniqueness => {:as => :index, :message => "Some error message"}, :inclusion => {:in => 1..9, :as => :trigger, :message => "Some error message"}} do
152
- it { should deny.at_least_one(1,1).with_initial(1, 2).and_message(/Duplicate entry/) }
153
- it { should deny(10).with_initial(8).and_message(/Some error message/) }
154
-
155
- with_change :inclusion => false do
156
- it { should deny.at_least_one(1,1).with_initial(1, 2).and_message(/Duplicate entry/) }
157
- it { should allow(10) }
158
- end
159
-
160
- with_change :inclusion => {:in => 1..9} do
161
- with_change :inclusion => false do
162
- it { should allow(10) }
163
- end
164
- end
165
- end
166
-
167
- for_integer_column :validates => {:uniqueness => {:as => :index, :message => "Some error message"}, :exclusion => {:in => 4..9, :as => :trigger, :message => "Some error message"}} do
168
- it { should deny.at_least_one(1,1).with_initial(1, 2).and_message(/Duplicate entry/) }
169
- it { should deny(9).with_initial(10).and_message(/Some error message/) }
170
-
171
- with_change :exclusion => false do
172
- it { should deny.at_least_one(1,1).with_initial(1, 2).and_message(/Duplicate entry/) }
173
- it { should allow(9) }
174
- end
175
-
176
- with_change :exclusion => {:in => 4..9} do
177
- with_change :exclusion => false do
178
- it { should allow(9) }
179
- end
180
- end
181
- end
182
-
183
- for_integer_column :validates => {:uniqueness => {:as => :index, :message => "Some error message"}, :presense => {:as => :trigger, :message => "Some error message"}} do
184
- it { should deny.at_least_one(1,1).with_initial(1, 2).and_message(/Duplicate entry/) }
185
- it { should deny(nil).with_initial(10).and_message(/Some error message/) }
186
-
187
- with_change :presense => false do
188
- it { should deny.at_least_one(1,1).with_initial(1, 2).and_message(/Duplicate entry/) }
189
- it { should allow(nil) }
190
- end
191
-
192
- with_change :presense => true do
193
- with_change :presense => false do
194
- it { should allow(nil) }
195
- end
196
- end
197
- end
198
-
199
-
200
- #float
201
- for_decimal_column :precision => 8, :scale => 5 do
202
-
203
- with_validator :presense do
204
- with_option :as => :trigger do
205
- it { should allow(1.1) }
206
- it { should deny(nil).with_initial(1.1) }
207
- end
208
-
209
- with_option :allow_blank => true do
210
- it { should allow(nil) }
211
- end
212
-
213
- with_option :allow_nil => true do
214
- it { should allow(nil) }
215
- end
216
-
217
- with_option :on => :update do
218
- it { should allow.insert(nil) }
219
- end
220
-
221
- with_option :on => :create do
222
- it { should allow.update(nil).with_initial(1.1) }
223
- end
224
- end
225
-
226
- with_validator :inclusion do
227
- with_option :as => :trigger do
228
- #closed integer interval
229
- with_options :in => 1.1..9.1 do
230
- it { should allow(1.1, 9.1) }
231
- it { should deny(1.0, 9.2).with_initial(1.1) }
232
- end
233
-
234
- #open integer interval
235
- with_options :in => 1.1...9.1 do
236
- it { should allow(1.1, 9) }
237
- it { should deny(1.0, 9.1, 9.2).with_initial(1.1) }
238
- end
239
-
240
- #single value
241
- with_options :in => 9.1 do
242
- it { should allow(9.1) }
243
- it { should deny(8.1, 10.1).with_initial(9.1) }
244
- end
245
-
246
- #array
247
- with_options :in => [1.1, 9.1] do
248
- it { should allow(1.1, 9.1) }
249
- it { should deny(0.1, 3.1, 10.1).with_initial(1.1) }
250
- end
251
-
252
- with_options :in => 9.1, :message => "Some error message" do
253
- it { should deny(8.1, 10.1).with_initial(9.1).and_message(/Some error message/) }
254
- end
255
- end
256
- end
257
-
258
- with_validator :exclusion do
259
- with_option :as => :trigger do
260
- #closed integer interval
261
- with_options :in => 1.1..9.1 do
262
- it { should allow(1.0, 9.2) }
263
- it { should deny(1.1, 9.1).with_initial(1.0) }
264
- end
265
-
266
- #open integer interval
267
- with_options :in => 1.1...9.1 do
268
- it { should allow(1.0, 9.1, 9.2) }
269
- it { should deny(1.1, 9).with_initial(1.0) }
270
- end
271
-
272
- #single value
273
- with_options :in => 9.1 do
274
- it { should deny(9.1).with_initial(9.0) }
275
- it { should allow(8.1, 10.1) }
276
- end
277
-
278
- #array
279
- with_options :in => [1.1, 9.1] do
280
- it { should deny(1.1, 9.1).with_initial(1.0) }
281
- it { should allow(0.1, 3.1, 10.1) }
282
- end
283
-
284
- with_options :in => 9.1, :message => "Some error message" do
285
- it { should deny(9.1).with_initial(9.0).and_message(/Some error message/) }
286
- end
287
- end
288
- end
289
- end
290
-
291
- #string
292
- for_string_column do
293
- with_validator :format do
294
- with_option :as => :trigger do
295
- with_option :with => /^start/ do
296
- it { should allow('start stop') }
297
- it { should deny('stop start').with_initial('start') }
298
- it { should deny('stop').with_initial('start') }
299
-
300
- with_option :on => :update do
301
- it { should allow.insert('stop')}
302
- end
303
-
304
- with_option :on => :create do
305
- it { should allow.update('stop').with_initial('start')}
306
- end
307
-
308
- with_option :message => "Some error message" do
309
- it { should deny('stop').with_initial('start').and_message(/Some error message/) }
310
- end
311
- end
312
- end
313
- end
314
-
315
- with_validator :presense do
316
- with_option :as => :trigger do
317
- it { should allow('b') }
318
- it { should deny(nil).with_initial('b') }
319
- end
320
-
321
- with_option :allow_blank => true do
322
- it { should allow(nil) }
323
- end
324
-
325
- with_option :allow_nil => true do
326
- it { should allow(nil) }
327
- end
328
-
329
- with_option :on => :update do
330
- it { should allow.insert(nil) }
331
- end
332
-
333
- with_option :on => :create do
334
- it { should allow.update(nil).with_initial('b') }
335
- end
336
- end
337
-
338
- with_validator :uniqueness do
339
- with_option :as => :trigger do
340
- it { should deny.at_least_one(' ', ' ').with_initial(' ', 'a') }
341
-
342
- with_option :allow_blank => true do
343
- it { should allow(' ', ' ') }
344
- end
345
- end
346
- end
347
-
348
- with_validator :inclusion do
349
- with_option :as => :trigger do
350
- #closed string interval
351
- with_options :in => 'b'..'e' do
352
- it { should allow('b', 'd', 'e') }
353
- it { should deny('a', 'f').with_initial('b') }
354
- it { should deny(' ').with_initial('b') }
355
- it { should deny(nil).with_initial('b') }
356
-
357
- with_option :allow_blank => true do
358
- it { should allow(' ') }
359
- end
360
-
361
- with_option :allow_nil => true do
362
- it { should allow(nil) }
363
- end
364
- end
365
-
366
- #open string interval
367
- with_options :in => 'b'...'e' do
368
- it { should allow('b', 'd') }
369
- it { should deny('a', 'e', 'f').with_initial('b') }
370
- it { should deny(' ').with_initial('b') }
371
- it { should deny(nil).with_initial('b') }
372
-
373
- with_option :allow_blank => true do
374
- it { should allow(' ') }
375
- end
376
-
377
- with_option :allow_nil => true do
378
- it { should allow(nil) }
379
- end
380
- end
381
-
382
- #single string value
383
- with_options :in => 'b' do
384
- it { should allow('b') }
385
- it { should deny('a', 'c').with_initial('b') }
386
- it { should deny(' ').with_initial('b') }
387
- it { should deny(nil).with_initial('b') }
388
-
389
- with_option :allow_blank => true do
390
- it { should allow(' ') }
391
- end
392
-
393
- with_option :allow_nil => true do
394
- it { should allow(nil) }
395
- end
396
- end
397
-
398
- #array
399
- with_options :in => ['b', 'e'] do
400
- it { should allow('b', 'e') }
401
- it { should deny('a', 'c', 'f').with_initial('b') }
402
- it { should deny(' ').with_initial('b') }
403
- it { should deny(nil).with_initial('b') }
404
-
405
- with_option :allow_blank => true do
406
- it { should allow(' ') }
407
- end
408
-
409
- with_option :allow_nil => true do
410
- it { should allow(nil) }
411
- end
412
- end
413
-
414
- with_options :in => 'b' do
415
- it { should allow('b') }
416
-
417
- with_option :message => "Some error message" do
418
- it { should deny('c').with_initial('b').with_message(/Some error message/) }
419
- end
420
-
421
- it { should deny(' ').with_initial('b') }
422
-
423
- with_option :allow_blank => true do
424
- it { should allow(' ') }
425
- end
426
- end
427
- end
428
- end
429
-
430
- with_validator :exclusion do
431
- with_option :as => :trigger do
432
- #closed string interval
433
- with_options :in => 'b'..'e' do
434
- it { should allow('a', 'f') }
435
- it { should deny('b', 'd', 'e').with_initial('a') }
436
- it { should allow(nil) }
437
- end
438
-
439
- #open string interval
440
- with_options :in => 'b'...'e' do
441
- it { should deny('b', 'd').with_initial('a') }
442
- it { should allow('a', 'e', 'f') }
443
- it { should allow(nil) }
444
- end
445
-
446
- #single string value
447
- with_options :in => 'b' do
448
- it { should deny('b').with_initial('a') }
449
- it { should allow('a', 'c') }
450
- it { should allow(nil) }
451
- end
452
-
453
- #array
454
- with_options :in => ['b', 'e', ' '] do
455
- it { should deny('b', 'e').with_initial('a') }
456
- it { should allow('a', 'c', 'f') }
457
- it { should deny(' ').with_initial('a') }
458
- it { should allow(nil) }
459
-
460
- with_option :allow_blank => true do
461
- it { should allow(' ') }
462
- end
463
- end
464
-
465
- with_options :in => 'b', :message => "Some error message" do
466
- it { should deny('b').with_initial('a').with_message(/Some error message/) }
467
- end
468
- end
469
- end
470
-
471
- with_validator :length do
472
- with_option :as => :trigger do
473
- with_option :is => 5 do
474
- it {should allow('12345') }
475
- it {should deny('1234', '123456').with_initial('12345') }
476
-
477
- with_option :message => "Some error message" do
478
- it {should deny('123456').with_initial('12345').with_message("Some error message") }
479
-
480
- with_option :wrong_length => "Some specific error message" do
481
- it {should deny('123456').with_initial('12345').with_message("Some specific error message") }
482
- end
483
- end
484
-
485
- with_option :on => :create do
486
- it {should deny.insert('1234', '123456') }
487
- it {should allow.update('1234', '123456').with_initial('12345') }
488
- end
489
-
490
- with_option :on => :update do
491
- it {should allow.insert('1234', '123456') }
492
- it {should deny.update('1234', '123456').with_initial('12345') }
493
- end
494
-
495
- it {should deny(' ', nil).with_initial('12345') }
496
-
497
- with_option :allow_blank => true do
498
- it { should allow.insert(' ') }
499
- end
500
-
501
- with_option :allow_nil => true do
502
- it { should allow.insert(nil) }
503
- end
504
- end
505
-
506
- with_option :is => 0 do
507
- it { should allow(nil) }
508
- end
509
-
510
-
511
- with_option :maximum => 5 do
512
- it {should allow('1234', '12345') }
513
- it {should deny('123456').with_initial('12345') }
514
-
515
- with_option :message => "Some error message" do
516
- it {should deny('123456').with_initial('12345').with_message("Some error message") }
517
-
518
- with_option :too_long => "Some specific error message" do
519
- it {should deny('123456').with_initial('12345').with_message("Some specific error message") }
520
- end
521
- end
522
-
523
- it { should allow(' ', nil) }
524
- end
525
-
526
- with_option :minimum => 5 do
527
- it {should allow('12345', '123456') }
528
- it {should deny('1234').with_initial('12345') }
529
-
530
- with_option :message => "Some error message" do
531
- it {should deny('1234').with_initial('12345').with_message("Some error message") }
532
-
533
- with_option :too_short => "Some specific error message" do
534
- it {should deny('1234').with_initial('12345').with_message("Some specific error message") }
535
- end
536
- end
537
-
538
- it {should deny(' ', nil).with_initial('12345') }
539
-
540
- with_option :allow_blank => true do
541
- it { should allow.insert(' ') }
542
- end
543
-
544
- with_option :allow_nil => true do
545
- it { should allow.insert(nil) }
546
- end
547
- end
548
-
549
- with_option :minimum => 0 do
550
- it { should allow(' ', nil) }
551
- end
552
-
553
- with_option :in => 2..5 do
554
- it {should allow('12', '123', '12345') }
555
- it {should deny('1', '123456').with_initial('12') }
556
-
557
- with_option :message => "Some error message" do
558
- it {should deny('1').with_initial('12').with_message("Some error message") }
559
- end
560
-
561
- it {should deny(' ', nil).with_initial('12') }
562
-
563
- with_option :allow_blank => true do
564
- it { should allow.insert(' ') }
565
- end
566
-
567
- with_option :allow_nil => true do
568
- it { should allow.insert(nil) }
569
- end
570
- end
571
-
572
- with_option :in => 0..1 do
573
- it { should allow(' ', nil) }
574
- end
575
-
576
- with_option :in => 2...5 do
577
- it {should allow('12', '123') }
578
- it {should deny('1', '12345', '123456').with_initial('12') }
579
-
580
- with_option :message => "Some error message" do
581
- it {should deny('1').with_initial('12').with_message("Some error message") }
582
- end
583
-
584
- it {should deny(' ', nil).with_initial('12') }
585
-
586
- with_option :allow_blank => true do
587
- it { should allow.insert(' ') }
588
- end
589
-
590
- with_option :allow_nil => true do
591
- it { should allow.insert(nil) }
592
- end
593
- end
594
-
595
- with_option :in => 0...2 do
596
- it { should allow(' ', nil) }
597
- end
598
-
599
- with_option :in => [2, 3, 5] do
600
- it {should allow('12', '123', '12345') }
601
- it {should deny('1', '1234', '123456').with_initial('12') }
602
-
603
- with_option :message => "Some error message" do
604
- it {should deny('1').with_initial('12').with_message("Some error message") }
605
- end
606
-
607
- it {should deny(' ', nil).with_initial('12') }
608
-
609
- with_option :allow_blank => true do
610
- it { should allow.insert(' ') }
611
- end
612
-
613
- with_option :allow_nil => true do
614
- it { should allow.insert(nil) }
615
- end
616
- end
617
-
618
- with_option :in => [0, 1] do
619
- it { should allow(' ', nil) }
620
- end
621
-
622
- with_option :in => 5 do
623
- it {should allow('12345') }
624
- it {should deny('1234', '123456').with_initial('12345') }
625
- end
626
-
627
- with_option :within => 2..5 do
628
- it {should allow('12', '123', '12345') }
629
- it {should deny('1', '123456').with_initial('12') }
630
-
631
- with_option :message => "Some error message" do
632
- it {should deny('1').with_initial('12').with_message("Some error message") }
633
- end
634
-
635
- it {should deny(' ', nil).with_initial('12') }
636
-
637
- with_option :allow_blank => true do
638
- it { should allow.insert(' ') }
639
- end
640
-
641
- with_option :allow_nil => true do
642
- it { should allow.insert(nil) }
643
- end
644
- end
645
-
646
- with_option :within => 0..1 do
647
- it { should allow(' ', nil) }
648
- end
649
-
650
- with_option :within => 2...5 do
651
- it {should allow('12', '123') }
652
- it {should deny('1', '12345', '123456').with_initial('12') }
653
-
654
- with_option :message => "Some error message" do
655
- it {should deny('1').with_initial('12').with_message("Some error message") }
656
- end
657
-
658
- it {should deny(' ', nil).with_initial('12') }
659
-
660
- with_option :allow_blank => true do
661
- it { should allow.insert(' ') }
662
- end
663
-
664
- with_option :allow_nil => true do
665
- it { should allow.insert(nil) }
666
- end
667
- end
668
-
669
- with_option :within => 0...2 do
670
- it { should allow(' ', nil) }
671
- end
672
-
673
- with_option :within => [2, 3, 5] do
674
- it {should allow('12', '123', '12345') }
675
- it {should deny('1', '1234', '123456').with_initial('12') }
676
-
677
- with_option :message => "Some error message" do
678
- it {should deny('1').with_initial('12').with_message("Some error message") }
679
- end
680
-
681
- it {should deny(' ', nil).with_initial('12') }
682
-
683
- with_option :allow_blank => true do
684
- it { should allow.insert(' ') }
685
- end
686
-
687
- with_option :allow_nil => true do
688
- it { should allow.insert(nil) }
689
- end
690
- end
691
-
692
- with_option :within => [0, 1] do
693
- it { should allow(' ', nil) }
694
- end
695
-
696
- with_option :within => 5 do
697
- it {should allow('12345') }
698
- it {should deny('1234', '123456').with_initial('12345') }
699
- end
700
- end
701
- end
702
- end
703
-
704
- for_string_column :validates => {:uniqueness => {:as => :index, :message => "Some error message"}, :length => {:in => 4..9, :as => :trigger, :message => "Some error message"}} do
705
- it { should deny.at_least_one('1234','1234').with_initial('1234', '12345').and_message(/Duplicate entry/) }
706
- it { should deny('123').with_initial('1234').and_message(/Some error message/) }
707
-
708
- with_change :length => false do
709
- it { should deny.at_least_one('1234','1234').with_initial('1234', '12345').and_message(/Duplicate entry/) }
710
- it { should allow('123') }
711
- end
712
-
713
- with_change :length => {:in => 4..9} do
714
- with_change :length => false do
715
- it { should allow('123') }
716
- end
717
- end
718
- end
719
-
720
- for_string_column :validates => {:uniqueness => {:as => :index, :message => "Some error message"}, :format => {:with => /^start/, :as => :trigger, :message => "Some error message"}} do
721
- it { should deny.at_least_one('start','start').with_initial('start', 'start1').and_message(/Duplicate entry/) }
722
- it { should deny('stop').with_initial('start').and_message(/Some error message/) }
723
-
724
- with_change :format => false do
725
- it { should deny.at_least_one('start','start').with_initial('start', 'start1').and_message(/Duplicate entry/) }
726
- it { should allow('stop') }
727
- end
728
-
729
- with_change :format => {:with => /^start/} do
730
- with_change :format => false do
731
- it { should allow('stop') }
732
- end
733
- end
734
- end
735
-
736
- #date
737
- for_date_column do
738
- startDate = Date.today - 5
739
- endDate = Date.today
740
-
741
- with_validator :presense do
742
- with_option :as => :trigger do
743
- it { should allow(startDate) }
744
- it { should deny(nil).with_initial(startDate) }
745
- end
746
-
747
- with_option :allow_blank => true do
748
- it { should allow(nil) }
749
- end
750
-
751
- with_option :allow_nil => true do
752
- it { should allow(nil) }
753
- end
754
-
755
- with_option :on => :update do
756
- it { should allow.insert(nil) }
757
- end
758
-
759
- with_option :on => :create do
760
- it { should allow.update(nil).with_initial(startDate) }
761
- end
762
- end
763
-
764
- with_validator :inclusion do
765
- with_option :as => :trigger do
766
-
767
- #closed date interval
768
- with_options :in => startDate..endDate do
769
- it { should allow(startDate, endDate - 3, endDate) }
770
- it { should deny(startDate - 1, endDate + 1).with_initial(endDate - 1) }
771
- end
772
-
773
- #open date interval
774
- with_options :in => startDate...endDate do
775
- it { should allow(startDate, endDate - 3) }
776
- it { should deny(startDate - 1, endDate, endDate + 1).with_initial(endDate - 1) }
777
- end
778
-
779
- #single date value
780
- with_options :in => endDate do
781
- it { should allow(endDate) }
782
- it { should deny(endDate - 1, endDate + 1).with_initial(endDate) }
783
- end
784
-
785
- #array
786
- with_options :in => [startDate, endDate] do
787
- it { should allow(startDate, endDate) }
788
- it { should deny(startDate - 1, endDate - 1, endDate + 1).with_initial(endDate) }
789
- end
790
-
791
- with_options :in => endDate, :message => "Some error message" do
792
- it { should deny(endDate + 1).with_initial(endDate).with_message(/Some error message/) }
793
- end
794
- end
795
- end
796
-
797
- with_validator :exclusion do
798
- with_option :as => :trigger do
799
-
800
- #closed date interval
801
- with_options :in => startDate..endDate do
802
- it { should deny(startDate, endDate - 3, endDate).with_initial(startDate - 1) }
803
- it { should allow(startDate - 1, endDate + 1) }
804
- end
805
-
806
- #open date interval
807
- with_options :in => startDate...endDate do
808
- it { should deny(startDate, endDate - 3).with_initial(startDate - 1) }
809
- it { should allow(startDate - 1, endDate, endDate + 1) }
810
- end
811
-
812
- #single date value
813
- with_options :in => endDate do
814
- it { should deny(endDate).with_initial(endDate - 1) }
815
- it { should allow(endDate - 1, endDate + 1) }
816
- end
817
-
818
- #array
819
- with_options :in => [startDate, endDate] do
820
- it { should deny(startDate, endDate).with_initial(startDate - 1) }
821
- it { should allow(startDate - 1, endDate - 1, endDate + 1) }
822
- end
823
-
824
- with_options :in => endDate, :message => "Some error message" do
825
- it { should deny(endDate).with_initial(endDate - 1).with_message(/Some error message/) }
826
- end
827
- end
828
- end
829
- end
830
-
831
- #time
832
- for_time_column do
833
- startTime = Time.now - 10
834
- endTime = Time.now
835
-
836
- with_validator :presense do
837
- with_option :as => :trigger do
838
- it { should allow(startTime) }
839
- it { should deny(nil).with_initial(startTime) }
840
- end
841
-
842
- with_option :allow_blank => true do
843
- it { should allow(nil) }
844
- end
845
-
846
- with_option :allow_nil => true do
847
- it { should allow(nil) }
848
- end
849
-
850
- with_option :on => :update do
851
- it { should allow.insert(nil) }
852
- end
853
-
854
- with_option :on => :create do
855
- it { should allow.update(nil).with_initial(startTime) }
856
- end
857
- end
858
-
859
- with_validator :inclusion do
860
- with_option :as => :trigger do
861
-
862
- #closed time interval
863
- with_options :in => startTime..endTime do
864
- it { should allow(startTime, startTime + 1, endTime) }
865
- it { should deny(startTime - 1, endTime + 1).with_initial(startTime) }
866
- end
867
-
868
- #open time interval
869
- with_options :in => startTime...endTime do
870
- it { should allow(startTime, startTime + 1, endTime - 1) }
871
- it { should deny(startTime - 1, endTime).with_initial(startTime) }
872
- end
873
-
874
- #single time value
875
- with_options :in => startTime do
876
- it { should allow(startTime) }
877
- it { should deny(startTime - 1, endTime).with_initial(startTime) }
878
- end
879
-
880
- #array
881
- with_options :in => [startTime, endTime] do
882
- it { should allow(startTime, endTime) }
883
- it { should deny(startTime - 1, startTime + 1, endTime + 1).with_initial(startTime) }
884
- end
885
-
886
- with_options :in => startTime, :message => "Some error message" do
887
- it { should deny(startTime + 1).with_initial(startTime).with_message(/Some error message/) }
888
- end
889
- end
890
- end
891
-
892
- with_validator :exclusion do
893
- with_option :as => :trigger do
894
-
895
- #closed time interval
896
- with_options :in => startTime..endTime do
897
- it { should deny(startTime, startTime + 1, endTime).with_initial(startTime - 1) }
898
- it { should allow(startTime - 1, endTime + 1) }
899
- end
900
-
901
- #open time interval
902
- with_options :in => startTime...endTime do
903
- it { should deny(startTime, startTime + 1, endTime - 1).with_initial(startTime - 1) }
904
- it { should allow(startTime - 1, endTime) }
905
- end
906
-
907
- #single time value
908
- with_options :in => startTime do
909
- it { should deny(startTime).with_initial(startTime - 1) }
910
- it { should allow(startTime - 1, endTime) }
911
- end
912
-
913
- #array
914
- with_options :in => [startTime, endTime] do
915
- it { should deny(startTime, endTime).with_initial(startTime - 1) }
916
- it { should allow(startTime - 1, startTime + 1, endTime + 1)}
917
- end
918
-
919
- with_options :in => startTime, :message => "Some error message" do
920
- it { should deny(startTime).with_initial(startTime - 1).with_message(/Some error message/) }
921
- end
922
- end
923
- end
924
- end
925
- end
926
- end
@@ -1,4 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "MvMysql" do
4
- end
data/spec/spec_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'mv-test'
5
- require 'mv-mysql'
6
- require 'shoulda'
7
- require 'factory_girl'
8
-
9
- # Requires supporting files with custom matchers and macros, etc,
10
- # in ./support/ and its subdirectories.
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
12
-
13
- RSpec.configure do |config|
14
-
15
- end