ardm 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +5 -13
  2. data/Gemfile +1 -2
  3. data/LICENSE +2 -2
  4. data/README.md +72 -16
  5. data/ardm.gemspec +1 -0
  6. data/lib/ardm.rb +2 -1
  7. data/lib/ardm/active_record.rb +8 -1
  8. data/lib/ardm/active_record/associations.rb +33 -4
  9. data/lib/ardm/active_record/base.rb +2 -0
  10. data/lib/ardm/active_record/collection.rb +5 -0
  11. data/lib/ardm/active_record/data_mapper_constant.rb +1 -0
  12. data/lib/ardm/active_record/data_mapper_constant_proxy.rb +24 -0
  13. data/lib/ardm/active_record/finalize.rb +18 -0
  14. data/lib/ardm/active_record/predicate_builder/array_handler.rb +10 -16
  15. data/lib/ardm/active_record/predicate_builder/rails3.rb +42 -15
  16. data/lib/ardm/active_record/predicate_builder/rails4.rb +39 -13
  17. data/lib/ardm/active_record/property.rb +24 -12
  18. data/lib/ardm/active_record/query.rb +9 -18
  19. data/lib/ardm/active_record/record.rb +54 -11
  20. data/lib/ardm/active_record/relation.rb +36 -6
  21. data/lib/ardm/active_record/repository.rb +6 -2
  22. data/lib/ardm/data_mapper.rb +2 -0
  23. data/lib/ardm/data_mapper/record.rb +3 -9
  24. data/lib/ardm/version.rb +1 -1
  25. data/spec/ardm/datamapper_constants_spec.rb +31 -0
  26. data/spec/fixtures/article.rb +2 -0
  27. data/spec/integration/api_key_spec.rb +3 -3
  28. data/spec/integration/bcrypt_hash_spec.rb +7 -7
  29. data/spec/integration/comma_separated_list_spec.rb +11 -11
  30. data/spec/integration/dirty_minder_spec.rb +23 -39
  31. data/spec/integration/enum_spec.rb +11 -11
  32. data/spec/integration/epoch_time_spec.rb +6 -6
  33. data/spec/integration/file_path_spec.rb +23 -23
  34. data/spec/integration/flag_spec.rb +11 -13
  35. data/spec/integration/ip_address_spec.rb +15 -15
  36. data/spec/integration/json_spec.rb +7 -7
  37. data/spec/integration/slug_spec.rb +6 -6
  38. data/spec/integration/uri_spec.rb +11 -11
  39. data/spec/integration/uuid_spec.rb +16 -16
  40. data/spec/integration/yaml_spec.rb +8 -8
  41. data/spec/public/model_spec.rb +193 -0
  42. data/spec/public/property/binary_spec.rb +4 -4
  43. data/spec/public/property/boolean_spec.rb +3 -3
  44. data/spec/public/property/class_spec.rb +2 -2
  45. data/spec/public/property/date_spec.rb +2 -2
  46. data/spec/public/property/date_time_spec.rb +2 -2
  47. data/spec/public/property/decimal_spec.rb +2 -2
  48. data/spec/public/property/discriminator_spec.rb +21 -20
  49. data/spec/public/property/float_spec.rb +2 -2
  50. data/spec/public/property/integer_spec.rb +2 -2
  51. data/spec/public/property/object_spec.rb +14 -13
  52. data/spec/public/property/serial_spec.rb +2 -2
  53. data/spec/public/property/string_spec.rb +2 -2
  54. data/spec/public/property/text_spec.rb +2 -2
  55. data/spec/public/property/time_spec.rb +2 -2
  56. data/spec/public/property_spec.rb +44 -48
  57. data/spec/public/resource_spec.rb +278 -0
  58. data/spec/schema.rb +33 -4
  59. data/spec/semipublic/property/boolean_spec.rb +5 -5
  60. data/spec/semipublic/property/class_spec.rb +3 -3
  61. data/spec/semipublic/property/date_spec.rb +8 -8
  62. data/spec/semipublic/property/date_time_spec.rb +9 -9
  63. data/spec/semipublic/property/decimal_spec.rb +16 -16
  64. data/spec/semipublic/property/float_spec.rb +16 -16
  65. data/spec/semipublic/property/integer_spec.rb +16 -16
  66. data/spec/semipublic/property/lookup_spec.rb +4 -4
  67. data/spec/semipublic/property/text_spec.rb +2 -2
  68. data/spec/semipublic/property/time_spec.rb +10 -10
  69. data/spec/semipublic/property_spec.rb +4 -4
  70. data/spec/shared/finder_shared_spec.rb +1151 -0
  71. data/spec/shared/flags_shared_spec.rb +6 -6
  72. data/spec/shared/identity_function_group.rb +1 -1
  73. data/spec/shared/public_property_spec.rb +26 -25
  74. data/spec/shared/resource_spec.rb +1218 -0
  75. data/spec/shared/semipublic_property_spec.rb +23 -22
  76. data/spec/spec_helper.rb +17 -0
  77. data/spec/unit/bcrypt_hash_spec.rb +15 -15
  78. data/spec/unit/csv_spec.rb +11 -11
  79. data/spec/unit/dirty_minder_spec.rb +3 -5
  80. data/spec/unit/enum_spec.rb +17 -17
  81. data/spec/unit/epoch_time_spec.rb +8 -8
  82. data/spec/unit/file_path_spec.rb +9 -9
  83. data/spec/unit/flag_spec.rb +9 -9
  84. data/spec/unit/ip_address_spec.rb +9 -9
  85. data/spec/unit/json_spec.rb +11 -11
  86. data/spec/unit/paranoid_boolean_spec.rb +19 -17
  87. data/spec/unit/paranoid_datetime_spec.rb +21 -19
  88. data/spec/unit/regexp_spec.rb +4 -4
  89. data/spec/unit/uri_spec.rb +8 -8
  90. data/spec/unit/yaml_spec.rb +9 -9
  91. metadata +35 -27
  92. data/lib/ardm/active_record/not_found.rb +0 -7
  93. data/lib/ardm/data_mapper/not_found.rb +0 -5
@@ -15,10 +15,8 @@ try_spec do
15
15
  end
16
16
 
17
17
  describe 'with the default value' do
18
- it 'returns it as an array' do
19
- pending "FIXME: This probably should pass" do
20
- @resource.size.should eq([Ardm::Fixtures::TShirt.properties[:size].default])
21
- end
18
+ it 'returns it as an array', skip: true do
19
+ expect(@resource.size).to eq([Ardm::Fixtures::TShirt.properties[:size].default])
22
20
  end
23
21
  end
24
22
 
@@ -26,12 +24,12 @@ try_spec do
26
24
  describe 'dumped and loaded' do
27
25
  before do
28
26
  @resource.size = [ :xs, :medium ]
29
- @resource.save.should be_true
27
+ expect(@resource.save).to be true
30
28
  @resource.reload
31
29
  end
32
30
 
33
- it 'returns size as array' do
34
- @resource.size.should == [ :xs, :medium ]
31
+ it 'returns size as array', pending: true do
32
+ expect(@resource.size).to eq([ :xs, :medium ])
35
33
  end
36
34
  end
37
35
  end
@@ -43,12 +41,12 @@ try_spec do
43
41
 
44
42
  describe 'dumped and loaded' do
45
43
  before do
46
- @resource.save.should be_true
44
+ expect(@resource.save).to be true
47
45
  @resource.reload
48
46
  end
49
47
 
50
- it 'returns size as array with a single value' do
51
- @resource.size.should == [:large]
48
+ it 'returns size as array with a single value', pending: true do
49
+ expect(@resource.size).to eq([:large])
52
50
  end
53
51
  end
54
52
  end
@@ -56,16 +54,16 @@ try_spec do
56
54
  # Flag does not add any auto validations
57
55
  describe 'without size' do
58
56
  before do
59
- @resource.should be_valid
57
+ expect(@resource).to be_valid
60
58
  @resource.size = nil
61
59
  end
62
60
 
63
61
  it 'is valid' do
64
- @resource.should be_valid
62
+ expect(@resource).to be_valid
65
63
  end
66
64
 
67
65
  it 'has no errors' do
68
- @resource.errors.should be_empty
66
+ expect(@resource.errors).to be_empty
69
67
  end
70
68
  end
71
69
  end
@@ -28,12 +28,12 @@ try_spec do
28
28
 
29
29
  describe 'when dumped and loaded' do
30
30
  before do
31
- @resource.save.should be(true)
31
+ expect(@resource.save).to be(true)
32
32
  @resource.reload
33
33
  end
34
34
 
35
35
  it 'is an IPv6 node' do
36
- @resource.should run_ipv6
36
+ expect(@resource).to run_ipv6
37
37
  end
38
38
  end
39
39
  end
@@ -45,12 +45,12 @@ try_spec do
45
45
 
46
46
  describe 'when dumped and loaded' do
47
47
  before do
48
- @resource.save.should be(true)
48
+ expect(@resource.save).to be(true)
49
49
  @resource.reload
50
50
  end
51
51
 
52
52
  it 'is an IPv4 node' do
53
- @resource.should run_ipv4
53
+ expect(@resource).to run_ipv4
54
54
  end
55
55
  end
56
56
  end
@@ -62,12 +62,12 @@ try_spec do
62
62
 
63
63
  describe 'when dumped and loaded' do
64
64
  before do
65
- @resource.save.should be(true)
65
+ expect(@resource.save).to be(true)
66
66
  @resource.reload
67
67
  end
68
68
 
69
69
  it 'is an IPv4 node' do
70
- @resource.should run_ipv4
70
+ expect(@resource).to run_ipv4
71
71
  end
72
72
  end
73
73
  end
@@ -79,12 +79,12 @@ try_spec do
79
79
 
80
80
  describe 'when dumped and loaded' do
81
81
  before do
82
- @resource.save.should be(true)
82
+ expect(@resource.save).to be(true)
83
83
  @resource.reload
84
84
  end
85
85
 
86
86
  it 'is an IPv4 node' do
87
- @resource.should run_ipv4
87
+ expect(@resource).to run_ipv4
88
88
  end
89
89
  end
90
90
  end
@@ -96,12 +96,12 @@ try_spec do
96
96
 
97
97
  describe 'when dumped and loaded' do
98
98
  before do
99
- @resource.save.should be(true)
99
+ expect(@resource.save).to be(true)
100
100
  @resource.reload
101
101
  end
102
102
 
103
103
  it 'is an IPv4 node' do
104
- @resource.should run_ipv4
104
+ expect(@resource).to run_ipv4
105
105
  end
106
106
 
107
107
  it 'includes IP address 218.43.243.2 in subnet hosts' do
@@ -117,16 +117,16 @@ try_spec do
117
117
 
118
118
  describe 'when dumped and loaded' do
119
119
  before do
120
- @resource.save.should be(true)
120
+ expect(@resource.save).to be(true)
121
121
  @resource.reload
122
122
  end
123
123
 
124
124
  it 'is an IPv4 node' do
125
- @resource.should run_ipv4
125
+ expect(@resource).to run_ipv4
126
126
  end
127
127
 
128
128
  it 'should be the expected value' do
129
- @resource.ip_address.should == IPAddr.new('0.0.0.0')
129
+ expect(@resource.ip_address).to eq(IPAddr.new('0.0.0.0'))
130
130
  end
131
131
  end
132
132
  end
@@ -138,12 +138,12 @@ try_spec do
138
138
 
139
139
  describe 'when dumped and loaded' do
140
140
  before do
141
- @resource.save.should be(true)
141
+ expect(@resource.save).to be(true)
142
142
  @resource.reload
143
143
  end
144
144
 
145
145
  it 'has no IP address assigned' do
146
- @resource.ip_address.should be_nil
146
+ expect(@resource.ip_address).to be_nil
147
147
  end
148
148
  end
149
149
  end
@@ -16,12 +16,12 @@ try_spec do
16
16
 
17
17
  describe 'when dumped and loaded again' do
18
18
  before do
19
- @resource.save.should be_true
19
+ expect(@resource.save).to be true
20
20
  @resource.reload
21
21
  end
22
22
 
23
23
  it 'has nil positions list' do
24
- @resource.positions.should be_nil
24
+ expect(@resource.positions).to be_nil
25
25
  end
26
26
  end
27
27
  end
@@ -36,15 +36,15 @@ try_spec do
36
36
 
37
37
  describe 'when dumped and loaded again' do
38
38
  before do
39
- @resource.save.should be_true
39
+ expect(@resource.save).to be true
40
40
  @resource.reload
41
41
  end
42
42
 
43
43
  it 'loads positions list to the state when it was dumped/persisted with keys being strings' do
44
- @resource.positions.should == [
44
+ expect(@resource.positions).to eq([
45
45
  { 'company' => 'The Death Star, Inc', 'title' => 'Light sabre engineer' },
46
46
  { 'company' => 'Sane Little Company', 'title' => 'Chief Curiosity Officer' },
47
- ]
47
+ ])
48
48
  end
49
49
  end
50
50
  end
@@ -56,12 +56,12 @@ try_spec do
56
56
 
57
57
  describe 'when dumped and loaded again' do
58
58
  before do
59
- @resource.save.should be_true
59
+ expect(@resource.save).to be true
60
60
  @resource.reload
61
61
  end
62
62
 
63
63
  it 'has empty positions list' do
64
- @resource.positions.should == []
64
+ expect(@resource.positions).to eq([])
65
65
  end
66
66
  end
67
67
  end
@@ -16,11 +16,11 @@ try_spec do
16
16
  end
17
17
 
18
18
  it 'has slug equal to "new-datamapper-type"' do
19
- @resource.slug.should == 'new-ardm-type'
19
+ expect(@resource.slug).to eq('new-ardm-type')
20
20
  end
21
21
 
22
22
  it 'can be found by slug' do
23
- Ardm::Fixtures::Article.where(:slug => 'new-ardm-type').first.should == @resource
23
+ expect(Ardm::Fixtures::Article.where(:slug => 'new-ardm-type').first).to eq(@resource)
24
24
  end
25
25
  end
26
26
 
@@ -41,21 +41,21 @@ try_spec do
41
41
  describe "set with title '#{title}'" do
42
42
  before do
43
43
  @resource = Ardm::Fixtures::Article.new(:title => title)
44
- @resource.valid?.should be(true)
44
+ expect(@resource.valid?).to be(true)
45
45
  end
46
46
 
47
47
  it "has slug equal to '#{slug}'" do
48
- @resource.slug.should == slug
48
+ expect(@resource.slug).to eq(slug)
49
49
  end
50
50
 
51
51
  describe "and persisted" do
52
52
  before do
53
- @resource.save.should be(true)
53
+ expect(@resource.save).to be(true)
54
54
  @resource.reload
55
55
  end
56
56
 
57
57
  it 'can be found by slug' do
58
- Ardm::Fixtures::Article.where(:slug => slug).first.should == @resource
58
+ expect(Ardm::Fixtures::Article.where(:slug => slug).first).to eq(@resource)
59
59
  end
60
60
  end
61
61
  end
@@ -15,11 +15,11 @@ try_spec do
15
15
  :tags => %w[ misc ]
16
16
  )
17
17
 
18
- @resource.save.should be(true)
18
+ expect(@resource.save).to be(true)
19
19
  end
20
20
 
21
21
  it 'can be found by uri' do
22
- Ardm::Fixtures::Bookmark.where(:uri => @uri).first.should == @resource
22
+ expect(Ardm::Fixtures::Bookmark.where(:uri => @uri).first).to eq(@resource)
23
23
  end
24
24
 
25
25
  describe 'when reloaded' do
@@ -28,7 +28,7 @@ try_spec do
28
28
  end
29
29
 
30
30
  it 'has no uri' do
31
- @resource.uri.should be_nil
31
+ expect(@resource.uri).to be_nil
32
32
  end
33
33
  end
34
34
  end
@@ -43,11 +43,11 @@ try_spec do
43
43
  :tags => %w[ misc ]
44
44
  )
45
45
 
46
- @resource.save.should be(true)
46
+ expect(@resource.save).to be(true)
47
47
  end
48
48
 
49
49
  it 'can be found by uri' do
50
- Ardm::Fixtures::Bookmark.where(:uri => @uri).first.should == @resource
50
+ expect(Ardm::Fixtures::Bookmark.where(:uri => @uri).first).to eq(@resource)
51
51
  end
52
52
 
53
53
  describe 'when reloaded' do
@@ -56,11 +56,11 @@ try_spec do
56
56
  end
57
57
 
58
58
  it 'is loaded as URI object' do
59
- @resource.uri.should be_an_instance_of(Addressable::URI)
59
+ expect(@resource.uri).to be_an_instance_of(Addressable::URI)
60
60
  end
61
61
 
62
62
  it 'has the same original URI' do
63
- @resource.uri.to_s.should == @uri
63
+ expect(@resource.uri.to_s).to eq(@uri)
64
64
  end
65
65
  end
66
66
  end
@@ -77,7 +77,7 @@ try_spec do
77
77
  end
78
78
 
79
79
  it 'is perfectly valid (URI type does not provide auto validations)' do
80
- @resource.save.should be(true)
80
+ expect(@resource.save).to be(true)
81
81
  end
82
82
  end
83
83
 
@@ -114,11 +114,11 @@ try_spec do
114
114
  :tags => %w[ misc ]
115
115
  )
116
116
 
117
- @resource.save.should be(true)
117
+ expect(@resource.save).to be(true)
118
118
  end
119
119
 
120
120
  it 'can be found by uri' do
121
- Ardm::Fixtures::Bookmark.where(:uri => uri).first.should_not be_nil
121
+ expect(Ardm::Fixtures::Bookmark.where(:uri => uri).first).not_to be_nil
122
122
  end
123
123
 
124
124
  describe 'when reloaded' do
@@ -127,7 +127,7 @@ try_spec do
127
127
  end
128
128
 
129
129
  it 'has the same original URI' do
130
- @resource.uri.to_s.should eql(uri)
130
+ expect(@resource.uri.to_s).to eql(uri)
131
131
  end
132
132
  end
133
133
  end
@@ -11,7 +11,7 @@ try_spec do
11
11
  @uuid = UUIDTools::UUID.parse(@uuid_string)
12
12
  @resource = Ardm::Fixtures::NetworkNode.new(:uuid => @uuid)
13
13
 
14
- @resource.save.should be(true)
14
+ expect(@resource.save).to be(true)
15
15
  end
16
16
 
17
17
  describe 'when reloaded' do
@@ -19,12 +19,12 @@ try_spec do
19
19
  @resource.reload
20
20
  end
21
21
 
22
- it 'has the same UUID string' do
23
- @resource.uuid.to_s.should == @uuid_string
22
+ it 'has the same UUID string', pending: true do
23
+ expect(@resource.uuid.to_s).to eq(@uuid_string)
24
24
  end
25
25
 
26
- it 'returns UUID as an object' do
27
- @resource.uuid.should be_an_instance_of(UUIDTools::UUID)
26
+ it 'returns UUID as an object', pending: true do
27
+ expect(@resource.uuid).to be_an_instance_of(UUIDTools::UUID)
28
28
  end
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ try_spec do
33
33
  before :each do
34
34
  @uuid = 'b0fc632e-d744-4821-afe3-4ea0701859ee'
35
35
  @resource = Ardm::Fixtures::NetworkNode.new(:uuid => @uuid)
36
- @resource.save.should be(true)
36
+ expect(@resource.save).to be(true)
37
37
  end
38
38
 
39
39
  describe 'when reloaded' do
@@ -41,12 +41,12 @@ try_spec do
41
41
  @resource.reload
42
42
  end
43
43
 
44
- it 'has the same UUID string' do
45
- @resource.uuid.to_s.should == @uuid
44
+ it 'has the same UUID string', pending: true do
45
+ expect(@resource.uuid.to_s).to eq(@uuid)
46
46
  end
47
47
 
48
- it 'returns UUID as an object' do
49
- @resource.uuid.should be_an_instance_of(UUIDTools::UUID)
48
+ it 'returns UUID as an object', pending: true do
49
+ expect(@resource.uuid).to be_an_instance_of(UUIDTools::UUID)
50
50
  end
51
51
  end
52
52
  end
@@ -60,8 +60,8 @@ try_spec do
60
60
  end
61
61
 
62
62
  describe 'when assigned UUID' do
63
- it 'raises ArgumentError' do
64
- @operation.should raise_error(ArgumentError, /Invalid UUID format/)
63
+ it 'raises ArgumentError', pending: true do
64
+ expect(@operation).to raise_error(ArgumentError, /Invalid UUID format/)
65
65
  end
66
66
  end
67
67
  end
@@ -75,8 +75,8 @@ try_spec do
75
75
  end
76
76
 
77
77
  describe 'when assigned UUID' do
78
- it 'raises ArgumentError' do
79
- @operation.should raise_error(ArgumentError, /Invalid UUID format/)
78
+ it 'raises ArgumentError', pending: true do
79
+ expect(@operation).to raise_error(ArgumentError, /Invalid UUID format/)
80
80
  end
81
81
  end
82
82
  end
@@ -85,7 +85,7 @@ try_spec do
85
85
  before :each do
86
86
  @uuid = nil
87
87
  @resource = Ardm::Fixtures::NetworkNode.new(:uuid => @uuid)
88
- @resource.save.should be(true)
88
+ expect(@resource.save).to be(true)
89
89
  end
90
90
 
91
91
  describe 'when reloaded' do
@@ -94,7 +94,7 @@ try_spec do
94
94
  end
95
95
 
96
96
  it 'has no UUID' do
97
- @resource.uuid.should be_nil
97
+ expect(@resource.uuid).to be_nil
98
98
  end
99
99
  end
100
100
  end
@@ -17,12 +17,12 @@ try_spec do
17
17
 
18
18
  describe 'when dumped and loaded again' do
19
19
  before do
20
- @resource.save.should be(true)
20
+ expect(@resource.save).to be(true)
21
21
  @resource.reload
22
22
  end
23
23
 
24
24
  it 'has nil inventions list' do
25
- @resource.inventions.should be_nil
25
+ expect(@resource.inventions).to be_nil
26
26
  end
27
27
  end
28
28
  end
@@ -37,12 +37,12 @@ try_spec do
37
37
 
38
38
  describe 'when dumped and loaded again' do
39
39
  before do
40
- @resource.save.should be(true)
40
+ expect(@resource.save).to be(true)
41
41
  @resource.reload
42
42
  end
43
43
 
44
44
  it 'loads inventions list to the state when it was dumped/persisted with keys being strings' do
45
- @resource.inventions.should == @input
45
+ expect(@resource.inventions).to eq(@input)
46
46
  end
47
47
  end
48
48
  end
@@ -54,12 +54,12 @@ try_spec do
54
54
 
55
55
  describe 'when dumped and loaded again' do
56
56
  before do
57
- @resource.save.should be(true)
57
+ expect(@resource.save).to be(true)
58
58
  @resource.reload
59
59
  end
60
60
 
61
61
  it 'has empty inventions list' do
62
- @resource.inventions.should == []
62
+ expect(@resource.inventions).to eq([])
63
63
  end
64
64
  end
65
65
  end
@@ -72,12 +72,12 @@ try_spec do
72
72
 
73
73
  describe 'when dumped and loaded again' do
74
74
  before do
75
- @resource.save.should be(true)
75
+ expect(@resource.save).to be(true)
76
76
  @resource.reload
77
77
  end
78
78
 
79
79
  it 'has correct inventions' do
80
- @resource.inventions.should == 'Foo and Bar'
80
+ expect(@resource.inventions).to eq('Foo and Bar')
81
81
  end
82
82
  end
83
83
  end