light_mongo 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Elliot Crosby-McCullough
@@ -53,14 +53,12 @@ files:
53
53
  - integration/object_embedding_spec.rb
54
54
  - integration/support/integration_helper.rb
55
55
  - lib/document.rb
56
- - lib/document/active_model_compliance.rb
57
56
  - lib/document/persistence.rb
58
57
  - lib/document/serialization.rb
59
58
  - lib/document/serialization/hash_serializer.rb
60
59
  - lib/document/serialization/serializer.rb
61
60
  - lib/light_mongo.rb
62
61
  - lib/util.rb
63
- - spec/document/active_model_compliance_spec.rb
64
62
  - spec/document/persistence_spec.rb
65
63
  - spec/document/serialization/hash_serializer_spec.rb
66
64
  - spec/document/serialization/serializer_spec.rb
@@ -97,7 +95,6 @@ signing_key:
97
95
  specification_version: 3
98
96
  summary: A lightweight Ruby object persistence library for Mongo DB
99
97
  test_files:
100
- - spec/document/active_model_compliance_spec.rb
101
98
  - spec/document/persistence_spec.rb
102
99
  - spec/document/serialization/hash_serializer_spec.rb
103
100
  - spec/document/serialization/serializer_spec.rb
@@ -1,44 +0,0 @@
1
- require 'rubygems'
2
-
3
- require 'active_model/naming'
4
-
5
- require 'active_model/deprecated_error_methods'
6
- require 'active_model/errors'
7
-
8
- # Still missing from complete ActionPack integration is
9
- # validations, which I've left out of this "barebones"
10
- # compliance, and translations, which might be worth
11
- # bundling in the future.
12
-
13
- module LightMongo
14
- module Document
15
-
16
- module ActiveModelCompliance
17
- # Replace this with your own validations.
18
- def valid?
19
- true
20
- end
21
-
22
- # There is currently no useful difference
23
- # between a new record and a destroyed record.
24
- #
25
- # As such, these methods are essentially synonymous.
26
- def new_record?
27
- @_id.nil?
28
- end
29
-
30
- def destroyed?
31
- @_id.nil?
32
- end
33
-
34
- def errors
35
- @errors ||= ActiveModel::Errors.new(self)
36
- end
37
-
38
- def self.included(doc_class)
39
- doc_class.extend ActiveModel::Naming
40
- end
41
- end
42
-
43
- end
44
- end
@@ -1,119 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../lib/document/active_model_compliance'
2
-
3
- ActiveModelCompliance = LightMongo::Document::ActiveModelCompliance
4
-
5
- class ActiveModelComplianceTest
6
- include LightMongo::Document::ActiveModelCompliance
7
- end
8
-
9
- describe ActiveModelCompliance do
10
- before(:each) do
11
- @model = ActiveModelComplianceTest.new
12
- end
13
-
14
- describe "#valid?" do
15
- it "responds to #valid?" do
16
- @model.should respond_to(:valid?)
17
- end
18
-
19
- it "always returns true" do
20
- @model.valid?.should be_true
21
- end
22
- end
23
-
24
- describe "#new_record?" do
25
- it "responds to #new_record?" do
26
- @model.should respond_to(:new_record?)
27
- end
28
-
29
- context "when the object has an id" do
30
- before(:each) do
31
- @model.instance_variable_set(:@_id, mock(:id))
32
- end
33
-
34
- it "is false" do
35
- @model.new_record?.should be_false
36
- end
37
- end
38
-
39
- context "when the object has no id" do
40
- before(:each) do
41
- @model.instance_variable_set(:@_id, nil)
42
- end
43
-
44
- it "is true" do
45
- @model.new_record?.should be_true
46
- end
47
- end
48
- end
49
-
50
- describe "#destroyed?" do
51
- it "responds to #destroyed?" do
52
- @model.should respond_to(:destroyed?)
53
- end
54
-
55
- context "when the object has an id" do
56
- before(:each) do
57
- @model.instance_variable_set(:@_id, mock(:id))
58
- end
59
-
60
- it "is false" do
61
- @model.destroyed?.should be_false
62
- end
63
- end
64
-
65
- context "when the object has no id" do
66
- before(:each) do
67
- @model.instance_variable_set(:@_id, nil)
68
- end
69
-
70
- it "is true" do
71
- @model.destroyed?.should be_true
72
- end
73
- end
74
- end
75
-
76
- describe "#errors" do
77
- it "responds to errors" do
78
- @model.should respond_to(:errors)
79
- end
80
-
81
- describe "#[]" do
82
- it "returns an array on a missing key lookup" do
83
- @model.errors[:does_not_exist].should be_an(Array)
84
- end
85
- end
86
-
87
- describe "#full_messages" do
88
- it "returns an array" do
89
- @model.errors.full_messages.should be_an(Array)
90
- end
91
- end
92
- end
93
-
94
- describe ".model_name" do
95
- it "responds to model_name" do
96
- ActiveModelComplianceTest.should respond_to(:model_name)
97
- end
98
-
99
- it "is a string" do
100
- ActiveModelComplianceTest.model_name.should be_a(String)
101
- end
102
-
103
- it "has a human inflector" do
104
- ActiveModelComplianceTest.model_name.human.should be_a(String)
105
- end
106
-
107
- it "has a partial path inflector" do
108
- ActiveModelComplianceTest.model_name.partial_path.should be_a(String)
109
- end
110
-
111
- it "has a singular inflector" do
112
- ActiveModelComplianceTest.model_name.singular.should be_a(String)
113
- end
114
-
115
- it "has a plural inflector" do
116
- ActiveModelComplianceTest.model_name.plural.should be_a(String)
117
- end
118
- end
119
- end