ohm-contrib 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ begin
14
14
  gem.add_development_dependency "redis", ">= 0"
15
15
  gem.add_development_dependency "ohm", ">= 0"
16
16
  gem.add_development_dependency "timecop", ">= 0"
17
+ gem.add_development_dependency "mocha", ">= 0"
17
18
  end
18
19
  Jeweler::GemcutterTasks.new
19
20
  rescue LoadError
@@ -52,4 +53,4 @@ Rake::RDocTask.new do |rdoc|
52
53
  rdoc.title = "ohm-contrib #{version}"
53
54
  rdoc.rdoc_files.include('README*')
54
55
  rdoc.rdoc_files.include('lib/**/*.rb')
55
- end
56
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -1,6 +1,6 @@
1
1
  module Ohm
2
2
  module Contrib
3
- VERSION = '0.0.8'
3
+ VERSION = '0.0.9'
4
4
  end
5
5
 
6
6
  autoload :Boundaries, "ohm/contrib/boundaries"
@@ -1,163 +1,91 @@
1
1
  require 'bigdecimal'
2
2
  require 'time'
3
3
  require 'date'
4
+ require 'forwardable'
4
5
 
5
6
  module Ohm
6
7
  module Types
7
- class String < ::String
8
- def self.[](value)
9
- new(value)
8
+ class Primitive < BasicObject
9
+ def initialize(value)
10
+ @raw = value
10
11
  end
11
- end
12
-
13
- class Time < ::Time
14
- ASSERTION = :assert_type_time
15
-
16
- def self.[](value)
17
- return value if value.to_s.empty?
18
12
 
19
- ret = parse(value)
20
- ret.to_s == value ? ret : value
13
+ def to_s
14
+ @raw
21
15
  end
22
- end
23
-
24
- class Date < ::Date
25
- ASSERTION = :assert_type_date
26
-
27
- def self.[](value)
28
- return value if value.to_s.empty?
29
16
 
30
- parse(value)
31
- rescue ArgumentError
32
- value
17
+ def inspect
18
+ "#<Primitive raw=#{@raw}>"
33
19
  end
34
- end
35
-
36
- class Decimal < BigDecimal
37
- ASSERTION = :assert_type_decimal
38
- CANONICAL = /^(\d+)?(\.\d+)?(E[+\-]\d+)?$/
39
-
40
- def self.[](value)
41
- return value if value.to_s.empty?
42
20
 
43
- if value.to_s =~ CANONICAL
44
- new(value)
45
- else
46
- value
47
- end
21
+ protected
22
+ def object
23
+ @raw
48
24
  end
49
- end
50
25
 
51
- class Float < ::Float
52
- ASSERTION = :assert_type_float
53
-
54
- def self.[](value)
55
- return value if value.to_s.empty?
56
-
57
- Float(value)
58
- rescue ArgumentError
59
- value
26
+ def method_missing(meth, *args, &blk)
27
+ object.send(meth, *args, &blk)
60
28
  end
61
29
  end
62
30
 
63
- class Integer < ::Integer
64
- ASSERTION = :assert_type_integer
65
-
66
- def self.[](value)
67
- return value if value.to_s.empty?
68
-
69
- Integer(value)
70
- rescue ArgumentError
71
- value
72
- end
31
+ class String < Primitive
73
32
  end
74
- end
75
-
76
- module TypeAssertions
77
33
 
78
- protected
79
- def assert_type_decimal(att, error = [att, :not_decimal])
80
- assert send(att).is_a?(Ohm::Types::Decimal), error
34
+ class Decimal < Primitive
35
+ protected
36
+ def object
37
+ ::Kernel::BigDecimal(@raw)
38
+ end
81
39
  end
82
40
 
83
- def assert_type_time(att, error = [att, :not_time])
84
- assert send(att).is_a?(Ohm::Types::Time), error
41
+ class Integer < Primitive
42
+ protected
43
+ def object
44
+ ::Kernel::Integer(@raw)
45
+ end
85
46
  end
86
47
 
87
- def assert_type_date(att, error = [att, :not_date])
88
- assert send(att).is_a?(Ohm::Types::Date), error
48
+ class Float < Primitive
49
+ protected
50
+ def object
51
+ ::Kernel::Float(@raw)
52
+ end
89
53
  end
90
54
 
91
- def assert_type_integer(att, error = [att, :not_integer])
92
- assert send(att).is_a?(Ohm::Types::Integer), error
55
+ class Time < Primitive
56
+ protected
57
+ def object
58
+ ::Time.parse(@raw)
59
+ end
93
60
  end
94
61
 
95
- def assert_type_float(att, error = [att, :not_float])
96
- assert send(att).is_a?(Ohm::Types::Float), error
62
+ class Date < Primitive
63
+ protected
64
+ def object
65
+ ::Date.parse(@raw)
66
+ end
97
67
  end
98
68
  end
99
-
69
+
100
70
  module Typecast
101
- class MissingValidation < StandardError
102
- MESSAGE = "%s :%s is required in your #validate method"
103
-
104
- attr :field
105
- attr :assertion
106
-
107
- def initialize(field, assertion)
108
- @field, @assertion = field, assertion
109
- end
110
-
111
- def message
112
- MESSAGE % [assertion, field]
113
- end
114
- end
115
-
116
71
  include Types
117
- include TypeAssertions
118
-
72
+
119
73
  def self.included(base)
120
74
  base.extend ClassMethods
121
75
  end
122
76
 
123
77
  module ClassMethods
124
- def attribute(name, type = Ohm::Types::String, assertion = defined?(type::ASSERTION) ? type::ASSERTION : nil)
78
+ def attribute(name, type = Ohm::Types::String)
125
79
  define_method(name) do
126
- type[read_local(name)]
80
+ value = read_local(name)
81
+ value && type.new(value)
127
82
  end
128
83
 
129
84
  define_method(:"#{name}=") do |value|
130
- if type.respond_to?(:dump)
131
- write_local(name, type.dump(value))
132
- else
133
- write_local(name, value && value.to_s)
134
- end
85
+ write_local(name, value && value.to_s)
135
86
  end
136
87
 
137
88
  attributes << name unless attributes.include?(name)
138
- types[name] = [type, assertion] unless types.has_key?(name)
139
- end
140
-
141
- def types
142
- @types ||= {}
143
- end
144
- end
145
-
146
- def valid?
147
- return unless super
148
-
149
- self.class.types.each do |field, (type, assertion)|
150
- value = send(field)
151
-
152
- unless value.kind_of?(type)
153
- raise MissingValidation.new(field, assertion)
154
- end
155
- end
156
- end
157
-
158
- def validate
159
- self.class.types.each do |field, (type, assertion)|
160
- send assertion, field if assertion
161
89
  end
162
90
  end
163
91
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ohm-contrib}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cyril David"]
@@ -65,17 +65,20 @@ Gem::Specification.new do |s|
65
65
  s.add_development_dependency(%q<redis>, [">= 0"])
66
66
  s.add_development_dependency(%q<ohm>, [">= 0"])
67
67
  s.add_development_dependency(%q<timecop>, [">= 0"])
68
+ s.add_development_dependency(%q<mocha>, [">= 0"])
68
69
  else
69
70
  s.add_dependency(%q<contest>, [">= 0"])
70
71
  s.add_dependency(%q<redis>, [">= 0"])
71
72
  s.add_dependency(%q<ohm>, [">= 0"])
72
73
  s.add_dependency(%q<timecop>, [">= 0"])
74
+ s.add_dependency(%q<mocha>, [">= 0"])
73
75
  end
74
76
  else
75
77
  s.add_dependency(%q<contest>, [">= 0"])
76
78
  s.add_dependency(%q<redis>, [">= 0"])
77
79
  s.add_dependency(%q<ohm>, [">= 0"])
78
80
  s.add_dependency(%q<timecop>, [">= 0"])
81
+ s.add_dependency(%q<mocha>, [">= 0"])
79
82
  end
80
83
  end
81
84
 
@@ -4,6 +4,7 @@ require 'contest'
4
4
  require 'redis'
5
5
  require 'ohm'
6
6
  require 'timecop'
7
+ require 'mocha'
7
8
 
8
9
  Ohm.connect :host => "localhost", :port => "6380"
9
10
 
@@ -12,4 +13,4 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
12
13
  require 'ohm/contrib'
13
14
 
14
15
  class Test::Unit::TestCase
15
- end
16
+ end
@@ -1,383 +1,238 @@
1
1
  require "helper"
2
2
 
3
3
  class TestOhmTypecast < Test::Unit::TestCase
4
- context "decimal typecasting" do
5
- class Product < Ohm::Model
4
+ context "the default case of just an attribute" do
5
+ class Post < Ohm::Model
6
6
  include Ohm::Typecast
7
-
8
- attribute :price, Decimal
9
-
10
- # override validate and purposely forget super
11
- def validate
12
- end
7
+
8
+ attribute :content
13
9
  end
14
10
 
15
- should "properly preserve the right precision" do
16
- product = Product.create(:price => 0.0001)
17
- product = Product[product.id]
18
- sum = 0
19
- 1_000.times { sum += product.price }
11
+ test "handles nil case correctly" do
12
+ post = Post.create(:content => nil)
13
+ post = Post[post.id]
20
14
 
21
- assert_equal 0.1, sum
15
+ assert_nil post.content
22
16
  end
23
17
 
24
- context "given a non-decimal value FooBar" do
25
- should "preseve the value FooBar" do
26
- product = Product.new(:price => "FooBar")
27
- assert_equal "FooBar", product.price
28
- end
29
-
30
- should "raise a MissingValidation error during validation" do
31
- product = Product.new(:price => "FooBar")
18
+ test "still responds to string methods properly" do
19
+ post = Post.create(:content => "FooBar")
20
+ post = Post[post.id]
32
21
 
33
- begin
34
- product.valid?
35
- rescue Ohm::Typecast::MissingValidation => ex
36
- assert_match(/assert_type_decimal :price is required in your #validate method/, ex.message)
37
- else
38
- flunk "Should have raised MissingValidation"
39
- end
40
- end
41
- end
42
-
43
- context "given a non-decimal value FooBar but with assert_type_decimal" do
44
- class Post < Ohm::Model
45
- include Ohm::Typecast
46
-
47
- attribute :price, Decimal
48
- end
49
-
50
- should "be invalid and have an error on the field" do
51
- post = Post.new(:price => "FooBar")
52
-
53
- assert ! post.valid?
54
- assert_equal [[:price, :not_decimal]], post.errors
55
- end
22
+ assert_equal "foobar", post.content.downcase
56
23
  end
57
24
  end
58
25
 
59
- context "time typecasting" do
60
- class Product < Ohm::Model
26
+ context "when using a decimal" do
27
+ class Post < Ohm::Model
61
28
  include Ohm::Typecast
62
-
63
- attribute :start_of_sale, Time
64
-
65
- # we override validate and purposely forget to call super
66
- def validate
67
- end
29
+
30
+ attribute :price, Decimal
68
31
  end
69
32
 
70
- test "read / write" do
71
- @time = Time.now.utc
72
- product = Product.create(:start_of_sale => @time)
73
- product = Product[product.id]
33
+ test "handles nil case correctly" do
34
+ post = Post.create(:price => nil)
35
+ post = Post[post.id]
74
36
 
75
- assert_equal @time.to_s, product.start_of_sale.to_s
37
+ assert_nil post.price
76
38
  end
77
39
 
78
- test "the retrieved value is a Time object" do
79
- @time = Time.now.utc
80
- product = Product.create(:start_of_sale => @time)
81
- product = Product[product.id]
82
-
83
- assert_kind_of Time, product.start_of_sale
40
+ test "handles empty string case correctly" do
41
+ post = Post.create(:price => "")
42
+ post = Post[post.id]
43
+
44
+ assert_equal "", post.price.to_s
84
45
  end
85
46
 
86
- test "an invalid string" do
87
- begin
88
- Product.create(:start_of_sale => "invalid time")
89
- rescue Ohm::Typecast::MissingValidation => ex
90
- assert_match(/assert_type_time :start_of_sale is required in your #validate method/, ex.message)
91
- else
92
- flunk "Should have raised MissingValidation"
93
- end
94
- end
47
+ test "allows for real arithmetic" do
48
+ post = Post.create(:price => "0.01")
49
+ post = Post[post.id]
95
50
 
96
- test "when nil" do
97
- product = Product.new(:start_of_sale => nil)
98
- assert_nil product.start_of_sale
51
+ assert_equal 0.02, post.price + post.price
52
+ assert_equal 0.0, post.price - post.price
53
+ assert_equal 0.0001, post.price * post.price
54
+ assert_equal 1.0, post.price / post.price
99
55
  end
100
56
 
101
- test "when empty string" do
102
- product = Product.new(:start_of_sale => "")
103
- assert_equal "", product.start_of_sale
57
+ test "is accurate accdg to the decimal spec" do
58
+ post = Post.create(:price => "0.0001")
59
+ post = Post[post.id]
60
+
61
+ sum = 0
62
+ 1_000.times { sum += post.price }
63
+ assert_equal 0.1, sum
104
64
  end
105
65
  end
106
66
 
107
- context "time typecasting with assert_type_time" do
67
+ context "when using an integer" do
108
68
  class Post < Ohm::Model
109
69
  include Ohm::Typecast
110
-
111
- attribute :start_of_sale, Time
112
- end
113
-
114
- should "be valid given invalid time value" do
115
- post = Post.new(:start_of_sale => "FooBar")
116
- assert ! post.valid?
117
- assert_equal [[:start_of_sale, :not_time]], post.errors
70
+
71
+ attribute :price, Integer
118
72
  end
119
- end
120
73
 
121
- context "date typecasting" do
122
- class Product < Ohm::Model
123
- include Ohm::Typecast
124
-
125
- attribute :date_bought, Date
74
+ test "handles nil case correctly" do
75
+ post = Post.create(:price => nil)
76
+ post = Post[post.id]
126
77
 
127
- # override validate and purposely forget super
128
- def validate
129
- end
78
+ assert_nil post.price
130
79
  end
131
80
 
132
- test "read / write" do
133
- @date = Date.today
134
- product = Product.create(:date_bought => @date)
135
- product = Product[product.id]
136
-
137
- assert_equal @date, product.date_bought
81
+ test "handles empty string case correctly" do
82
+ post = Post.create(:price => "")
83
+ post = Post[post.id]
84
+
85
+ assert_equal "", post.price.to_s
138
86
  end
139
87
 
140
- test "the retrieved value is a Date object" do
141
- @date = Date.today
142
- product = Product.create(:date_bought => @date)
143
- product = Product[product.id]
88
+ test "allows for real arithmetic" do
89
+ post = Post.create(:price => "3")
90
+ post = Post[post.id]
144
91
 
145
- assert_kind_of Date, product.date_bought
92
+ assert_equal 6, post.price + post.price
93
+ assert_equal 0, post.price - post.price
94
+ assert_equal 9, post.price * post.price
95
+ assert_equal 1, post.price / post.price
146
96
  end
147
97
 
148
- test "assigning a string which is not a valid date" do
149
- begin
150
- Product.create(:date_bought => "Bla Bla")
151
- rescue Ohm::Typecast::MissingValidation => ex
152
- assert_match(/assert_type_date :date_bought is required in your #validate method/, ex.message)
153
- else
154
- flunk "Should have raised MissingValidation"
98
+ test "raises when trying to do arithmetic ops on a non-int" do
99
+ post = Post.create(:price => "FooBar")
100
+ post = Post[post.id]
101
+
102
+ assert_raise ArgumentError do
103
+ post.price * post.price
155
104
  end
156
105
  end
157
-
158
- test "when nil" do
159
- assert_nil Product.new.date_bought
160
- end
161
-
162
- test "empty string" do
163
- assert_equal "", Product.new(:date_bought => "").date_bought
164
- end
165
106
  end
166
107
 
167
- context "date typecasting with assert_type_date" do
108
+ context "when using an float" do
168
109
  class Post < Ohm::Model
169
110
  include Ohm::Typecast
170
-
171
- attribute :created, Date
172
-
173
- def validate
174
- assert_type_date :created
175
- end
176
- end
177
-
178
- should "have an invalid created field on save" do
179
- post = Post.new(:created => "FooBar")
180
- assert ! post.valid?
181
- assert_equal [[:created, :not_date]], post.errors
182
- assert_equal "FooBar", post.created
183
- end
184
- end
185
-
186
- context "integer typecasting" do
187
- class Product < Ohm::Model
188
- include Ohm::Typecast
189
-
190
- attribute :stock_count, Integer
111
+
112
+ attribute :price, Float
191
113
  end
192
114
 
193
- test "when nil" do
194
- assert_nil Product.new(:stock_count => nil).stock_count
195
- end
115
+ test "handles nil case correctly" do
116
+ post = Post.create(:price => nil)
117
+ post = Post[post.id]
196
118
 
197
- test "when empty string" do
198
- assert_equal "", Product.new(:stock_count => "").stock_count
119
+ assert_nil post.price
199
120
  end
200
121
 
201
- test "when unparseable" do
202
- assert_equal "FooBar", Product.new(:stock_count => "FooBar").stock_count
122
+ test "handles empty string case correctly" do
123
+ post = Post.create(:price => "")
124
+ post = Post[post.id]
125
+
126
+ assert_equal "", post.price.to_s
203
127
  end
204
128
 
205
- test "when a float" do
206
- assert_equal '1.0', Product.new(:stock_count => "1.0").stock_count
207
- end
129
+ test "allows for real arithmetic" do
130
+ post = Post.create(:price => "3")
131
+ post = Post[post.id]
208
132
 
209
- test "when a real int" do
210
- assert_equal 1, Product.new(:stock_count => '1').stock_count
133
+ assert_equal 6.0, post.price + post.price
134
+ assert_equal 0.0, post.price - post.price
135
+ assert_equal 9.0, post.price * post.price
136
+ assert_equal 1.0, post.price / post.price
211
137
  end
212
- end
213
-
214
- context "integer typecasting with assert_type_integer validation" do
215
- class Post < Ohm::Model
216
- include Ohm::Typecast
217
138
 
218
- attribute :counter, Integer
219
-
220
- def validate
221
- assert_type_integer :counter
139
+ test "raises when trying to do arithmetic ops on a non-float" do
140
+ post = Post.create(:price => "FooBar")
141
+ post = Post[post.id]
142
+
143
+ assert_raise ArgumentError do
144
+ post.price * post.price
222
145
  end
223
146
  end
224
-
225
- should "have an error on counter given a non-integer value" do
226
- post = Post.new(:counter => "FooBar")
227
- assert ! post.valid?
228
- assert_equal [[:counter, :not_integer]], post.errors
229
- assert_equal "FooBar", post.counter
230
- end
231
147
  end
232
148
 
233
- context "float typecasting" do
234
- class Product < Ohm::Model
149
+ context "when using a time" do
150
+ class Post < Ohm::Model
235
151
  include Ohm::Typecast
236
-
237
- attribute :vat, Float
238
- end
239
-
240
- test "when nil" do
241
- assert_nil Product.new(:vat => nil).vat
152
+
153
+ attribute :created_at, Time
242
154
  end
243
155
 
244
- test "when empty string" do
245
- assert_equal "", Product.new(:vat => "").vat
246
- end
156
+ test "handles nil case correctly" do
157
+ post = Post.create(:created_at => nil)
158
+ post = Post[post.id]
247
159
 
248
- test "when unparseable" do
249
- assert_equal "FooBar", Product.new(:vat => "FooBar").vat
160
+ assert_nil post.created_at
250
161
  end
251
162
 
252
- test "when a float" do
253
- assert_equal 1.0, Product.new(:vat => "1.0").vat
163
+ test "handles empty string case correctly" do
164
+ post = Post.create(:created_at => "")
165
+ post = Post[post.id]
166
+
167
+ assert_equal "", post.created_at.to_s
254
168
  end
255
169
 
256
- test "when an int" do
257
- assert_equal 1.0, Product.new(:vat => '1').vat
170
+ test "allows for real time operations" do
171
+ post = Post.create(:created_at => "2010-05-10")
172
+ post = Post[post.id]
173
+
174
+ assert_respond_to post.created_at, :strftime
175
+ assert_equal "2010-05-10", post.created_at.strftime('%Y-%m-%d')
258
176
  end
259
177
 
260
- test "when a .12 value" do
261
- assert_equal 0.12, Product.new(:vat => ".12").vat
262
- end
263
- end
264
-
265
- context "float typecasting with assert_type_float validation" do
266
- class Post < Ohm::Model
267
- include Ohm::Typecast
268
-
269
- attribute :quotient, Float
178
+ test "raises when trying to do non-time operations" do
179
+ post = Post.create(:created_at => "FooBar")
180
+ post = Post[post.id]
181
+
182
+ assert ! post.created_at.respond_to?(:slice)
270
183
 
271
- def validate
272
- assert_type_float :quotient
184
+ assert_raise NoMethodError do
185
+ post.created_at.slice
273
186
  end
274
187
  end
275
-
276
- should "have an error on quotient given a non-float value" do
277
- post = Post.new(:quotient => "FooBar")
278
- assert ! post.valid?
279
- assert_equal [[:quotient, :not_float]], post.errors
280
- assert_equal "FooBar", post.quotient
281
- end
282
188
  end
283
189
 
284
-
285
- context "trying to validate numericality of a decimal" do
286
- class Item < Ohm::Model
190
+ context "when using a date" do
191
+ class Post < Ohm::Model
287
192
  include Ohm::Typecast
193
+
194
+ attribute :created_on, Date
288
195
 
289
- attribute :price, Decimal
290
-
291
- def validate
292
- assert_numeric :price
293
- end
294
- end
295
-
296
- setup do
297
- @item = Item.new(:price => "FooBar")
298
- end
299
-
300
- test "invalidation of price" do
301
- assert ! @item.valid?
302
- assert_equal [[:price, :not_numeric]], @item.errors
303
- end
304
- end
305
-
306
- context "specifying a custom DataType without a #dump method" do
307
- class ::FooBar < Struct.new(:value)
308
- def self.[](str)
309
- new(str)
196
+ def today
197
+ ::Date.today
310
198
  end
311
199
  end
312
-
313
- class Item < Ohm::Model
314
- include Ohm::Typecast
315
200
 
316
- attribute :foo, FooBar
317
- end
201
+ test "handles nil case correctly" do
202
+ post = Post.create(:created_on => nil)
203
+ post = Post[post.id]
318
204
 
319
- should "use it as expected" do
320
- item = Item.new(:foo => "bar")
321
- assert_equal FooBar.new("bar"), item.foo
322
- end
323
- end
324
-
325
- context "specifying a customer DataType but with a #dump method" do
326
- class ::CSV < Array
327
- def self.dump(arr)
328
- arr.join(',')
329
- end
330
-
331
- def self.[](str)
332
- new(str.split(','))
333
- end
334
-
335
- def to_s
336
- join(',')
337
- end
205
+ assert_nil post.created_on
338
206
  end
339
207
 
340
- class Item < Ohm::Model
341
- include Ohm::Typecast
342
-
343
- attribute :csv, CSV
208
+ test "handles empty string case correctly" do
209
+ post = Post.create(:created_on => "")
210
+ post = Post[post.id]
211
+
212
+ assert_equal "", post.created_on.to_s
344
213
  end
345
214
 
346
-
347
- should "dump the appropriate value" do
348
- item = Item.new(:csv => [ 'first', 'second', 'third'])
215
+ test "allows for real time operations" do
216
+ post = Post.create(:created_on => "2010-05-10")
217
+ post = Post[post.id]
349
218
 
350
- assert_equal 'first,second,third', item.send(:read_local, :csv)
219
+ assert_respond_to post.created_on, :strftime
220
+ assert_equal "2010-05-10", post.created_on.strftime('%Y-%m-%d')
351
221
  end
352
222
 
353
- should "be able to retrieve it back properly" do
354
- item = Item.create(:csv => [ 'first', 'second', 'third'])
355
- item = Item[item.id]
356
-
357
- assert_equal ['first', 'second', 'third'], item.csv
223
+ test "raises when trying to do date operations on a non-date" do
224
+ post = Post.create(:created_on => "FooBar")
225
+ post = Post[post.id]
226
+
227
+ assert_raise ArgumentError do
228
+ post.created_on.strftime("%Y")
229
+ end
358
230
  end
359
231
 
360
- should "also be able to read/write with raw CSV" do
361
- item = Item.create(:csv => CSV.new(['first', 'second', 'third']))
362
- item = Item[item.id]
363
-
364
- assert_equal ['first', 'second', 'third'], item.csv
232
+ test "still able to access Date" do
233
+ assert_equal Date.today, Post.new.today
365
234
  end
366
235
  end
367
236
 
368
- context "defaut Strings" do
369
- class Post < Ohm::Model
370
- include Ohm::Typecast
371
-
372
- attribute :field1
373
- attribute :field2
374
- attribute :field3
375
- end
376
237
 
377
- should "not throw a validation missing exception during save" do
378
- assert_nothing_raised Ohm::Typecast::MissingValidation do
379
- Post.create :field1 => "field1", :field2 => "field2", :field3 => "fld3"
380
- end
381
- end
382
- end
383
238
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cyril David
@@ -65,6 +65,18 @@ dependencies:
65
65
  version: "0"
66
66
  type: :development
67
67
  version_requirements: *id004
68
+ - !ruby/object:Gem::Dependency
69
+ name: mocha
70
+ prerelease: false
71
+ requirement: &id005 !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ type: :development
79
+ version_requirements: *id005
68
80
  description: Highly decoupled drop-in functionality for Ohm models
69
81
  email: cyx.ucron@gmail.com
70
82
  executables: []