mongoa 0.0.2 → 0.1.1
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.
- data/VERSION +1 -1
- data/lib/mongoa/{rspec2.rb → integrations/rspec2.rb} +1 -0
- data/lib/mongoa/mongo_mapper/association_matcher.rb +10 -10
- data/lib/mongoa/mongo_mapper/associations.rb +12 -0
- data/lib/mongoa/{matchers.rb → mongo_mapper/matchers.rb} +1 -0
- data/lib/mongoa.rb +4 -4
- data/mongoa.gemspec +5 -4
- metadata +7 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.1
|
@@ -27,7 +27,11 @@ module Mongoa
|
|
27
27
|
return false
|
28
28
|
end
|
29
29
|
@subject = subject
|
30
|
-
association_exists? && macro_correct?
|
30
|
+
result = (association_exists? && macro_correct?)
|
31
|
+
if result && macro == :belongs_to
|
32
|
+
result = foreign_key_exists?
|
33
|
+
end
|
34
|
+
result
|
31
35
|
end
|
32
36
|
|
33
37
|
def failure_message
|
@@ -53,7 +57,6 @@ module Mongoa
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def model_class
|
56
|
-
p @subject
|
57
60
|
@subject.class
|
58
61
|
end
|
59
62
|
|
@@ -74,17 +77,14 @@ module Mongoa
|
|
74
77
|
def association_exists?
|
75
78
|
if !association
|
76
79
|
@missing = "no association called #{name}"
|
77
|
-
false
|
80
|
+
return false
|
78
81
|
end
|
79
82
|
true
|
80
83
|
end
|
81
84
|
|
82
|
-
|
83
|
-
association
|
84
|
-
|
85
|
-
|
86
|
-
def macro_correct?
|
87
|
-
association.type == macro
|
85
|
+
def macro_correct?
|
86
|
+
(association.type == :belongs_to && macro == :belongs_to) ||
|
87
|
+
(association.type == :many && macro == :has_many)
|
88
88
|
end
|
89
89
|
|
90
90
|
def foreign_key_exists?
|
@@ -92,7 +92,7 @@ module Mongoa
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def belongs_to_foreign_key_exists?
|
95
|
-
|
95
|
+
model_class.keys.keys.include?("#{reflection_name}_id")
|
96
96
|
end
|
97
97
|
|
98
98
|
def reflection_name
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module MongoMapper
|
2
|
+
module Plugins
|
3
|
+
module Associations
|
4
|
+
module ClassMethods
|
5
|
+
def find_association(name)
|
6
|
+
name_association = self.associations.detect {|key, value| key.to_s == name.to_s}
|
7
|
+
name_association ? name_association.last : nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/mongoa.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
if defined?(RSpec)
|
1
|
+
# if defined?(RSpec)
|
2
2
|
require 'mongoa/integrations/rspec2'
|
3
|
-
else
|
4
|
-
|
5
|
-
end
|
3
|
+
# else
|
4
|
+
# raise 'DONT SUPPORT THAT TEST FRAMEWORK'
|
5
|
+
# end
|
data/mongoa.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoa}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott J. Tamosunas"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-08}
|
13
13
|
s.description = %q{Adds the association and validation macros for Rspec in the same way Shoulda does for ActiveRecord.}
|
14
14
|
s.email = %q{tamosunas@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,9 +24,10 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/mongoa.rb",
|
27
|
-
"lib/mongoa/
|
27
|
+
"lib/mongoa/integrations/rspec2.rb",
|
28
28
|
"lib/mongoa/mongo_mapper/association_matcher.rb",
|
29
|
-
"lib/mongoa/
|
29
|
+
"lib/mongoa/mongo_mapper/associations.rb",
|
30
|
+
"lib/mongoa/mongo_mapper/matchers.rb",
|
30
31
|
"mongoa.gemspec",
|
31
32
|
"spec/mongoa_spec.rb",
|
32
33
|
"spec/spec.opts",
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott J. Tamosunas
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-08 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -49,9 +49,10 @@ files:
|
|
49
49
|
- Rakefile
|
50
50
|
- VERSION
|
51
51
|
- lib/mongoa.rb
|
52
|
-
- lib/mongoa/
|
52
|
+
- lib/mongoa/integrations/rspec2.rb
|
53
53
|
- lib/mongoa/mongo_mapper/association_matcher.rb
|
54
|
-
- lib/mongoa/
|
54
|
+
- lib/mongoa/mongo_mapper/associations.rb
|
55
|
+
- lib/mongoa/mongo_mapper/matchers.rb
|
55
56
|
- mongoa.gemspec
|
56
57
|
- spec/mongoa_spec.rb
|
57
58
|
- spec/spec.opts
|