mongoid-rspec 1.2.0 → 1.2.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/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.2-rc2
1
+ rvm 1.9.2
data/Gemfile CHANGED
@@ -1,11 +1,9 @@
1
1
  # A sample Gemfile
2
2
  source :gemcutter
3
3
 
4
- gem "rails", "3.0.0.rc"
5
-
6
- gem "mongoid", :git => 'git://github.com/durran/mongoid.git'
4
+ gem "mongoid", '>= 2.0.0.beta.15'
7
5
  gem 'bson_ext', '>= 1.0.4'
8
6
 
9
7
  gem 'redgreen'
10
8
 
11
- gem 'rspec-rails', ">= 2.0.0.beta.19"
9
+ gem 'rspec', ">= 2.0.0.beta.19"
@@ -1,81 +1,24 @@
1
- GIT
2
- remote: git://github.com/durran/mongoid.git
3
- revision: 93bd79e
4
- specs:
5
- mongoid (2.0.0.beta.15)
6
- activemodel (= 3.0.0.rc)
7
- bson (= 1.0.4)
8
- mongo (= 1.0.6)
9
- tzinfo (= 0.3.22)
10
- will_paginate (~> 3.0.pre)
11
-
12
1
  GEM
13
2
  remote: http://rubygems.org/
14
3
  specs:
15
- abstract (1.0.0)
16
- actionmailer (3.0.0.rc)
17
- actionpack (= 3.0.0.rc)
18
- mail (~> 2.2.5)
19
- actionpack (3.0.0.rc)
20
- activemodel (= 3.0.0.rc)
21
- activesupport (= 3.0.0.rc)
22
- builder (~> 2.1.2)
23
- erubis (~> 2.6.6)
24
- i18n (~> 0.4.1)
25
- rack (~> 1.2.1)
26
- rack-mount (~> 0.6.9)
27
- rack-test (~> 0.5.4)
28
- tzinfo (~> 0.3.22)
29
4
  activemodel (3.0.0.rc)
30
5
  activesupport (= 3.0.0.rc)
31
6
  builder (~> 2.1.2)
32
7
  i18n (~> 0.4.1)
33
- activerecord (3.0.0.rc)
34
- activemodel (= 3.0.0.rc)
35
- activesupport (= 3.0.0.rc)
36
- arel (~> 0.4.0)
37
- tzinfo (~> 0.3.22)
38
- activeresource (3.0.0.rc)
39
- activemodel (= 3.0.0.rc)
40
- activesupport (= 3.0.0.rc)
41
8
  activesupport (3.0.0.rc)
42
- arel (0.4.0)
43
- activesupport (>= 3.0.0.beta)
44
9
  bson (1.0.4)
45
10
  bson_ext (1.0.4)
46
11
  builder (2.1.2)
47
12
  diff-lcs (1.1.2)
48
- erubis (2.6.6)
49
- abstract (>= 1.0.0)
50
13
  i18n (0.4.1)
51
- mail (2.2.5)
52
- activesupport (>= 2.3.6)
53
- mime-types
54
- treetop (>= 1.4.5)
55
- mime-types (1.16)
56
- mongo (1.0.6)
14
+ mongo (1.0.7)
57
15
  bson (>= 1.0.4)
58
- nokogiri (1.4.3.1)
59
- polyglot (0.3.1)
60
- rack (1.2.1)
61
- rack-mount (0.6.9)
62
- rack (>= 1.0.0)
63
- rack-test (0.5.4)
64
- rack (>= 1.0)
65
- rails (3.0.0.rc)
66
- actionmailer (= 3.0.0.rc)
67
- actionpack (= 3.0.0.rc)
68
- activerecord (= 3.0.0.rc)
69
- activeresource (= 3.0.0.rc)
70
- activesupport (= 3.0.0.rc)
71
- bundler (>= 1.0.0.rc.1)
72
- railties (= 3.0.0.rc)
73
- railties (3.0.0.rc)
74
- actionpack (= 3.0.0.rc)
75
- activesupport (= 3.0.0.rc)
76
- rake (>= 0.8.3)
77
- thor (~> 0.14.0)
78
- rake (0.8.7)
16
+ mongoid (2.0.0.beta.16)
17
+ activemodel (= 3.0.0.rc)
18
+ bson (= 1.0.4)
19
+ mongo (= 1.0.7)
20
+ tzinfo (= 0.3.22)
21
+ will_paginate (~> 3.0.pre)
79
22
  redgreen (1.2.2)
80
23
  rspec (2.0.0.beta.19)
81
24
  rspec-core (= 2.0.0.beta.19)
@@ -85,17 +28,7 @@ GEM
85
28
  rspec-expectations (2.0.0.beta.19)
86
29
  diff-lcs (>= 1.1.2)
87
30
  rspec-mocks (2.0.0.beta.19)
88
- rspec-rails (2.0.0.beta.19)
89
- rspec (= 2.0.0.beta.19)
90
- webrat (>= 0.7.2.beta.1)
91
- thor (0.14.0)
92
- treetop (1.4.8)
93
- polyglot (>= 0.3.1)
94
31
  tzinfo (0.3.22)
95
- webrat (0.7.2.beta.1)
96
- nokogiri (>= 1.2.0)
97
- rack (>= 1.0)
98
- rack-test (>= 0.5.3)
99
32
  will_paginate (3.0.pre2)
100
33
 
101
34
  PLATFORMS
@@ -103,7 +36,6 @@ PLATFORMS
103
36
 
104
37
  DEPENDENCIES
105
38
  bson_ext (>= 1.0.4)
106
- mongoid!
107
- rails (= 3.0.0.rc)
39
+ mongoid (>= 2.0.0.beta.15)
108
40
  redgreen
109
- rspec-rails (>= 2.0.0.beta.19)
41
+ rspec (>= 2.0.0.beta.19)
@@ -0,0 +1,50 @@
1
+ mongoid-rspec
2
+ =
3
+
4
+ RSpec matchers for Mongoid.
5
+
6
+
7
+ Association Matchers
8
+ -
9
+ describe User do
10
+ it { should reference_many :articles }
11
+ it { should reference_many :comments }
12
+ it { should embed_one :profile }
13
+ it { should reference_many(:children).stored_as(:array) }
14
+ end
15
+
16
+ describe Profile do
17
+ it { should be_embedded_in(:user).as_inverse_of(:profile) }
18
+ end
19
+
20
+ describe Article do
21
+ it { should be_referenced_in(:user).as_inverse_of(:articles) }
22
+ it { should embed_many(:comments) }
23
+ end
24
+
25
+ describe Comment do
26
+ it { should be_embedded_in(:article).as_inverse_of(:comments) }
27
+ it { should be_referenced_in(:user).as_inverse_of(:comments) }
28
+ end
29
+
30
+ Validation Matchers
31
+ -
32
+ describe User do
33
+ it { should validate_presence_of(:login) }
34
+ it { should validate_uniqueness_of(:login) }
35
+ it { should validate_format_of(:login).to_allow("valid_login").not_to_allow("invalid login") }
36
+ it { should validate_associated(:profile) }
37
+ it { should validate_inclusion_of(:role).to_allow("admin", "member") }
38
+ it { should validate_numericality_of(:age) }
39
+ end
40
+
41
+ Others
42
+ -
43
+ describe User do
44
+ it { should have_fields(:email, :login) }
45
+ it { should have_field(:active).of_type(Boolean).with_default_value_of(false) }
46
+ it { should have_fields(:birthdate, :registered_at).of_type(DateTime) }
47
+
48
+ # useful if you use factory_girl and have Factory(:user) defined for User
49
+ it { should save }
50
+ end
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gem.authors = ["Evan Sagge"]
13
13
  gem.add_dependency "mongoid", ">= 2.0.0.beta.15"
14
14
  gem.add_dependency "bson_ext", ">= 1.0.4"
15
- gem.add_dependency "rspec-rails", ">= 2.0.0.beta.19"
15
+ gem.add_dependency "rspec", ">= 2.0.0.beta.19"
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
@@ -4,6 +4,7 @@ module Mongoid
4
4
  module Matchers
5
5
  module Associations
6
6
  HAS_MANY = defined?(Mongoid::Associations::HasManyRelated) ? Mongoid::Associations::HasManyRelated : Mongoid::Associations::ReferencesMany
7
+ HAS_MANY_AS_ARRAY = Mongoid::Associations::ReferencesManyAsArray
7
8
  HAS_ONE = defined?(Mongoid::Associations::HasOneRelated) ? Mongoid::Associations::HasOneRelated : Mongoid::Associations::ReferencesOne
8
9
  BELONGS_TO = defined?(Mongoid::Associations::BelongsToRelated) ? Mongoid::Associations::BelongsToRelated : Mongoid::Associations::ReferencedIn
9
10
  EMBEDS_MANY = Mongoid::Associations::EmbedsMany
@@ -37,6 +38,11 @@ module Mongoid
37
38
  self
38
39
  end
39
40
 
41
+ def stored_as(store_as)
42
+ @association[:type] = HAS_MANY_AS_ARRAY if store_as == :array
43
+ self
44
+ end
45
+
40
46
  def matches?(actual)
41
47
  @actual = actual.is_a?(Class) ? actual : actual.class
42
48
  association = @actual.associations[@association[:name]]
@@ -99,11 +105,13 @@ module Mongoid
99
105
  when HAS_ONE.name
100
106
  (passive ? 'reference' : 'references') << ' one'
101
107
  when HAS_MANY.name
102
- (passive ? 'reference' : 'references') << ' many'
108
+ (passive ? 'reference' : 'references') << ' many'
109
+ when HAS_MANY_AS_ARRAY.name
110
+ (passive ? 'reference' : 'references') << ' many as array'
103
111
  when BELONGS_TO.name
104
112
  (passive ? 'be referenced in' : 'referenced in')
105
113
  else
106
- raise "Unknown association type"
114
+ raise "Unknown association type '%s'" % type
107
115
  end
108
116
  end
109
117
  end
@@ -5,16 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid-rspec}
8
- s.version = "1.2.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Evan Sagge"]
12
- s.date = %q{2010-08-03}
12
+ s.date = %q{2010-08-25}
13
13
  s.description = %q{RSpec matches for Mongoid models, including association and validation matchers}
14
14
  s.email = %q{evansagge@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.markdown"
18
18
  ]
19
19
  s.files = [
20
20
  ".bundle/config",
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  "Gemfile",
25
25
  "Gemfile.lock",
26
26
  "LICENSE",
27
- "README.rdoc",
27
+ "README.markdown",
28
28
  "Rakefile",
29
29
  "VERSION",
30
30
  "lib/matchers/associations.rb",
@@ -70,16 +70,16 @@ Gem::Specification.new do |s|
70
70
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
71
71
  s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.15"])
72
72
  s.add_runtime_dependency(%q<bson_ext>, [">= 1.0.4"])
73
- s.add_runtime_dependency(%q<rspec-rails>, [">= 2.0.0.beta.19"])
73
+ s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
74
74
  else
75
75
  s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.15"])
76
76
  s.add_dependency(%q<bson_ext>, [">= 1.0.4"])
77
- s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.19"])
77
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
78
78
  end
79
79
  else
80
80
  s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.15"])
81
81
  s.add_dependency(%q<bson_ext>, [">= 1.0.4"])
82
- s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.19"])
82
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
83
83
  end
84
84
  end
85
85
 
@@ -7,6 +7,7 @@ class User
7
7
 
8
8
  references_many :articles
9
9
  references_many :comments
10
+ references_many :children, :stored_as => :array, :class_name => "User"
10
11
 
11
12
  embeds_one :profile
12
13
 
@@ -1,31 +1,24 @@
1
- # require 'spec_helper'
2
- #
3
- # describe "Associations" do
4
- # describe User do
5
- # subject { User }
6
- #
7
- # it { should reference_many :articles }
8
- # it { should reference_many :comments }
9
- # it { should embed_one :profile }
10
- # end
11
- #
12
- # describe Profile do
13
- # subject { Profile }
14
- #
15
- # it { should be_embedded_in(:user).as_inverse_of(:profile) }
16
- # end
17
- #
18
- # describe Article do
19
- # subject { Article }
20
- #
21
- # it { should be_referenced_in(:user).as_inverse_of(:articles) }
22
- # it { should embed_many(:comments) }
23
- # end
24
- #
25
- # describe Comment do
26
- # subject { Comment }
27
- #
28
- # it { should be_embedded_in(:article).as_inverse_of(:comments) }
29
- # it { should be_referenced_in(:user).as_inverse_of(:comments) }
30
- # end
31
- # end
1
+ require 'spec_helper'
2
+
3
+ describe "Associations" do
4
+ describe User do
5
+ it { should reference_many :articles }
6
+ it { should reference_many :comments }
7
+ it { should embed_one :profile }
8
+ it { should reference_many(:children).stored_as(:array) }
9
+ end
10
+
11
+ describe Profile do
12
+ it { should be_embedded_in(:user).as_inverse_of(:profile) }
13
+ end
14
+
15
+ describe Article do
16
+ it { should be_referenced_in(:user).as_inverse_of(:articles) }
17
+ it { should embed_many(:comments) }
18
+ end
19
+
20
+ describe Comment do
21
+ it { should be_embedded_in(:article).as_inverse_of(:comments) }
22
+ it { should be_referenced_in(:user).as_inverse_of(:comments) }
23
+ end
24
+ end
@@ -8,7 +8,7 @@ describe "Validations" do
8
8
  it { should validate_associated(:profile) }
9
9
  it { should validate_inclusion_of(:role).to_allow("admin", "member") }
10
10
  end
11
-
11
+
12
12
  describe Profile do
13
13
  it { should validate_numericality_of(:age) }
14
14
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 0
9
- version: 1.2.0
8
+ - 1
9
+ version: 1.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Evan Sagge
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-03 00:00:00 +08:00
17
+ date: 2010-08-25 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- name: rspec-rails
53
+ name: rspec
54
54
  prerelease: false
55
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
@@ -74,7 +74,7 @@ extensions: []
74
74
 
75
75
  extra_rdoc_files:
76
76
  - LICENSE
77
- - README.rdoc
77
+ - README.markdown
78
78
  files:
79
79
  - .bundle/config
80
80
  - .document
@@ -83,7 +83,7 @@ files:
83
83
  - Gemfile
84
84
  - Gemfile.lock
85
85
  - LICENSE
86
- - README.rdoc
86
+ - README.markdown
87
87
  - Rakefile
88
88
  - VERSION
89
89
  - lib/matchers/associations.rb
@@ -1,3 +0,0 @@
1
- = mongoid-rspec
2
-
3
- RSpec matchers for Mongoid