ardm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +35 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE +21 -0
  5. data/README.md +70 -0
  6. data/Rakefile +4 -0
  7. data/ardm.gemspec +29 -0
  8. data/db/.gitignore +1 -0
  9. data/lib/ardm/active_record/associations.rb +80 -0
  10. data/lib/ardm/active_record/base.rb +49 -0
  11. data/lib/ardm/active_record/dirty.rb +25 -0
  12. data/lib/ardm/active_record/hooks.rb +31 -0
  13. data/lib/ardm/active_record/inheritance.rb +37 -0
  14. data/lib/ardm/active_record/is/state_machine.rb +21 -0
  15. data/lib/ardm/active_record/is.rb +22 -0
  16. data/lib/ardm/active_record/not_found.rb +7 -0
  17. data/lib/ardm/active_record/predicate_builder/array_handler.rb +31 -0
  18. data/lib/ardm/active_record/predicate_builder/rails3.rb +147 -0
  19. data/lib/ardm/active_record/predicate_builder/rails4.rb +139 -0
  20. data/lib/ardm/active_record/predicate_builder/relation_handler.rb +15 -0
  21. data/lib/ardm/active_record/predicate_builder.rb +19 -0
  22. data/lib/ardm/active_record/property.rb +357 -0
  23. data/lib/ardm/active_record/query.rb +108 -0
  24. data/lib/ardm/active_record/record.rb +70 -0
  25. data/lib/ardm/active_record/relation.rb +83 -0
  26. data/lib/ardm/active_record/repository.rb +38 -0
  27. data/lib/ardm/active_record/serialization.rb +164 -0
  28. data/lib/ardm/active_record/storage_names.rb +28 -0
  29. data/lib/ardm/active_record/validations.rb +111 -0
  30. data/lib/ardm/active_record.rb +43 -0
  31. data/lib/ardm/data_mapper/not_found.rb +5 -0
  32. data/lib/ardm/data_mapper/record.rb +41 -0
  33. data/lib/ardm/data_mapper.rb +5 -0
  34. data/lib/ardm/env.rb +5 -0
  35. data/lib/ardm/property/api_key.rb +30 -0
  36. data/lib/ardm/property/bcrypt_hash.rb +31 -0
  37. data/lib/ardm/property/binary.rb +23 -0
  38. data/lib/ardm/property/boolean.rb +29 -0
  39. data/lib/ardm/property/class.rb +19 -0
  40. data/lib/ardm/property/comma_separated_list.rb +28 -0
  41. data/lib/ardm/property/csv.rb +35 -0
  42. data/lib/ardm/property/date.rb +12 -0
  43. data/lib/ardm/property/datetime.rb +12 -0
  44. data/lib/ardm/property/decimal.rb +38 -0
  45. data/lib/ardm/property/discriminator.rb +65 -0
  46. data/lib/ardm/property/enum.rb +51 -0
  47. data/lib/ardm/property/epoch_time.rb +38 -0
  48. data/lib/ardm/property/file_path.rb +25 -0
  49. data/lib/ardm/property/flag.rb +65 -0
  50. data/lib/ardm/property/float.rb +18 -0
  51. data/lib/ardm/property/integer.rb +24 -0
  52. data/lib/ardm/property/invalid_value_error.rb +22 -0
  53. data/lib/ardm/property/ip_address.rb +35 -0
  54. data/lib/ardm/property/json.rb +49 -0
  55. data/lib/ardm/property/lookup.rb +29 -0
  56. data/lib/ardm/property/numeric.rb +40 -0
  57. data/lib/ardm/property/object.rb +36 -0
  58. data/lib/ardm/property/paranoid_boolean.rb +18 -0
  59. data/lib/ardm/property/paranoid_datetime.rb +17 -0
  60. data/lib/ardm/property/regexp.rb +22 -0
  61. data/lib/ardm/property/serial.rb +16 -0
  62. data/lib/ardm/property/slug.rb +29 -0
  63. data/lib/ardm/property/string.rb +40 -0
  64. data/lib/ardm/property/support/dirty_minder.rb +169 -0
  65. data/lib/ardm/property/support/flags.rb +41 -0
  66. data/lib/ardm/property/support/paranoid_base.rb +78 -0
  67. data/lib/ardm/property/text.rb +11 -0
  68. data/lib/ardm/property/time.rb +12 -0
  69. data/lib/ardm/property/uri.rb +27 -0
  70. data/lib/ardm/property/uuid.rb +65 -0
  71. data/lib/ardm/property/validation.rb +208 -0
  72. data/lib/ardm/property/yaml.rb +38 -0
  73. data/lib/ardm/property.rb +891 -0
  74. data/lib/ardm/property_set.rb +152 -0
  75. data/lib/ardm/query/expression.rb +85 -0
  76. data/lib/ardm/query/ext/symbol.rb +37 -0
  77. data/lib/ardm/query/operator.rb +64 -0
  78. data/lib/ardm/record.rb +1 -0
  79. data/lib/ardm/support/assertions.rb +8 -0
  80. data/lib/ardm/support/deprecate.rb +12 -0
  81. data/lib/ardm/support/descendant_set.rb +89 -0
  82. data/lib/ardm/support/equalizer.rb +48 -0
  83. data/lib/ardm/support/ext/array.rb +22 -0
  84. data/lib/ardm/support/ext/blank.rb +25 -0
  85. data/lib/ardm/support/ext/hash.rb +67 -0
  86. data/lib/ardm/support/ext/module.rb +47 -0
  87. data/lib/ardm/support/ext/object.rb +57 -0
  88. data/lib/ardm/support/ext/string.rb +24 -0
  89. data/lib/ardm/support/ext/try_dup.rb +12 -0
  90. data/lib/ardm/support/hook.rb +405 -0
  91. data/lib/ardm/support/lazy_array.rb +451 -0
  92. data/lib/ardm/support/local_object_space.rb +13 -0
  93. data/lib/ardm/support/logger.rb +201 -0
  94. data/lib/ardm/support/mash.rb +176 -0
  95. data/lib/ardm/support/naming_conventions.rb +90 -0
  96. data/lib/ardm/support/ordered_set.rb +380 -0
  97. data/lib/ardm/support/subject.rb +33 -0
  98. data/lib/ardm/support/subject_set.rb +250 -0
  99. data/lib/ardm/version.rb +3 -0
  100. data/lib/ardm.rb +56 -0
  101. data/spec/fixtures/api_user.rb +11 -0
  102. data/spec/fixtures/article.rb +22 -0
  103. data/spec/fixtures/bookmark.rb +14 -0
  104. data/spec/fixtures/invention.rb +5 -0
  105. data/spec/fixtures/network_node.rb +23 -0
  106. data/spec/fixtures/person.rb +17 -0
  107. data/spec/fixtures/software_package.rb +22 -0
  108. data/spec/fixtures/ticket.rb +12 -0
  109. data/spec/fixtures/tshirt.rb +15 -0
  110. data/spec/integration/api_key_spec.rb +25 -0
  111. data/spec/integration/bcrypt_hash_spec.rb +45 -0
  112. data/spec/integration/comma_separated_list_spec.rb +85 -0
  113. data/spec/integration/dirty_minder_spec.rb +197 -0
  114. data/spec/integration/enum_spec.rb +79 -0
  115. data/spec/integration/epoch_time_spec.rb +59 -0
  116. data/spec/integration/file_path_spec.rb +158 -0
  117. data/spec/integration/flag_spec.rb +72 -0
  118. data/spec/integration/ip_address_spec.rb +151 -0
  119. data/spec/integration/json_spec.rb +70 -0
  120. data/spec/integration/slug_spec.rb +65 -0
  121. data/spec/integration/uri_spec.rb +136 -0
  122. data/spec/integration/uuid_spec.rb +102 -0
  123. data/spec/integration/yaml_spec.rb +85 -0
  124. data/spec/public/property/binary_spec.rb +41 -0
  125. data/spec/public/property/boolean_spec.rb +30 -0
  126. data/spec/public/property/class_spec.rb +28 -0
  127. data/spec/public/property/date_spec.rb +22 -0
  128. data/spec/public/property/date_time_spec.rb +22 -0
  129. data/spec/public/property/decimal_spec.rb +23 -0
  130. data/spec/public/property/discriminator_spec.rb +133 -0
  131. data/spec/public/property/float_spec.rb +22 -0
  132. data/spec/public/property/integer_spec.rb +22 -0
  133. data/spec/public/property/object_spec.rb +103 -0
  134. data/spec/public/property/serial_spec.rb +22 -0
  135. data/spec/public/property/string_spec.rb +22 -0
  136. data/spec/public/property/text_spec.rb +23 -0
  137. data/spec/public/property/time_spec.rb +22 -0
  138. data/spec/public/property_spec.rb +316 -0
  139. data/spec/rcov.opts +6 -0
  140. data/spec/schema.rb +86 -0
  141. data/spec/semipublic/property/binary_spec.rb +14 -0
  142. data/spec/semipublic/property/boolean_spec.rb +48 -0
  143. data/spec/semipublic/property/class_spec.rb +36 -0
  144. data/spec/semipublic/property/date_spec.rb +44 -0
  145. data/spec/semipublic/property/date_time_spec.rb +47 -0
  146. data/spec/semipublic/property/decimal_spec.rb +83 -0
  147. data/spec/semipublic/property/discriminator_spec.rb +22 -0
  148. data/spec/semipublic/property/float_spec.rb +83 -0
  149. data/spec/semipublic/property/integer_spec.rb +83 -0
  150. data/spec/semipublic/property/lookup_spec.rb +27 -0
  151. data/spec/semipublic/property/serial_spec.rb +14 -0
  152. data/spec/semipublic/property/string_spec.rb +14 -0
  153. data/spec/semipublic/property/text_spec.rb +30 -0
  154. data/spec/semipublic/property/time_spec.rb +49 -0
  155. data/spec/semipublic/property_spec.rb +51 -0
  156. data/spec/shared/flags_shared_spec.rb +36 -0
  157. data/spec/shared/identity_function_group.rb +5 -0
  158. data/spec/shared/public_property_spec.rb +229 -0
  159. data/spec/shared/semipublic_property_spec.rb +159 -0
  160. data/spec/spec.opts +4 -0
  161. data/spec/spec_helper.rb +58 -0
  162. data/spec/unit/bcrypt_hash_spec.rb +154 -0
  163. data/spec/unit/csv_spec.rb +139 -0
  164. data/spec/unit/dirty_minder_spec.rb +64 -0
  165. data/spec/unit/enum_spec.rb +125 -0
  166. data/spec/unit/epoch_time_spec.rb +72 -0
  167. data/spec/unit/file_path_spec.rb +75 -0
  168. data/spec/unit/flag_spec.rb +114 -0
  169. data/spec/unit/ip_address_spec.rb +109 -0
  170. data/spec/unit/json_spec.rb +127 -0
  171. data/spec/unit/paranoid_boolean_spec.rb +142 -0
  172. data/spec/unit/paranoid_datetime_spec.rb +149 -0
  173. data/spec/unit/regexp_spec.rb +62 -0
  174. data/spec/unit/uri_spec.rb +64 -0
  175. data/spec/unit/yaml_spec.rb +111 -0
  176. data/tasks/spec.rake +40 -0
  177. data/tasks/yard.rake +9 -0
  178. data/tasks/yardstick.rake +19 -0
  179. metadata +350 -0
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Class do
4
+ before do
5
+ Object.send(:remove_const, :Foo) if defined?(Foo)
6
+ Object.send(:remove_const, :Bar) if defined?(Bar)
7
+
8
+ class ::Foo; end
9
+ class ::Bar; end
10
+
11
+ @name = :type
12
+ @type = described_class
13
+ @load_as = Class
14
+ @value = Foo
15
+ @other_value = Bar
16
+ @invalid_value = 1
17
+ end
18
+
19
+ it_should_behave_like 'A public Property'
20
+
21
+ describe '.options' do
22
+ subject { described_class.options }
23
+
24
+ it { should be_kind_of(Hash) }
25
+
26
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_constant) }
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Date do
4
+ before do
5
+ @name = :created_on
6
+ @type = described_class
7
+ @load_as = Date
8
+ @value = Date.today
9
+ @other_value = Date.today + 1
10
+ @invalid_value = 1
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_date) }
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::DateTime do
4
+ before do
5
+ @name = :created_at
6
+ @type = described_class
7
+ @load_as = DateTime
8
+ @value = DateTime.now
9
+ @other_value = DateTime.now + 15
10
+ @invalid_value = 1
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_datetime) }
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Decimal do
4
+ before do
5
+ @name = :rate
6
+ @type = described_class
7
+ @options = { :precision => 5, :scale => 2 }
8
+ @load_as = BigDecimal
9
+ @value = BigDecimal('1.0')
10
+ @other_value = BigDecimal('2.0')
11
+ @invalid_value = true
12
+ end
13
+
14
+ it_should_behave_like 'A public Property'
15
+
16
+ describe '.options' do
17
+ subject { described_class.options }
18
+
19
+ it { should be_kind_of(Hash) }
20
+
21
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_decimal, :precision => 10, :scale => 0) }
22
+ end
23
+ end
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ module ::DiscBlog
4
+ class Content < Ardm::Record
5
+ self.table_name = "articles"
6
+
7
+ property :id, Serial
8
+ property :title, String, :required => true
9
+ property :type, Discriminator, :field => "slug"
10
+ end
11
+
12
+ class Article < Content; end
13
+ class Announcement < Article; end
14
+ class Release < Announcement; end
15
+ end
16
+
17
+
18
+ describe Ardm::Property::Discriminator do
19
+ before do
20
+ @content_model = DiscBlog::Content
21
+ @article_model = DiscBlog::Article
22
+ @announcement_model = DiscBlog::Announcement
23
+ @release_model = DiscBlog::Release
24
+ end
25
+
26
+ describe '.options' do
27
+ subject { described_class.options }
28
+
29
+ it { should be_kind_of(Hash) }
30
+
31
+ it { should include(:load_as => Class, :required => true) }
32
+ end
33
+
34
+ it 'should typecast to a Model' do
35
+ @article_model.properties[:type].typecast('DiscBlog::Release').should equal(@release_model)
36
+ end
37
+
38
+ describe 'Model#new' do
39
+ describe 'when provided a String discriminator in the attributes' do
40
+ before do
41
+ @resource = @article_model.new(:type => 'DiscBlog::Release')
42
+ end
43
+
44
+ it 'should return a Resource' do
45
+ @resource.should be_kind_of(Ardm::Record)
46
+ end
47
+
48
+ it 'should be an descendant instance' do
49
+ @resource.should be_instance_of(DiscBlog::Release)
50
+ end
51
+ end
52
+
53
+ describe 'when provided a Class discriminator in the attributes' do
54
+ before do
55
+ @resource = @article_model.new(:type => DiscBlog::Release)
56
+ end
57
+
58
+ it 'should return a Resource' do
59
+ @resource.should be_kind_of(Ardm::Record)
60
+ end
61
+
62
+ it 'should be an descendant instance' do
63
+ @resource.should be_instance_of(DiscBlog::Release)
64
+ end
65
+ end
66
+
67
+ describe 'when not provided a discriminator in the attributes' do
68
+ before do
69
+ @resource = @article_model.new
70
+ end
71
+
72
+ it 'should return a Resource' do
73
+ @resource.should be_kind_of(Ardm::Record)
74
+ end
75
+
76
+ it 'should be a base model instance' do
77
+ @resource.should be_instance_of(@article_model)
78
+ end
79
+ end
80
+ end
81
+
82
+ describe 'Model#descendants' do
83
+ it 'should set the descendants for the grandparent model' do
84
+ @article_model.descendants.to_a.should =~ [ @announcement_model, @release_model ]
85
+ end
86
+
87
+ it 'should set the descendants for the parent model' do
88
+ @announcement_model.descendants.to_a.should == [ @release_model ]
89
+ end
90
+
91
+ it 'should set the descendants for the child model' do
92
+ @release_model.descendants.to_a.should == []
93
+ end
94
+ end
95
+
96
+ describe 'Model#default_scope', :pending => "I don't understand the intention of these" do
97
+ it 'should have no default scope for the top level model' do
98
+ @content_model.default_scope[:type].should be_nil
99
+ end
100
+
101
+ it 'should set the default scope for the grandparent model' do
102
+ @article_model.default_scope[:type].to_a.should =~ [ @article_model, @announcement_model, @release_model ]
103
+ end
104
+
105
+ it 'should set the default scope for the parent model' do
106
+ @announcement_model.default_scope[:type].to_a.should =~ [ @announcement_model, @release_model ]
107
+ end
108
+
109
+ it 'should set the default scope for the child model' do
110
+ @release_model.default_scope[:type].to_a.should == [ @release_model ]
111
+ end
112
+ end
113
+
114
+ before do
115
+ @announcement = @announcement_model.create(:title => 'Announcement')
116
+ end
117
+
118
+ it 'should persist the type' do
119
+ @announcement.class.find(*@announcement.key).type.should equal(@announcement_model)
120
+ end
121
+
122
+ it 'should be retrieved as an instance of the correct class' do
123
+ @announcement.class.find(*@announcement.key).should be_instance_of(@announcement_model)
124
+ end
125
+
126
+ it 'should include descendants in finders' do
127
+ @article_model.first.should eql(@announcement)
128
+ end
129
+
130
+ it 'should not include ancestors' do
131
+ @release_model.first.should be_nil
132
+ end
133
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Float do
4
+ before do
5
+ @name = :rating
6
+ @type = described_class
7
+ @load_as = Float
8
+ @value = 0.1
9
+ @other_value = 0.2
10
+ @invalid_value = '1'
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_float, :precision => 10, :scale => nil) }
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Integer do
4
+ before do
5
+ @name = :age
6
+ @type = described_class
7
+ @load_as = Integer
8
+ @value = 1
9
+ @other_value = 2
10
+ @invalid_value = '1'
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_integer) }
21
+ end
22
+ end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property, 'Object type' do
4
+ before do
5
+ module ::Blog
6
+ class Article < Ardm::Record
7
+ self.table_name = "articles"
8
+ property :id, Serial
9
+ property :title, String
10
+ property :meta, Object, :required => true, :field => 'body'
11
+ end
12
+ end
13
+
14
+ @model = Blog::Article
15
+ @property = @model.properties[:meta]
16
+ end
17
+
18
+ subject { @property }
19
+
20
+ describe '.options' do
21
+ subject { described_class.options }
22
+
23
+ it { should be_kind_of(Hash) }
24
+
25
+ it { should be_empty }
26
+ end
27
+
28
+ it { should respond_to(:typecast) }
29
+
30
+ describe '#typecast' do
31
+ before do
32
+ @value = { 'lang' => 'en_CA' }
33
+ end
34
+
35
+ subject { @property.typecast(@value) }
36
+
37
+ it { should equal(@value) }
38
+ end
39
+
40
+ it { should respond_to(:dump) }
41
+
42
+ describe '#dump' do
43
+ describe 'with a value' do
44
+ before do
45
+ @value = { 'lang' => 'en_CA' }
46
+ end
47
+
48
+ subject { @property.dump(@value) }
49
+
50
+ it { @property.load(subject).should == @value }
51
+ end
52
+
53
+ describe 'with nil' do
54
+ subject { @property.dump(nil) }
55
+
56
+ it { should be_nil }
57
+ end
58
+ end
59
+
60
+ it { should respond_to(:valid?) }
61
+
62
+ describe '#valid?' do
63
+ describe 'with a valid load_as' do
64
+ subject { @property.valid?('lang' => 'en_CA') }
65
+
66
+ it { should be(true) }
67
+ end
68
+
69
+ describe 'with nil and property is not required' do
70
+ before do
71
+ @property = @model.property(:meta, Object, :required => false)
72
+ end
73
+
74
+ subject { @property.valid?(nil) }
75
+
76
+ it { should be(true) }
77
+ end
78
+
79
+ describe 'with nil and property is required' do
80
+ subject { @property.valid?(nil) }
81
+
82
+ it { should be(false) }
83
+ end
84
+
85
+ describe 'with nil and property is required, but validity is negated' do
86
+ subject { @property.valid?(nil, true) }
87
+
88
+ it { should be(true) }
89
+ end
90
+ end
91
+
92
+ describe 'persistable' do
93
+ before do
94
+ @resource = @model.create(:title => 'Test', :meta => { 'lang' => 'en_CA' })
95
+ end
96
+
97
+ subject { @resource.reload.meta }
98
+
99
+ it 'should load the correct value' do
100
+ should == { 'lang' => 'en_CA' }
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Serial do
4
+ before do
5
+ @name = :id
6
+ @type = described_class
7
+ @load_as = Integer
8
+ @value = 1
9
+ @other_value = 2
10
+ @invalid_value = 'foo'
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_integer, :min => 1, :serial => true) }
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::String do
4
+ before do
5
+ @name = :name
6
+ @type = described_class
7
+ @load_as = String
8
+ @value = 'value'
9
+ @other_value = 'return value'
10
+ @invalid_value = 1
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_string, :length => 50) }
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Text do
4
+ before do
5
+ @name = :title
6
+ @type = described_class
7
+ @load_as = String
8
+ @value = 'value'
9
+ @other_value = 'return value'
10
+ @invalid_value = 1
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_string, :length => 65535, :lazy => true) }
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ardm::Property::Time do
4
+ before do
5
+ @name = :deleted_at
6
+ @type = described_class
7
+ @load_as = Time
8
+ @value = Time.now
9
+ @other_value = Time.now + 15
10
+ @invalid_value = 1
11
+ end
12
+
13
+ it_should_behave_like 'A public Property'
14
+
15
+ describe '.options' do
16
+ subject { described_class.options }
17
+
18
+ it { should be_kind_of(Hash) }
19
+
20
+ it { should eql(:load_as => @load_as, :dump_as => @load_as, :coercion_method => :to_time) }
21
+ end
22
+ end