mongoid-rspec 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -1
- data/lib/matchers/document.rb +7 -3
- data/lib/matchers/indexes.rb +1 -1
- data/lib/mongoid-rspec/version.rb +1 -1
- data/spec/models/article.rb +3 -1
- data/spec/unit/document_spec.rb +1 -0
- data/spec/unit/indexes_spec.rb +1 -0
- metadata +24 -9
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
mongoid-rspec
|
2
2
|
=
|
3
3
|
|
4
|
+
[![Build Status](https://secure.travis-ci.org/evansagge/mongoid-rspec.png?branch=master)](https://travis-ci.org/evansagge/mongoid-rspec)
|
5
|
+
|
4
6
|
http://rubygems.org/gems/mongoid-rspec
|
5
7
|
|
6
8
|
RSpec matchers for Mongoid 3.x.
|
@@ -117,7 +119,6 @@ Others
|
|
117
119
|
-
|
118
120
|
describe User do
|
119
121
|
it { should have_fields(:email, :login) }
|
120
|
-
it { should have_field(:active).of_type(Boolean).with_default_value_of(false) }
|
121
122
|
it { should have_field(:s).with_alias(:status) }
|
122
123
|
it { should have_fields(:birthdate, :registered_at).of_type(DateTime) }
|
123
124
|
|
@@ -135,6 +136,13 @@ Others
|
|
135
136
|
it { should be_stored_in :logs }
|
136
137
|
end
|
137
138
|
|
139
|
+
describe Article do
|
140
|
+
it { should have_field(:published).of_type(Boolean).with_default_value_of(false) }
|
141
|
+
it { should have_field(:allow_comments).of_type(Boolean).with_default_value_of(true) }
|
142
|
+
it { should_not have_field(:allow_comments).of_type(Boolean).with_default_value_of(false) }
|
143
|
+
it { should_not have_field(:number_of_comments).of_type(Integer).with_default_value_of(1) }
|
144
|
+
end
|
145
|
+
|
138
146
|
Use
|
139
147
|
-
|
140
148
|
add in Gemfile
|
data/lib/matchers/document.rb
CHANGED
@@ -30,10 +30,14 @@ module Mongoid
|
|
30
30
|
error << " of type #{@klass.fields[attr].type}"
|
31
31
|
end
|
32
32
|
|
33
|
-
if !@default.nil?
|
34
|
-
|
33
|
+
if !@default.nil?
|
34
|
+
if @klass.fields[attr].default_val.nil?
|
35
|
+
error << " with default not set"
|
36
|
+
elsif @klass.fields[attr].default_val != @default
|
37
|
+
error << " with default value of #{@klass.fields[attr].default_val}"
|
38
|
+
end
|
35
39
|
end
|
36
|
-
|
40
|
+
|
37
41
|
if @field_alias and @klass.fields[attr].options[:as] != @field_alias
|
38
42
|
error << " with alias #{@klass.fields[attr].options[:as]}"
|
39
43
|
end
|
data/lib/matchers/indexes.rb
CHANGED
data/spec/models/article.rb
CHANGED
@@ -9,6 +9,7 @@ class Article
|
|
9
9
|
field :content
|
10
10
|
field :published, :type => Boolean, :default => false
|
11
11
|
field :allow_comments, :type => Boolean, :default => true
|
12
|
+
field :number_of_comments, :type => Integer
|
12
13
|
|
13
14
|
embeds_many :comments
|
14
15
|
embeds_one :permalink
|
@@ -20,4 +21,5 @@ class Article
|
|
20
21
|
|
21
22
|
index({ title: 1 }, { unique: true, background: true })
|
22
23
|
index({ published: 1 })
|
23
|
-
|
24
|
+
index({ 'permalink._id' => 1 })
|
25
|
+
end
|
data/spec/unit/document_spec.rb
CHANGED
@@ -12,6 +12,7 @@ describe "Document" do
|
|
12
12
|
it { should have_field(:published).of_type(Boolean).with_default_value_of(false) }
|
13
13
|
it { should have_field(:allow_comments).of_type(Boolean).with_default_value_of(true) }
|
14
14
|
it { should_not have_field(:allow_comments).of_type(Boolean).with_default_value_of(false) }
|
15
|
+
it { should_not have_field(:number_of_comments).of_type(Integer).with_default_value_of(1) }
|
15
16
|
it { should be_mongoid_document }
|
16
17
|
it { should be_versioned_document }
|
17
18
|
it { should be_timestamped_document }
|
data/spec/unit/indexes_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: mongoid
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 3.0.1
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.1
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '2.9'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.9'
|
47
62
|
description: RSpec matches for Mongoid models, including association and validation
|
48
63
|
matchers
|
49
64
|
email: evansagge@gmail.com
|
@@ -118,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
133
|
version: '0'
|
119
134
|
requirements: []
|
120
135
|
rubyforge_project: mongoid-rspec
|
121
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.24
|
122
137
|
signing_key:
|
123
138
|
specification_version: 3
|
124
139
|
summary: RSpec matchers for Mongoid
|