mongo_doc 0.6.26 → 0.6.27
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +14 -203
- data/Rakefile +0 -134
- data/lib/mongo_doc/collection.rb +4 -0
- data/lib/mongo_doc/finders.rb +1 -0
- data/lib/mongo_doc/timestamps.rb +4 -3
- data/lib/mongo_doc/version.rb +3 -0
- data/lib/mongo_doc.rb +0 -5
- metadata +25 -212
- data/.document +0 -5
- data/.gitignore +0 -8
- data/.rspec +0 -2
- data/.rvmrc +0 -1
- data/.watchr +0 -32
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -72
- data/HISTORY.md +0 -11
- data/VERSION +0 -1
- data/examples/simple_document.rb +0 -46
- data/examples/simple_object.rb +0 -34
- data/features/collections.feature +0 -9
- data/features/connection.feature +0 -13
- data/features/db_references.feature +0 -21
- data/features/embed_hash.feature +0 -16
- data/features/finders.feature +0 -76
- data/features/indexes.feature +0 -28
- data/features/mongodb.yml +0 -7
- data/features/mongodoc_base.feature +0 -128
- data/features/new_record.feature +0 -36
- data/features/partial_updates.feature +0 -95
- data/features/polymorphic_collections.feature +0 -16
- data/features/references.feature +0 -28
- data/features/removing_documents.feature +0 -68
- data/features/saving_an_object.feature +0 -15
- data/features/scopes.feature +0 -66
- data/features/step_definitions/collection_steps.rb +0 -17
- data/features/step_definitions/connection_steps.rb +0 -13
- data/features/step_definitions/document_steps.rb +0 -155
- data/features/step_definitions/documents.rb +0 -61
- data/features/step_definitions/embed_hash_steps.rb +0 -6
- data/features/step_definitions/field_steps.rb +0 -28
- data/features/step_definitions/finder_steps.rb +0 -15
- data/features/step_definitions/index_steps.rb +0 -10
- data/features/step_definitions/json_steps.rb +0 -9
- data/features/step_definitions/object_steps.rb +0 -50
- data/features/step_definitions/objects.rb +0 -24
- data/features/step_definitions/partial_update_steps.rb +0 -31
- data/features/step_definitions/query_steps.rb +0 -69
- data/features/step_definitions/removing_documents_steps.rb +0 -14
- data/features/step_definitions/scope_steps.rb +0 -18
- data/features/step_definitions/string_casting_steps.rb +0 -29
- data/features/step_definitions/util_steps.rb +0 -7
- data/features/string_casting.feature +0 -10
- data/features/support/support.rb +0 -12
- data/features/timestamps.feature +0 -14
- data/features/using_criteria.feature +0 -148
- data/mongo_doc.gemspec +0 -272
- data/mongodb.example.yml +0 -14
- data/perf/mongo_doc_object.rb +0 -83
- data/perf/mongo_document.rb +0 -84
- data/perf/ruby_driver.rb +0 -49
- data/script/console +0 -8
- data/spec/active_model_behavior.rb +0 -64
- data/spec/array_including_argument_matcher.rb +0 -62
- data/spec/associations/collection_proxy_spec.rb +0 -233
- data/spec/associations/document_proxy_spec.rb +0 -45
- data/spec/associations/hash_proxy_spec.rb +0 -181
- data/spec/associations/proxy_base_spec.rb +0 -92
- data/spec/associations_spec.rb +0 -218
- data/spec/attributes_accessor_spec.rb +0 -39
- data/spec/attributes_spec.rb +0 -184
- data/spec/bson_matchers.rb +0 -54
- data/spec/bson_spec.rb +0 -196
- data/spec/collection_spec.rb +0 -169
- data/spec/connection_spec.rb +0 -169
- data/spec/contexts/ids_spec.rb +0 -49
- data/spec/contexts/mongo_spec.rb +0 -241
- data/spec/contexts_spec.rb +0 -56
- data/spec/criteria/optional_spec.rb +0 -26
- data/spec/criteria_spec.rb +0 -73
- data/spec/cursor_spec.rb +0 -91
- data/spec/database_cleaner_spec.rb +0 -24
- data/spec/document_ext.rb +0 -9
- data/spec/document_spec.rb +0 -569
- data/spec/embedded_save_spec.rb +0 -73
- data/spec/ext_spec.rb +0 -100
- data/spec/finders_spec.rb +0 -61
- data/spec/hash_matchers.rb +0 -29
- data/spec/index_spec.rb +0 -79
- data/spec/matchers_spec.rb +0 -342
- data/spec/mongodb.yml +0 -6
- data/spec/mongodb_pairs.yml +0 -8
- data/spec/new_record_spec.rb +0 -128
- data/spec/polymorphic_collection_spec.rb +0 -47
- data/spec/references_many_spec.rb +0 -214
- data/spec/references_spec.rb +0 -121
- data/spec/root_spec.rb +0 -41
- data/spec/scope_spec.rb +0 -88
- data/spec/spec_helper.rb +0 -16
- data/spec/timestamps_spec.rb +0 -154
- data/spec/update_spec.rb +0 -167
- data/spec/validations_spec.rb +0 -30
data/spec/criteria_spec.rb
DELETED
@@ -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
|