mongo_doc 0.6.26 → 0.6.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. data/README.textile +14 -203
  2. data/Rakefile +0 -134
  3. data/lib/mongo_doc/collection.rb +4 -0
  4. data/lib/mongo_doc/finders.rb +1 -0
  5. data/lib/mongo_doc/timestamps.rb +4 -3
  6. data/lib/mongo_doc/version.rb +3 -0
  7. data/lib/mongo_doc.rb +0 -5
  8. metadata +25 -212
  9. data/.document +0 -5
  10. data/.gitignore +0 -8
  11. data/.rspec +0 -2
  12. data/.rvmrc +0 -1
  13. data/.watchr +0 -32
  14. data/Gemfile +0 -3
  15. data/Gemfile.lock +0 -72
  16. data/HISTORY.md +0 -11
  17. data/VERSION +0 -1
  18. data/examples/simple_document.rb +0 -46
  19. data/examples/simple_object.rb +0 -34
  20. data/features/collections.feature +0 -9
  21. data/features/connection.feature +0 -13
  22. data/features/db_references.feature +0 -21
  23. data/features/embed_hash.feature +0 -16
  24. data/features/finders.feature +0 -76
  25. data/features/indexes.feature +0 -28
  26. data/features/mongodb.yml +0 -7
  27. data/features/mongodoc_base.feature +0 -128
  28. data/features/new_record.feature +0 -36
  29. data/features/partial_updates.feature +0 -95
  30. data/features/polymorphic_collections.feature +0 -16
  31. data/features/references.feature +0 -28
  32. data/features/removing_documents.feature +0 -68
  33. data/features/saving_an_object.feature +0 -15
  34. data/features/scopes.feature +0 -66
  35. data/features/step_definitions/collection_steps.rb +0 -17
  36. data/features/step_definitions/connection_steps.rb +0 -13
  37. data/features/step_definitions/document_steps.rb +0 -155
  38. data/features/step_definitions/documents.rb +0 -61
  39. data/features/step_definitions/embed_hash_steps.rb +0 -6
  40. data/features/step_definitions/field_steps.rb +0 -28
  41. data/features/step_definitions/finder_steps.rb +0 -15
  42. data/features/step_definitions/index_steps.rb +0 -10
  43. data/features/step_definitions/json_steps.rb +0 -9
  44. data/features/step_definitions/object_steps.rb +0 -50
  45. data/features/step_definitions/objects.rb +0 -24
  46. data/features/step_definitions/partial_update_steps.rb +0 -31
  47. data/features/step_definitions/query_steps.rb +0 -69
  48. data/features/step_definitions/removing_documents_steps.rb +0 -14
  49. data/features/step_definitions/scope_steps.rb +0 -18
  50. data/features/step_definitions/string_casting_steps.rb +0 -29
  51. data/features/step_definitions/util_steps.rb +0 -7
  52. data/features/string_casting.feature +0 -10
  53. data/features/support/support.rb +0 -12
  54. data/features/timestamps.feature +0 -14
  55. data/features/using_criteria.feature +0 -148
  56. data/mongo_doc.gemspec +0 -272
  57. data/mongodb.example.yml +0 -14
  58. data/perf/mongo_doc_object.rb +0 -83
  59. data/perf/mongo_document.rb +0 -84
  60. data/perf/ruby_driver.rb +0 -49
  61. data/script/console +0 -8
  62. data/spec/active_model_behavior.rb +0 -64
  63. data/spec/array_including_argument_matcher.rb +0 -62
  64. data/spec/associations/collection_proxy_spec.rb +0 -233
  65. data/spec/associations/document_proxy_spec.rb +0 -45
  66. data/spec/associations/hash_proxy_spec.rb +0 -181
  67. data/spec/associations/proxy_base_spec.rb +0 -92
  68. data/spec/associations_spec.rb +0 -218
  69. data/spec/attributes_accessor_spec.rb +0 -39
  70. data/spec/attributes_spec.rb +0 -184
  71. data/spec/bson_matchers.rb +0 -54
  72. data/spec/bson_spec.rb +0 -196
  73. data/spec/collection_spec.rb +0 -169
  74. data/spec/connection_spec.rb +0 -169
  75. data/spec/contexts/ids_spec.rb +0 -49
  76. data/spec/contexts/mongo_spec.rb +0 -241
  77. data/spec/contexts_spec.rb +0 -56
  78. data/spec/criteria/optional_spec.rb +0 -26
  79. data/spec/criteria_spec.rb +0 -73
  80. data/spec/cursor_spec.rb +0 -91
  81. data/spec/database_cleaner_spec.rb +0 -24
  82. data/spec/document_ext.rb +0 -9
  83. data/spec/document_spec.rb +0 -569
  84. data/spec/embedded_save_spec.rb +0 -73
  85. data/spec/ext_spec.rb +0 -100
  86. data/spec/finders_spec.rb +0 -61
  87. data/spec/hash_matchers.rb +0 -29
  88. data/spec/index_spec.rb +0 -79
  89. data/spec/matchers_spec.rb +0 -342
  90. data/spec/mongodb.yml +0 -6
  91. data/spec/mongodb_pairs.yml +0 -8
  92. data/spec/new_record_spec.rb +0 -128
  93. data/spec/polymorphic_collection_spec.rb +0 -47
  94. data/spec/references_many_spec.rb +0 -214
  95. data/spec/references_spec.rb +0 -121
  96. data/spec/root_spec.rb +0 -41
  97. data/spec/scope_spec.rb +0 -88
  98. data/spec/spec_helper.rb +0 -16
  99. data/spec/timestamps_spec.rb +0 -154
  100. data/spec/update_spec.rb +0 -167
  101. data/spec/validations_spec.rb +0 -30
data/spec/ext_spec.rb DELETED
@@ -1,100 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Ruby Object Extensions" do
4
- context "Rails3 support" do
5
- describe "#singleton_class" do
6
- it "is either defined or aliased" do
7
- Object.new.should respond_to(:singleton_class)
8
- end
9
- end
10
- end
11
-
12
- context "Conversions" do
13
- context "Boolean" do
14
- it "converts from a '1' to true" do
15
- Boolean.cast_from_string('1').should be_true
16
- end
17
-
18
- it "converts from a 'tRuE' to true" do
19
- Boolean.cast_from_string('tRuE').should be_true
20
- end
21
-
22
- it "converts anything else to false" do
23
- Boolean.cast_from_string('0').should be_false
24
- end
25
- end
26
-
27
- context "Date" do
28
- it "returns nil for a blank string" do
29
- Date.cast_from_string('').should be_nil
30
- end
31
-
32
- it "converts from a string to a Date" do
33
- date = Date.today
34
- Date.cast_from_string(date.to_s).should == date
35
- end
36
- end
37
-
38
- context "DateTime" do
39
- it "returns nil for a blank string" do
40
- DateTime.cast_from_string('').should be_nil
41
- end
42
-
43
- it "converts from a string to a DateTime" do
44
- datetime = DateTime.now
45
- DateTime.cast_from_string(datetime.to_s).should === datetime
46
- end
47
- end
48
-
49
- context "Numbers" do
50
- context "Float" do
51
- it "returns nil for a blank string" do
52
- Float.cast_from_string('').should be_nil
53
- end
54
-
55
- it "converts from a string to a BigDecimal" do
56
- float = "12345.6789".to_f
57
- Float.cast_from_string(float.to_s).should == float
58
- end
59
- end
60
-
61
- context "Integer" do
62
- it "returns nil for a blank string" do
63
- Integer.cast_from_string('').should be_nil
64
- end
65
-
66
- it "converts from a string to a Bignum" do
67
- big_number = 1000000000000
68
- Integer.cast_from_string(big_number.to_s).should == big_number
69
- end
70
-
71
- it "converts from a string to a Fixnum" do
72
- fixnum = 1
73
- Integer.cast_from_string(fixnum.to_s).should == fixnum
74
- end
75
- end
76
- end
77
-
78
- context "ObjectID" do
79
- it "returns nil for a blank string" do
80
- BSON::ObjectID.cast_from_string('').should be_nil
81
- end
82
-
83
- it "converts from a string to an ObjectID" do
84
- obj = BSON::ObjectID.new
85
- BSON::ObjectID.cast_from_string(obj.to_s).should == obj
86
- end
87
- end
88
-
89
- context "Time" do
90
- it "returns nil for a blank string" do
91
- Time.cast_from_string('').should be_nil
92
- end
93
-
94
- it "converts from a string to a Time" do
95
- time = Time.now
96
- Time.cast_from_string(time.to_s).to_s.should == time.to_s
97
- end
98
- end
99
- end
100
- end
data/spec/finders_spec.rb DELETED
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MongoDoc::Finders do
4
- class FindersTest
5
- include MongoDoc::Document
6
-
7
- attr_accessor :data
8
- end
9
-
10
- let(:criteria) { stub('criteria').as_null_object }
11
-
12
- context ".find" do
13
- before do
14
- FindersTest.stub(:criteria).and_return(criteria)
15
- end
16
-
17
- it "delegates to id for the criteria" do
18
- args = [1, 2, 3]
19
- criteria.should_receive(:id).with(*args)
20
- FindersTest.find(*args)
21
- end
22
- end
23
-
24
- context ".find_all" do
25
- it "delegates to an empty criteria" do
26
- FindersTest.should_receive(:criteria)
27
- FindersTest.find_all
28
- end
29
-
30
- it "returns the empty criteria" do
31
- FindersTest.stub(:criteria).and_return(criteria)
32
- FindersTest.find_all.should == criteria
33
- end
34
- end
35
-
36
- context ".find_one" do
37
- context "with an id" do
38
- it "delegates to translate" do
39
- id = 'an id'
40
- Mongoid::Criteria.should_receive(:translate).with(FindersTest, id)
41
- FindersTest.find_one(id)
42
- end
43
- end
44
-
45
- context "with conditions" do
46
- let(:conditions) { {:where => 'this.a > 3'} }
47
-
48
- it "calls translate with the conditions" do
49
- Mongoid::Criteria.should_receive(:translate).with(FindersTest, conditions).and_return(criteria)
50
- FindersTest.find_one(conditions)
51
- end
52
-
53
- it "call one on the result" do
54
- Mongoid::Criteria.stub(:translate).and_return(criteria)
55
- criteria.should_receive(:one)
56
- FindersTest.find_one(conditions)
57
- end
58
- end
59
- end
60
-
61
- end
@@ -1,29 +0,0 @@
1
- class HasEntry
2
- def initialize(expected)
3
- @expected = expected
4
- end
5
-
6
- def matches?(target)
7
- @target = target
8
- @expected.all? do |key, value|
9
- @target[key] == value
10
- end
11
- end
12
-
13
- def failure_message_for_should
14
- "expected #{@target.inspect} to have entries #{@expected.inspect}"
15
- end
16
-
17
- def failure_message_for_should_not
18
- "expected #{@target.inspect} not to have entries #{@expected.inspect}"
19
- end
20
- end
21
-
22
- module HashMatchers
23
- def has_entry(expected)
24
- HasEntry.new(expected)
25
- end
26
- alias :has_entries :has_entry
27
- alias :have_entries :has_entry
28
- alias :have_entry :has_entry
29
- end
data/spec/index_spec.rb DELETED
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MongoDoc::Index do
4
- class Address
5
- include MongoDoc::Document
6
-
7
- attr_accessor :state
8
- end
9
-
10
- class IndexTest
11
- include MongoDoc::Document
12
-
13
- attr_accessor :ssn
14
- attr_accessor :first_name
15
- attr_accessor :last_name
16
- attr_accessor :birthdate, :type => Date
17
- attr_accessor :notes
18
- attr_accessor :location, :type => Array
19
-
20
- embed :addresses
21
-
22
- # This is the API we are testing, commented out to avoid firing before
23
- # specs are run
24
- #
25
- # index :birthdate
26
- # index :ssn, :unique => true
27
- # index :first_name => :asc, :last_name => :asc
28
- # index :last_name => :asc, :first_name => :asc, :unique => true
29
- # index "addresses.state"
30
- # index :location => :geo2d
31
- end
32
-
33
- let(:collection) { stub('collection') }
34
-
35
- before do
36
- IndexTest.stub(:collection).and_return(collection)
37
- end
38
-
39
- context "Simple index" do
40
-
41
- it "creates an index for the field" do
42
- collection.should_receive(:create_index).with(:birthdate, {})
43
- IndexTest.index(:birthdate)
44
- end
45
-
46
- it "creates a unique index for the field" do
47
- collection.should_receive(:create_index).with(:birthdate, {:unique => true})
48
- IndexTest.index(:birthdate, :unique => true)
49
- end
50
-
51
- end
52
-
53
- context "Compound index" do
54
-
55
- it "creates a compound index" do
56
- collection.should_receive(:create_index).with(array_including([:first_name, Mongo::ASCENDING], [:last_name, Mongo::ASCENDING]), {})
57
- IndexTest.index(:first_name => :asc, :last_name => :asc)
58
- end
59
-
60
- it "creates a unique compound index" do
61
- collection.should_receive(:create_index).with(array_including([:first_name, Mongo::ASCENDING], [:last_name, Mongo::ASCENDING]), {:unique => true})
62
- IndexTest.index(:first_name => :asc, :last_name => :asc, :unique => true)
63
- end
64
- end
65
-
66
- context "Nested index" do
67
- it "creates an index for the field" do
68
- collection.should_receive(:create_index).with("addresses.state", {})
69
- IndexTest.index("addresses.state")
70
- end
71
- end
72
-
73
- context "Geo index" do
74
- it "creates a geo index for the field" do
75
- collection.should_receive(:create_index).with([[:location, Mongo::GEO2D]], {})
76
- IndexTest.index(:location => :geo2d)
77
- end
78
- end
79
- end
@@ -1,342 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MongoDoc::Matchers do
4
-
5
- class Address
6
- include MongoDoc::Matchers
7
-
8
- attr_accessor :number
9
- attr_accessor :services
10
- attr_accessor :street
11
-
12
- def initialize(attrs = {})
13
- attrs.each {|key, value| send("#{key}=", value)}
14
- end
15
- end
16
-
17
- describe "#matches?" do
18
-
19
- context "when performing simple matching" do
20
-
21
- before do
22
- @document = Address.new(:street => "Clarkenwell Road")
23
- end
24
-
25
- context "when the attributes match" do
26
-
27
- before do
28
- @selector = { :street => "Clarkenwell Road" }
29
- end
30
-
31
- it "returns true" do
32
- @document.matches?(@selector).should be_true
33
- end
34
-
35
- end
36
-
37
- context "when the attributes dont match" do
38
-
39
- before do
40
- @selector = { :street => "Broadway Ave" }
41
- end
42
-
43
- it "returns false" do
44
- @document.matches?(@selector).should be_false
45
- end
46
-
47
- end
48
-
49
- end
50
-
51
- context "when performing complex matching" do
52
-
53
- before do
54
- @document = Address.new(:services => ["first", "second"], :number => 100)
55
- end
56
-
57
- context "with an $all selector" do
58
-
59
- context "when the attributes match" do
60
-
61
- before do
62
- @selector = { :services => { "$all" => [ "first", "second" ] } }
63
- end
64
-
65
- it "returns true" do
66
- @document.matches?(@selector).should be_true
67
- end
68
-
69
- end
70
-
71
- context "when the attributes do not match" do
72
-
73
- before do
74
- @selector = { :services => { "$all" => [ "first" ] } }
75
- end
76
-
77
- it "returns false" do
78
- @document.matches?(@selector).should be_false
79
- end
80
-
81
- end
82
-
83
- end
84
-
85
- context "with an $exists selector" do
86
-
87
- context "when the attributes match" do
88
-
89
- before do
90
- @selector = { :services => { "$exists" => true } }
91
- end
92
-
93
- it "returns true" do
94
- @document.matches?(@selector).should be_true
95
- end
96
-
97
- end
98
-
99
- context "when the attributes do not match" do
100
-
101
- before do
102
- @selector = { :services => { "$exists" => false } }
103
- end
104
-
105
- it "returns false" do
106
- @document.matches?(@selector).should be_false
107
- end
108
-
109
- end
110
-
111
- end
112
-
113
- context "with a $gt selector" do
114
-
115
- context "when the attributes match" do
116
-
117
- before do
118
- @selector = { :number => { "$gt" => 50 } }
119
- end
120
-
121
- it "returns true" do
122
- @document.matches?(@selector).should be_true
123
- end
124
-
125
- end
126
-
127
- context "when the attributes do not match" do
128
-
129
- before do
130
- @selector = { :number => { "$gt" => 200 } }
131
- end
132
-
133
- it "returns false" do
134
- @document.matches?(@selector).should be_false
135
- end
136
-
137
- end
138
-
139
- end
140
-
141
- context "with a $gte selector" do
142
-
143
- context "when the attributes match" do
144
-
145
- before do
146
- @selector = { :number => { "$gte" => 100 } }
147
- end
148
-
149
- it "returns true" do
150
- @document.matches?(@selector).should be_true
151
- end
152
-
153
- end
154
-
155
- context "when the attributes do not match" do
156
-
157
- before do
158
- @selector = { :number => { "$gte" => 200 } }
159
- end
160
-
161
- it "returns false" do
162
- @document.matches?(@selector).should be_false
163
- end
164
-
165
- end
166
-
167
- end
168
-
169
- context "with an $in selector" do
170
-
171
- context "when the attributes match" do
172
-
173
- before do
174
- @selector = { :number => { "$in" => [ 100, 200 ] } }
175
- end
176
-
177
- it "returns true" do
178
- @document.matches?(@selector).should be_true
179
- end
180
-
181
- end
182
-
183
- context "when the attributes do not match" do
184
-
185
- before do
186
- @selector = { :number => { "$in" => [ 200, 300 ] } }
187
- end
188
-
189
- it "returns false" do
190
- @document.matches?(@selector).should be_false
191
- end
192
-
193
- end
194
-
195
- end
196
-
197
- context "with a $lt selector" do
198
-
199
- context "when the attributes match" do
200
-
201
- before do
202
- @selector = { :number => { "$lt" => 200 } }
203
- end
204
-
205
- it "returns true" do
206
- @document.matches?(@selector).should be_true
207
- end
208
-
209
- end
210
-
211
- context "when the attributes do not match" do
212
-
213
- before do
214
- @selector = { :number => { "$lt" => 50 } }
215
- end
216
-
217
- it "returns false" do
218
- @document.matches?(@selector).should be_false
219
- end
220
-
221
- end
222
-
223
- end
224
-
225
- context "with a $lte selector" do
226
-
227
- context "when the attributes match" do
228
-
229
- before do
230
- @selector = { :number => { "$lte" => 200 } }
231
- end
232
-
233
- it "returns true" do
234
- @document.matches?(@selector).should be_true
235
- end
236
-
237
- end
238
-
239
- context "when the attributes do not match" do
240
-
241
- before do
242
- @selector = { :number => { "$lte" => 50 } }
243
- end
244
-
245
- it "returns false" do
246
- @document.matches?(@selector).should be_false
247
- end
248
-
249
- end
250
-
251
- end
252
-
253
- context "with an $ne selector" do
254
-
255
- context "when the attributes match" do
256
-
257
- before do
258
- @selector = { :number => { "$ne" => 200 } }
259
- end
260
-
261
- it "returns true" do
262
- @document.matches?(@selector).should be_true
263
- end
264
-
265
- end
266
-
267
- context "when the attributes do not match" do
268
-
269
- before do
270
- @selector = { :number => { "$ne" => 100 } }
271
- end
272
-
273
- it "returns false" do
274
- @document.matches?(@selector).should be_false
275
- end
276
-
277
- end
278
-
279
- end
280
-
281
- context "with a $nin selector" do
282
-
283
- context "when the attributes match" do
284
-
285
- before do
286
- @selector = { :number => { "$nin" => [ 1, 2, 3 ] } }
287
- end
288
-
289
- it "returns true" do
290
- @document.matches?(@selector).should be_true
291
- end
292
-
293
- end
294
-
295
- context "when the attributes do not match" do
296
-
297
- before do
298
- @selector = { :number => { "$nin" => [ 100 ] } }
299
- end
300
-
301
- it "returns false" do
302
- @document.matches?(@selector).should be_false
303
- end
304
-
305
- end
306
-
307
- end
308
-
309
- context "with a $size selector" do
310
-
311
- context "when the attributes match" do
312
-
313
- before do
314
- @selector = { :services => { "$size" => 2 } }
315
- end
316
-
317
- it "returns true" do
318
- @document.matches?(@selector).should be_true
319
- end
320
-
321
- end
322
-
323
- context "when the attributes do not match" do
324
-
325
- before do
326
- @selector = { :services => { "$size" => 5 } }
327
- end
328
-
329
- it "returns false" do
330
- @document.matches?(@selector).should be_false
331
- end
332
-
333
- end
334
-
335
- end
336
-
337
- end
338
-
339
- end
340
-
341
- end
342
-
data/spec/mongodb.yml DELETED
@@ -1,6 +0,0 @@
1
- name: database_name
2
- host: localhost
3
- port: 27017
4
- options:
5
- auto_reconnect: true
6
-
@@ -1,8 +0,0 @@
1
- name: database_name
2
- host_pairs:
3
- first:
4
- ['localhost', 27017]
5
- port: 27017
6
- options:
7
- auto_reconnect: true
8
-