sequel 2.12.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/CHANGELOG +62 -0
  2. data/README.rdoc +3 -3
  3. data/Rakefile +7 -0
  4. data/doc/advanced_associations.rdoc +44 -0
  5. data/doc/release_notes/3.0.0.txt +221 -0
  6. data/lib/sequel/adapters/amalgalite.rb +208 -0
  7. data/lib/sequel/adapters/db2.rb +3 -0
  8. data/lib/sequel/adapters/dbi.rb +9 -0
  9. data/lib/sequel/adapters/do.rb +0 -4
  10. data/lib/sequel/adapters/firebird.rb +16 -18
  11. data/lib/sequel/adapters/informix.rb +5 -3
  12. data/lib/sequel/adapters/jdbc.rb +24 -20
  13. data/lib/sequel/adapters/jdbc/h2.rb +15 -4
  14. data/lib/sequel/adapters/mysql.rb +4 -8
  15. data/lib/sequel/adapters/odbc.rb +0 -4
  16. data/lib/sequel/adapters/oracle.rb +0 -4
  17. data/lib/sequel/adapters/shared/mssql.rb +16 -5
  18. data/lib/sequel/adapters/shared/mysql.rb +87 -86
  19. data/lib/sequel/adapters/shared/oracle.rb +92 -3
  20. data/lib/sequel/adapters/shared/postgres.rb +85 -29
  21. data/lib/sequel/adapters/shared/progress.rb +8 -3
  22. data/lib/sequel/adapters/shared/sqlite.rb +53 -23
  23. data/lib/sequel/adapters/sqlite.rb +4 -7
  24. data/lib/sequel/adapters/utils/unsupported.rb +3 -3
  25. data/lib/sequel/connection_pool.rb +18 -25
  26. data/lib/sequel/core.rb +2 -21
  27. data/lib/sequel/database.rb +60 -44
  28. data/lib/sequel/database/schema_generator.rb +26 -31
  29. data/lib/sequel/database/schema_methods.rb +8 -3
  30. data/lib/sequel/database/schema_sql.rb +114 -28
  31. data/lib/sequel/dataset.rb +14 -41
  32. data/lib/sequel/dataset/convenience.rb +31 -54
  33. data/lib/sequel/dataset/graph.rb +7 -13
  34. data/lib/sequel/dataset/sql.rb +43 -54
  35. data/lib/sequel/extensions/inflector.rb +0 -5
  36. data/lib/sequel/extensions/schema_dumper.rb +238 -0
  37. data/lib/sequel/metaprogramming.rb +0 -20
  38. data/lib/sequel/model.rb +1 -2
  39. data/lib/sequel/model/base.rb +18 -16
  40. data/lib/sequel/model/inflections.rb +6 -9
  41. data/lib/sequel/plugins/caching.rb +0 -6
  42. data/lib/sequel/plugins/hook_class_methods.rb +1 -1
  43. data/lib/sequel/sql.rb +2 -0
  44. data/lib/sequel/version.rb +2 -2
  45. data/spec/adapters/firebird_spec.rb +35 -8
  46. data/spec/adapters/mysql_spec.rb +173 -266
  47. data/spec/adapters/oracle_spec.rb +13 -0
  48. data/spec/adapters/postgres_spec.rb +127 -227
  49. data/spec/adapters/sqlite_spec.rb +13 -171
  50. data/spec/core/connection_pool_spec.rb +15 -4
  51. data/spec/core/core_sql_spec.rb +14 -170
  52. data/spec/core/database_spec.rb +50 -132
  53. data/spec/core/dataset_spec.rb +47 -930
  54. data/spec/core/expression_filters_spec.rb +12 -0
  55. data/spec/core/schema_generator_spec.rb +37 -45
  56. data/spec/core/schema_spec.rb +26 -16
  57. data/spec/core/spec_helper.rb +0 -25
  58. data/spec/extensions/inflector_spec.rb +0 -3
  59. data/spec/extensions/schema_dumper_spec.rb +292 -0
  60. data/spec/extensions/serialization_spec.rb +9 -0
  61. data/spec/extensions/single_table_inheritance_spec.rb +6 -1
  62. data/spec/extensions/spec_helper.rb +1 -3
  63. data/spec/extensions/validation_helpers_spec.rb +4 -4
  64. data/spec/integration/database_test.rb +18 -0
  65. data/spec/integration/dataset_test.rb +112 -1
  66. data/spec/integration/eager_loader_test.rb +70 -9
  67. data/spec/integration/prepared_statement_test.rb +2 -2
  68. data/spec/integration/schema_test.rb +76 -27
  69. data/spec/integration/spec_helper.rb +0 -14
  70. data/spec/integration/transaction_test.rb +27 -0
  71. data/spec/model/associations_spec.rb +0 -36
  72. data/spec/model/base_spec.rb +18 -123
  73. data/spec/model/hooks_spec.rb +2 -235
  74. data/spec/model/inflector_spec.rb +15 -115
  75. data/spec/model/model_spec.rb +0 -120
  76. data/spec/model/plugins_spec.rb +0 -70
  77. data/spec/model/record_spec.rb +35 -93
  78. data/spec/model/spec_helper.rb +0 -27
  79. data/spec/model/validations_spec.rb +0 -931
  80. metadata +9 -14
  81. data/lib/sequel/deprecated.rb +0 -593
  82. data/lib/sequel/deprecated_migration.rb +0 -91
  83. data/lib/sequel/model/deprecated.rb +0 -204
  84. data/lib/sequel/model/deprecated_hooks.rb +0 -103
  85. data/lib/sequel/model/deprecated_inflector.rb +0 -335
  86. data/lib/sequel/model/deprecated_validations.rb +0 -388
  87. data/spec/core/core_ext_spec.rb +0 -156
  88. data/spec/core/migration_spec.rb +0 -263
  89. data/spec/core/pretty_table_spec.rb +0 -58
  90. data/spec/model/caching_spec.rb +0 -217
  91. data/spec/model/schema_spec.rb +0 -92
@@ -1,388 +0,0 @@
1
- module Sequel
2
- module Plugins
3
- module DeprecatedValidationClassMethods
4
- module ClassMethods
5
- # The Generator class is used to generate validation definitions using
6
- # the validates {} idiom.
7
- class Generator
8
- # Initializes a new generator.
9
- def initialize(receiver ,&block)
10
- @receiver = receiver
11
- instance_eval(&block)
12
- end
13
-
14
- # Delegates method calls to the receiver by calling receiver.validates_xxx.
15
- def method_missing(m, *args, &block)
16
- @receiver.send(:"validates_#{m}", *args, &block)
17
- end
18
- end
19
-
20
- # Returns true if validations are defined.
21
- def has_validations?
22
- !validations.empty?
23
- end
24
-
25
- # Instructs the model to skip validations defined in superclasses
26
- def skip_superclass_validations
27
- @skip_superclass_validations = true
28
- end
29
-
30
- # Defines validations by converting a longhand block into a series of
31
- # shorthand definitions. For example:
32
- #
33
- # class MyClass < Sequel::Model
34
- # validates do
35
- # length_of :name, :minimum => 6
36
- # length_of :password, :minimum => 8
37
- # end
38
- # end
39
- #
40
- # is equivalent to:
41
- # class MyClass < Sequel::Model
42
- # validates_length_of :name, :minimum => 6
43
- # validates_length_of :password, :minimum => 8
44
- # end
45
- def validates(&block)
46
- Deprecation.deprecate('Sequel::Model.validates', 'Use Model.plugin(:validation_class_methods) first')
47
- Generator.new(self, &block)
48
- end
49
-
50
- # Validates the given instance.
51
- def validate(o)
52
- if superclass.respond_to?(:validate) && !@skip_superclass_validations
53
- superclass.validate(o)
54
- end
55
- validations.each do |att, procs|
56
- v = case att
57
- when Array
58
- att.collect{|a| o.send(a)}
59
- else
60
- o.send(att)
61
- end
62
- procs.each {|tag, p| p.call(o, att, v)}
63
- end
64
- end
65
-
66
- # Validates acceptance of an attribute. Just checks that the value
67
- # is equal to the :accept option. This method is unique in that
68
- # :allow_nil is assumed to be true instead of false.
69
- #
70
- # Possible Options:
71
- # * :accept - The value required for the object to be valid (default: '1')
72
- # * :message - The message to use (default: 'is not accepted')
73
- def validates_acceptance_of(*atts)
74
- Deprecation.deprecate('Sequel::Model.validates_acceptance_of', 'Use Model.plugin(:validation_class_methods) first')
75
- opts = {
76
- :message => 'is not accepted',
77
- :allow_nil => true,
78
- :accept => '1',
79
- :tag => :acceptance,
80
- }.merge!(extract_options!(atts))
81
- atts << opts
82
- validates_each(*atts) do |o, a, v|
83
- o.errors[a] << opts[:message] unless v == opts[:accept]
84
- end
85
- end
86
-
87
- # Validates confirmation of an attribute. Checks that the object has
88
- # a _confirmation value matching the current value. For example:
89
- #
90
- # validates_confirmation_of :blah
91
- #
92
- # Just makes sure that object.blah = object.blah_confirmation. Often used for passwords
93
- # or email addresses on web forms.
94
- #
95
- # Possible Options:
96
- # * :message - The message to use (default: 'is not confirmed')
97
- def validates_confirmation_of(*atts)
98
- Deprecation.deprecate('Sequel::Model.validates_confirmation_of', 'Use Model.plugin(:validation_class_methods) first')
99
- opts = {
100
- :message => 'is not confirmed',
101
- :tag => :confirmation,
102
- }.merge!(extract_options!(atts))
103
- atts << opts
104
- validates_each(*atts) do |o, a, v|
105
- o.errors[a] << opts[:message] unless v == o.send(:"#{a}_confirmation")
106
- end
107
- end
108
-
109
- # Adds a validation for each of the given attributes using the supplied
110
- # block. The block must accept three arguments: instance, attribute and
111
- # value, e.g.:
112
- #
113
- # validates_each :name, :password do |object, attribute, value|
114
- # object.errors[attribute] << 'is not nice' unless value.nice?
115
- # end
116
- #
117
- # Possible Options:
118
- # * :allow_blank - Whether to skip the validation if the value is blank.
119
- # * :allow_missing - Whether to skip the validation if the attribute isn't a key in the
120
- # values hash. This is different from allow_nil, because Sequel only sends the attributes
121
- # in the values when doing an insert or update. If the attribute is not present, Sequel
122
- # doesn't specify it, so the database will use the table's default value. This is different
123
- # from having an attribute in values with a value of nil, which Sequel will send as NULL.
124
- # If your database table has a non NULL default, this may be a good option to use. You
125
- # don't want to use allow_nil, because if the attribute is in values but has a value nil,
126
- # Sequel will attempt to insert a NULL value into the database, instead of using the
127
- # database's default.
128
- # * :allow_nil - Whether to skip the validation if the value is nil.
129
- # * :if - A symbol (indicating an instance_method) or proc (which is instance_evaled)
130
- # skipping this validation if it returns nil or false.
131
- # * :tag - The tag to use for this validation.
132
- def validates_each(*atts, &block)
133
- Deprecation.deprecate('Sequel::Model.validates_each', 'Use Model.plugin(:validation_class_methods) first')
134
- opts = extract_options!(atts)
135
- blk = if (i = opts[:if]) || (am = opts[:allow_missing]) || (an = opts[:allow_nil]) || (ab = opts[:allow_blank])
136
- proc do |o,a,v|
137
- next if i && !validation_if_proc(o, i)
138
- next if an && Array(v).all?{|x| x.nil?}
139
- next if ab && Array(v).all?{|x| x.blank?}
140
- next if am && Array(a).all?{|x| !o.values.has_key?(x)}
141
- block.call(o,a,v)
142
- end
143
- else
144
- block
145
- end
146
- tag = opts[:tag]
147
- atts.each do |a|
148
- a_vals = validations[a]
149
- if tag && (old = a_vals.find{|x| x[0] == tag})
150
- old[1] = blk
151
- else
152
- a_vals << [tag, blk]
153
- end
154
- end
155
- end
156
-
157
- # Validates the format of an attribute, checking the string representation of the
158
- # value against the regular expression provided by the :with option.
159
- #
160
- # Possible Options:
161
- # * :message - The message to use (default: 'is invalid')
162
- # * :with - The regular expression to validate the value with (required).
163
- def validates_format_of(*atts)
164
- Deprecation.deprecate('Sequel::Model.validates_format_of', 'Use Model.plugin(:validation_class_methods) first')
165
- opts = {
166
- :message => 'is invalid',
167
- :tag => :format,
168
- }.merge!(extract_options!(atts))
169
-
170
- unless opts[:with].is_a?(Regexp)
171
- raise ArgumentError, "A regular expression must be supplied as the :with option of the options hash"
172
- end
173
-
174
- atts << opts
175
- validates_each(*atts) do |o, a, v|
176
- o.errors[a] << opts[:message] unless v.to_s =~ opts[:with]
177
- end
178
- end
179
-
180
- # Validates the length of an attribute.
181
- #
182
- # Possible Options:
183
- # * :is - The exact size required for the value to be valid (no default)
184
- # * :maximum - The maximum size allowed for the value (no default)
185
- # * :message - The message to use (no default, overrides :too_long, :too_short, and :wrong_length
186
- # options if present)
187
- # * :minimum - The minimum size allowed for the value (no default)
188
- # * :too_long - The message to use use if it the value is too long (default: 'is too long')
189
- # * :too_short - The message to use use if it the value is too short (default: 'is too short')
190
- # * :within - The array/range that must include the size of the value for it to be valid (no default)
191
- # * :wrong_length - The message to use use if it the value is not valid (default: 'is the wrong length')
192
- def validates_length_of(*atts)
193
- Deprecation.deprecate('Sequel::Model.validates_length_of', 'Use Model.plugin(:validation_class_methods) first')
194
- opts = {
195
- :too_long => 'is too long',
196
- :too_short => 'is too short',
197
- :wrong_length => 'is the wrong length'
198
- }.merge!(extract_options!(atts))
199
-
200
- opts[:tag] ||= ([:length] + [:maximum, :minimum, :is, :within].reject{|x| !opts.include?(x)}).join('-').to_sym
201
- atts << opts
202
- validates_each(*atts) do |o, a, v|
203
- if m = opts[:maximum]
204
- o.errors[a] << (opts[:message] || opts[:too_long]) unless v && v.size <= m
205
- end
206
- if m = opts[:minimum]
207
- o.errors[a] << (opts[:message] || opts[:too_short]) unless v && v.size >= m
208
- end
209
- if i = opts[:is]
210
- o.errors[a] << (opts[:message] || opts[:wrong_length]) unless v && v.size == i
211
- end
212
- if w = opts[:within]
213
- o.errors[a] << (opts[:message] || opts[:wrong_length]) unless v && w.include?(v.size)
214
- end
215
- end
216
- end
217
-
218
- # Validates whether an attribute is not a string. This is generally useful
219
- # in conjunction with raise_on_typecast_failure = false, where you are
220
- # passing in string values for non-string attributes (such as numbers and dates).
221
- # If typecasting fails (invalid number or date), the value of the attribute will
222
- # be a string in an invalid format, and if typecasting succeeds, the value will
223
- # not be a string.
224
- #
225
- # Possible Options:
226
- # * :message - The message to use (default: 'is a string' or 'is not a valid (integer|datetime|etc.)' if the type is known)
227
- def validates_not_string(*atts)
228
- Deprecation.deprecate('Sequel::Model.validates_not_string', 'Use Model.plugin(:validation_class_methods) first')
229
- opts = {
230
- :tag => :not_string,
231
- }.merge!(extract_options!(atts))
232
- atts << opts
233
- validates_each(*atts) do |o, a, v|
234
- if v.is_a?(String)
235
- unless message = opts[:message]
236
- message = if sch = o.db_schema[a] and typ = sch[:type]
237
- "is not a valid #{typ}"
238
- else
239
- "is a string"
240
- end
241
- end
242
- o.errors[a] << message
243
- end
244
- end
245
- end
246
-
247
- # Validates whether an attribute is a number.
248
- #
249
- # Possible Options:
250
- # * :message - The message to use (default: 'is not a number')
251
- # * :only_integer - Whether only integers are valid values (default: false)
252
- def validates_numericality_of(*atts)
253
- Deprecation.deprecate('Sequel::Model.validates_numericality_of', 'Use Model.plugin(:validation_class_methods) first')
254
- opts = {
255
- :message => 'is not a number',
256
- :tag => :numericality,
257
- }.merge!(extract_options!(atts))
258
- atts << opts
259
- validates_each(*atts) do |o, a, v|
260
- begin
261
- if opts[:only_integer]
262
- Kernel.Integer(v.to_s)
263
- else
264
- Kernel.Float(v.to_s)
265
- end
266
- rescue
267
- o.errors[a] << opts[:message]
268
- end
269
- end
270
- end
271
-
272
- # Validates the presence of an attribute. Requires the value not be blank,
273
- # with false considered present instead of absent.
274
- #
275
- # Possible Options:
276
- # * :message - The message to use (default: 'is not present')
277
- def validates_presence_of(*atts)
278
- Deprecation.deprecate('Sequel::Model.validates_presence_of', 'Use Model.plugin(:validation_class_methods) first')
279
- opts = {
280
- :message => 'is not present',
281
- :tag => :presence,
282
- }.merge!(extract_options!(atts))
283
- atts << opts
284
- validates_each(*atts) do |o, a, v|
285
- o.errors[a] << opts[:message] if v.blank? && v != false
286
- end
287
- end
288
-
289
- # Validates that an attribute is within a specified range or set of values.
290
- #
291
- # Possible Options:
292
- # * :in - An array or range of values to check for validity (required)
293
- # * :message - The message to use (default: 'is not in range or set: <specified range>')
294
- def validates_inclusion_of(*atts)
295
- Deprecation.deprecate('Sequel::Model.validates_inclusion_of', 'Use Model.plugin(:validation_class_methods) first')
296
- opts = extract_options!(atts)
297
- unless opts[:in] && opts[:in].respond_to?(:include?)
298
- raise ArgumentError, "The :in parameter is required, and respond to include?"
299
- end
300
- opts[:message] ||= "is not in range or set: #{opts[:in].inspect}"
301
- atts << opts
302
- validates_each(*atts) do |o, a, v|
303
- o.errors[a] << opts[:message] unless opts[:in].include?(v)
304
- end
305
- end
306
-
307
- # Validates only if the fields in the model (specified by atts) are
308
- # unique in the database. Pass an array of fields instead of multiple
309
- # fields to specify that the combination of fields must be unique,
310
- # instead of that each field should have a unique value.
311
- #
312
- # This means that the code:
313
- # validates_uniqueness_of([:column1, :column2])
314
- # validates the grouping of column1 and column2 while
315
- # validates_uniqueness_of(:column1, :column2)
316
- # validates them separately.
317
- #
318
- # You should also add a unique index in the
319
- # database, as this suffers from a fairly obvious race condition.
320
- #
321
- # Possible Options:
322
- # * :message - The message to use (default: 'is already taken')
323
- def validates_uniqueness_of(*atts)
324
- Deprecation.deprecate('Sequel::Model.validates_uniqueness_of', 'Use Model.plugin(:validation_class_methods) first')
325
- opts = {
326
- :message => 'is already taken',
327
- :tag => :uniqueness,
328
- }.merge!(extract_options!(atts))
329
-
330
- atts << opts
331
- validates_each(*atts) do |o, a, v|
332
- error_field = a
333
- a = Array(a)
334
- v = Array(v)
335
- ds = o.class.filter(a.zip(v))
336
- num_dups = ds.count
337
- allow = if num_dups == 0
338
- # No unique value in the database
339
- true
340
- elsif num_dups > 1
341
- # Multiple "unique" values in the database!!
342
- # Someone didn't add a unique index
343
- false
344
- elsif o.new?
345
- # New record, but unique value already exists in the database
346
- false
347
- elsif ds.first === o
348
- # Unique value exists in database, but for the same record, so the update won't cause a duplicate record
349
- true
350
- else
351
- false
352
- end
353
- o.errors[error_field] << opts[:message] unless allow
354
- end
355
- end
356
-
357
- # Returns the validations hash for the class.
358
- def validations
359
- @validations ||= Hash.new {|h, k| h[k] = []}
360
- end
361
-
362
- private
363
-
364
- def extract_options!(array)
365
- array.last.is_a?(Hash) ? array.pop : {}
366
- end
367
-
368
- def validation_if_proc(o, i)
369
- case i
370
- when Symbol then o.send(i)
371
- when Proc then o.instance_eval(&i)
372
- when nil then true
373
- else raise(::Sequel::Error, "invalid value for :if validation option")
374
- end
375
- end
376
- end
377
-
378
- module InstanceMethods
379
- # Validates the object.
380
- def validate
381
- model.validate(self)
382
- end
383
- end
384
- end
385
- end
386
-
387
- Model.plugin :deprecated_validation_class_methods
388
- end
@@ -1,156 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
-
3
- context "Array#extract_options!" do
4
- deprec_specify "should pop the last item if it is a hash" do
5
- a = [1,2,{1=>2}]
6
- a.extract_options!.should == {1=>2}
7
- a.should == [1,2]
8
- end
9
-
10
- deprec_specify "should return an empty hash if the last item is not a hash" do
11
- a = [1,2]
12
- a.extract_options!.should == {}
13
- a.should == [1,2]
14
- end
15
- end
16
-
17
- context "Enumerable#send_each" do
18
- deprec_specify "should send the supplied method to each item" do
19
- a = ['abbc', 'bbccdd', 'hebtre']
20
- a.send_each(:gsub!, 'b', '_')
21
- a.should == ['a__c', '__ccdd', 'he_tre']
22
- end
23
- end
24
-
25
- context "Range#interval" do
26
- deprec_specify "should return the interval between the beginning and end for an inclusive range" do
27
- (1..10).interval.should == 9
28
-
29
- r = rand(100000) + 10
30
- t1 = Time.now.to_i; t2 = t1 + r
31
- (t1..t2).interval.should == r
32
- end
33
-
34
- deprec_specify "should return the interval between the beginning and end for an exclusive range" do
35
- (1...10).interval.should == 8
36
-
37
- r = rand(100000) + 10
38
- t1 = Time.now.to_i; t2 = t1 + r
39
- (t1...t2).interval.should == r - 1
40
- end
41
- end
42
-
43
- context "Module#class_attr_reader" do
44
- deprec_specify "it should create instance methods that call class methods of the same name" do
45
- @c = Class.new do
46
- def self.x; 1; end
47
- class_attr_reader :x
48
- end
49
- @c.new.x.should == 1
50
- def @c.x; 2; end
51
- @c.new.x.should == 2
52
- end
53
- end
54
-
55
- context "Module#metaalias" do
56
- deprec_specify "it should create aliases of singleton/class methods" do
57
- @c = Class.new do
58
- def self.x; 1; end
59
- metaalias :y, :x
60
- end
61
- @c.y.should == 1
62
- def @c.x; 2; end
63
- @c.y.should == 1
64
- end
65
- end
66
-
67
- context "Module#metaattr_reader" do
68
- deprec_specify "it should create attr_readers of singleton/class methods" do
69
- @c = Class.new do
70
- @y = 1
71
- @x = 2
72
- metaattr_reader :y, :x
73
- end
74
- @c.y.should == 1
75
- @c.x.should == 2
76
- end
77
- end
78
-
79
- context "Object#is_one_of?" do
80
- deprec_specify "it should be true if the object is one of the classes" do
81
- 1.is_one_of?(Numeric, Array).should == true
82
- [].is_one_of?(Numeric, Array).should == true
83
- {}.is_one_of?(Numeric, Enumerable).should == true
84
- end
85
-
86
- deprec_specify "it should be false if the object is not one of the classes" do
87
- 'a'.is_one_of?(Numeric, Array).should == false
88
- Object.new.is_one_of?(Numeric, Array).should == false
89
- end
90
- end
91
-
92
- context "Object#blank?" do
93
- deprec_specify "it should be true if the object responds true to empty?" do
94
- [].blank?.should == true
95
- {}.blank?.should == true
96
- o = Object.new
97
- def o.empty?; true; end
98
- o.blank?.should == true
99
- end
100
-
101
- deprec_specify "it should be false if the object doesn't respond true to empty?" do
102
- [2].blank?.should == false
103
- {1=>2}.blank?.should == false
104
- Object.new.blank?.should == false
105
- end
106
- end
107
-
108
- context "Numeric#blank?" do
109
- deprec_specify "it should always be false" do
110
- 1.blank?.should == false
111
- 0.blank?.should == false
112
- -1.blank?.should == false
113
- 1.0.blank?.should == false
114
- 0.0.blank?.should == false
115
- -1.0.blank?.should == false
116
- 10000000000000000.blank?.should == false
117
- -10000000000000000.blank?.should == false
118
- 10000000000000000.0.blank?.should == false
119
- -10000000000000000.0.blank?.should == false
120
- end
121
- end
122
-
123
- context "NilClass#blank?" do
124
- deprec_specify "it should always be true" do
125
- nil.blank?.should == true
126
- end
127
- end
128
-
129
- context "TrueClass#blank?" do
130
- deprec_specify "it should always be false" do
131
- true.blank?.should == false
132
- end
133
- end
134
-
135
- context "FalseClass#blank?" do
136
- deprec_specify "it should always be true" do
137
- false.blank?.should == true
138
- end
139
- end
140
-
141
- context "FalseClass#blank?" do
142
- deprec_specify "it should be true if the string is empty" do
143
- ''.blank?.should == true
144
- end
145
- deprec_specify "it should be true if the string is composed of just whitespace" do
146
- ' '.blank?.should == true
147
- "\r\n\t".blank?.should == true
148
- (' '*4000).blank?.should == true
149
- ("\r\n\t"*4000).blank?.should == true
150
- end
151
- deprec_specify "it should be false if the string has any non whitespace characters" do
152
- '1'.blank?.should == false
153
- ("\r\n\t"*4000 + 'a').blank?.should == false
154
- ("\r\na\t"*4000).blank?.should == false
155
- end
156
- end