durran-mongoid 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/MIT_LICENSE +20 -0
- data/README.textile +134 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/mongoid.rb +77 -0
- data/lib/mongoid/associations/association_factory.rb +21 -0
- data/lib/mongoid/associations/belongs_to_association.rb +23 -0
- data/lib/mongoid/associations/has_many_association.rb +25 -0
- data/lib/mongoid/associations/has_one_association.rb +26 -0
- data/lib/mongoid/document.rb +202 -0
- data/lib/mongoid/extensions.rb +7 -0
- data/lib/mongoid/extensions/array/conversions.rb +13 -0
- data/lib/mongoid/extensions/object/conversions.rb +13 -0
- data/lib/mongoid/paginator.rb +22 -0
- data/mongoid.gemspec +79 -0
- data/spec/integration/mongoid/document_spec.rb +95 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/unit/mongoid/associations/association_factory_spec.rb +48 -0
- data/spec/unit/mongoid/associations/belongs_to_association_spec.rb +35 -0
- data/spec/unit/mongoid/associations/has_many_association_spec.rb +105 -0
- data/spec/unit/mongoid/associations/has_one_association_spec.rb +35 -0
- data/spec/unit/mongoid/document_spec.rb +559 -0
- data/spec/unit/mongoid/extensions/array/conversions_spec.rb +14 -0
- data/spec/unit/mongoid/extensions/object/conversions_spec.rb +13 -0
- data/spec/unit/mongoid/paginator_spec.rb +74 -0
- metadata +108 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../../../spec_helper.rb")
|
2
|
+
|
3
|
+
describe Mongoid::Extensions::Array::Conversions do
|
4
|
+
|
5
|
+
describe "#mongoidize" do
|
6
|
+
|
7
|
+
it "collects each of its attributes" do
|
8
|
+
array = [Person.new(:title => "Sir"), Person.new(:title => "Madam")]
|
9
|
+
array.mongoidize.should == [{ :title => "Sir" }, { :title => "Madam" }]
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../../../spec_helper.rb")
|
2
|
+
|
3
|
+
describe Mongoid::Extensions::Object::Conversions do
|
4
|
+
|
5
|
+
describe "#mongoidize" do
|
6
|
+
|
7
|
+
it "returns its attributes" do
|
8
|
+
Person.new(:title => "Sir").mongoidize.should == { :title => "Sir" }
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../../spec_helper.rb")
|
2
|
+
|
3
|
+
describe Mongoid::Paginator do
|
4
|
+
|
5
|
+
describe "#limit" do
|
6
|
+
|
7
|
+
context "when per_page is defined" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@options = { :per_page => 50 }
|
11
|
+
@paginator = Mongoid::Paginator.new(@options)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns the per_page value" do
|
15
|
+
@paginator.limit.should == 50
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when per_page is not defined" do
|
21
|
+
|
22
|
+
before do
|
23
|
+
@options = {}
|
24
|
+
@paginator = Mongoid::Paginator.new(@options)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the default of 20" do
|
28
|
+
@paginator.limit.should == 20
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#offset" do
|
36
|
+
|
37
|
+
context "when page is defined" do
|
38
|
+
|
39
|
+
before do
|
40
|
+
@options = { :page => 11 }
|
41
|
+
@paginator = Mongoid::Paginator.new(@options)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns the page value - 1 * limit" do
|
45
|
+
@paginator.offset.should == 200
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when page is not defined" do
|
51
|
+
|
52
|
+
before do
|
53
|
+
@options = {}
|
54
|
+
@paginator = Mongoid::Paginator.new(@options)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns the default of 0" do
|
58
|
+
@paginator.offset.should == 0
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#options" do
|
66
|
+
|
67
|
+
it "returns a hash of the limit and offset" do
|
68
|
+
@paginator = Mongoid::Paginator.new
|
69
|
+
@paginator.options.should == { :limit => 20, :offset => 0 }
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: durran-mongoid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Durran Jordan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-23 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: active_support
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mongodb-mongo
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description:
|
36
|
+
email: durran@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.textile
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- MIT_LICENSE
|
46
|
+
- README.textile
|
47
|
+
- Rakefile
|
48
|
+
- VERSION
|
49
|
+
- lib/mongoid.rb
|
50
|
+
- lib/mongoid/associations/association_factory.rb
|
51
|
+
- lib/mongoid/associations/belongs_to_association.rb
|
52
|
+
- lib/mongoid/associations/has_many_association.rb
|
53
|
+
- lib/mongoid/associations/has_one_association.rb
|
54
|
+
- lib/mongoid/document.rb
|
55
|
+
- lib/mongoid/extensions.rb
|
56
|
+
- lib/mongoid/extensions/array/conversions.rb
|
57
|
+
- lib/mongoid/extensions/object/conversions.rb
|
58
|
+
- lib/mongoid/paginator.rb
|
59
|
+
- mongoid.gemspec
|
60
|
+
- spec/integration/mongoid/document_spec.rb
|
61
|
+
- spec/spec.opts
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- spec/unit/mongoid/associations/association_factory_spec.rb
|
64
|
+
- spec/unit/mongoid/associations/belongs_to_association_spec.rb
|
65
|
+
- spec/unit/mongoid/associations/has_many_association_spec.rb
|
66
|
+
- spec/unit/mongoid/associations/has_one_association_spec.rb
|
67
|
+
- spec/unit/mongoid/document_spec.rb
|
68
|
+
- spec/unit/mongoid/extensions/array/conversions_spec.rb
|
69
|
+
- spec/unit/mongoid/extensions/object/conversions_spec.rb
|
70
|
+
- spec/unit/mongoid/paginator_spec.rb
|
71
|
+
has_rdoc: false
|
72
|
+
homepage: http://github.com/durran/mongoid
|
73
|
+
licenses:
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options:
|
76
|
+
- --charset=UTF-8
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.3.5
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Mongoid
|
98
|
+
test_files:
|
99
|
+
- spec/integration/mongoid/document_spec.rb
|
100
|
+
- spec/spec_helper.rb
|
101
|
+
- spec/unit/mongoid/associations/association_factory_spec.rb
|
102
|
+
- spec/unit/mongoid/associations/belongs_to_association_spec.rb
|
103
|
+
- spec/unit/mongoid/associations/has_many_association_spec.rb
|
104
|
+
- spec/unit/mongoid/associations/has_one_association_spec.rb
|
105
|
+
- spec/unit/mongoid/document_spec.rb
|
106
|
+
- spec/unit/mongoid/extensions/array/conversions_spec.rb
|
107
|
+
- spec/unit/mongoid/extensions/object/conversions_spec.rb
|
108
|
+
- spec/unit/mongoid/paginator_spec.rb
|