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
@@ -1,73 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MongoDoc::Criteria do
4
-
5
- class CriteriaTest
6
- extend MongoDoc::Criteria
7
-
8
- def self.collection; end
9
- end
10
-
11
- context ".criteria" do
12
- it "creates a new CriteriaWrapper for the document" do
13
- CriteriaTest.criteria.should be_a_kind_of(MongoDoc::Criteria::CriteriaWrapper)
14
- end
15
- end
16
-
17
- context "CriteriaWrapper" do
18
- let(:wrapper) { MongoDoc::Criteria::CriteriaWrapper.new(CriteriaTest) }
19
-
20
- it "is a Criteria" do
21
- Mongoid::Criteria.should === wrapper
22
- end
23
-
24
- it "sets the criteria klass" do
25
- wrapper.klass.should == CriteriaTest
26
- end
27
-
28
- %w(all and any_in cache enslave excludes fuse id in limit offset only order_by skip where).each do |wrapping_method|
29
- it "#{wrapping_method} returns a new CriteriaWrapper" do
30
- wrapper.send(wrapping_method).object_id.should_not == wrapper.object_id
31
- end
32
- end
33
-
34
- it "extras returns a new CriteriaWrapper" do
35
- wrapper.extras({}).object_id.should_not == wrapper.object_id
36
- end
37
-
38
- it "not_in returns a new CriteriaWrapper" do
39
- wrapper.not_in({}).object_id.should_not == wrapper.object_id
40
- end
41
-
42
- it "id with mutliple ids returns a new CriteriaWrapper with the id selector set" do
43
- id1 = BSON::ObjectID.new
44
- id2 = BSON::ObjectID.new
45
- returned = wrapper.id(id1, id2)
46
- returned.object_id.should_not == wrapper.object_id
47
- returned.selector[:_id].should == {'$in' => [id1, id2]}
48
- end
49
- end
50
-
51
- context "criteria delegates" do
52
- let(:criteria) { stub('criteria').as_null_object }
53
-
54
- before do
55
- CriteriaTest.stub(:criteria).and_return(criteria)
56
- end
57
-
58
- %w(aggregate all and any_in blank? count empty? excludes extras first group id in last limit max min not_in offset one only order_by page paginate per_page skip sum where).each do |criteria_op|
59
- it "#{criteria_op} delegates to the criteria" do
60
- criteria.should_receive(criteria_op)
61
- CriteriaTest.send(criteria_op)
62
- end
63
- end
64
- end
65
-
66
- context "criteria are reusable" do
67
- it "creates a new instance on each invocation" do
68
- original = CriteriaTest.any_in(:name => 'Les Hill')
69
- chained = original.only(:name)
70
- original.should_not == chained
71
- end
72
- end
73
- end
data/spec/cursor_spec.rb DELETED
@@ -1,91 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "MongoDoc::Cursor" do
4
- let(:mongo_cursor) { stub('cursor') }
5
-
6
- let(:collection) { stub('collection') }
7
-
8
- let(:cursor) { MongoDoc::Cursor.new(collection, mongo_cursor) }
9
-
10
- it "is Enumerable" do
11
- Enumerable.should === cursor
12
- end
13
-
14
- it ".new wraps a Mongo::Cursor" do
15
- cursor._cursor.should == mongo_cursor
16
- end
17
-
18
- it "#collection returns the MongoDoc::Collection for this cursor" do
19
- cursor.collection.should == collection
20
- cursor._collection.should == collection
21
- end
22
-
23
- context "with the underlying cursor" do
24
- %w(admin close closed? count explain fields full_collection_name hint limit order query_options_hash query_opts selector skip snapshot sort timeout).each do |delegated_method|
25
- it "delegates #{delegated_method} to the Mongo::Cursor" do
26
- mongo_cursor.should_receive(delegated_method)
27
- cursor.send(delegated_method)
28
- end
29
- end
30
- end
31
-
32
- context "#each" do
33
- it "delegates to the cursor" do
34
- mongo_cursor.should_receive(:each)
35
- cursor.each
36
- end
37
-
38
- it "decodes the return from the delegate" do
39
- bson = stub('bson')
40
- cursor.stub(:_cursor).and_return([bson])
41
- MongoDoc::BSON.should_receive(:decode).with(bson)
42
- cursor.each {}
43
- end
44
-
45
- it "calls the block with the decoded return" do
46
- result = stub('bson')
47
- cursor.stub(:_cursor).and_return([result])
48
- MongoDoc::BSON.stub(:decode).and_return(result)
49
- cursor.each {|obj| @obj = obj}
50
- @obj.should == result
51
- end
52
- end
53
-
54
- context "#next_document" do
55
- it "delegates to the cursor" do
56
- mongo_cursor.should_receive(:next_document)
57
- cursor.next_document
58
- end
59
-
60
- it "decodes the return from the delegate" do
61
- bson = stub('bson')
62
- mongo_cursor.stub(:next_document).and_return(bson)
63
- MongoDoc::BSON.should_receive(:decode).with(bson)
64
- cursor.next_document
65
- end
66
-
67
- it "returns nil if the delegate returns nil" do
68
- mongo_cursor.stub(:next_document)
69
- cursor.next_document.should be_nil
70
- end
71
- end
72
-
73
- context "#to_a" do
74
- it "delegates to the cursor" do
75
- mongo_cursor.should_receive(:to_a)
76
- cursor.to_a
77
- end
78
-
79
- it "decodes the return from the delegate" do
80
- array = stub('array')
81
- mongo_cursor.stub(:to_a).and_return(array)
82
- MongoDoc::BSON.should_receive(:decode).with(array)
83
- cursor.to_a
84
- end
85
-
86
- it "returns [] if the delegate returns []" do
87
- mongo_cursor.stub(:to_a).and_return([])
88
- cursor.to_a.should == []
89
- end
90
- end
91
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
- require 'mongo_doc/database_cleaner'
3
-
4
- describe "MongoDoc::DatabaseCleaner" do
5
-
6
- describe "#clean_database" do
7
-
8
- let(:collections) { [people_collection, system_collection, remove_system_collection] }
9
- let(:database) { stub(:collections => collections) }
10
- let(:people_collection) { stub(:name => 'people_collection') }
11
- let(:system_collection) { stub(:name => 'system_collection') }
12
- let(:remove_system_collection) { stub(:name => 'remove_this_non_system_collection') }
13
-
14
- before do
15
- MongoDoc::Connection.stub(:database).and_return(database)
16
- end
17
-
18
- it "removes all the non-system collections" do
19
- MongoDoc::Connection.database.should_receive(:drop_collection).with(people_collection.name)
20
- MongoDoc::Connection.database.should_receive(:drop_collection).with(remove_system_collection.name)
21
- MongoDoc::DatabaseCleaner.clean_database
22
- end
23
- end
24
- end
data/spec/document_ext.rb DELETED
@@ -1,9 +0,0 @@
1
- module MongoDoc
2
- module Document
3
- def errors_on(attribute)
4
- self.valid?
5
- [self.errors[attribute]].flatten.compact
6
- end
7
- alias :error_on :errors_on
8
- end
9
- end