mongoid-rspec 1.4.3 → 1.4.4
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/lib/matchers/document.rb +3 -3
- data/lib/mongoid-rspec/version.rb +1 -1
- data/spec/models/article.rb +2 -0
- data/spec/unit/associations_spec.rb +1 -0
- data/spec/unit/document_spec.rb +2 -0
- metadata +1 -1
data/lib/matchers/document.rb
CHANGED
@@ -24,8 +24,8 @@ module Mongoid
|
|
24
24
|
if @type and @klass.fields[attr].type != @type
|
25
25
|
error << " of type #{@klass.fields[attr].type}"
|
26
26
|
end
|
27
|
-
|
28
|
-
if
|
27
|
+
|
28
|
+
if !@default.nil? and !@klass.fields[attr].default.nil? and @klass.fields[attr].default != @default
|
29
29
|
error << " with default value of #{@klass.fields[attr].default}"
|
30
30
|
end
|
31
31
|
|
@@ -48,7 +48,7 @@ module Mongoid
|
|
48
48
|
def description
|
49
49
|
desc = "have #{@attributes.size > 1 ? 'fields' : 'field'} named #{@attributes.collect(&:inspect).to_sentence}"
|
50
50
|
desc << " of type #{@type.inspect}" if @type
|
51
|
-
desc << " with default value of #{@default.inspect}" if
|
51
|
+
desc << " with default value of #{@default.inspect}" if !@default.nil?
|
52
52
|
desc
|
53
53
|
end
|
54
54
|
end
|
data/spec/models/article.rb
CHANGED
@@ -7,8 +7,10 @@ class Article
|
|
7
7
|
field :title
|
8
8
|
field :content
|
9
9
|
field :published, :type => Boolean, :default => false
|
10
|
+
field :allow_comments, :type => Boolean, :default => true
|
10
11
|
|
11
12
|
embeds_many :comments
|
13
|
+
embeds_one :permalink
|
12
14
|
referenced_in :author, :class_name => 'User', :inverse_of => :articles
|
13
15
|
|
14
16
|
validates :title, :presence => true
|
@@ -25,6 +25,7 @@ describe "Associations" do
|
|
25
25
|
it { should be_referenced_in(:author).of_type(User).as_inverse_of(:articles) }
|
26
26
|
it { should belong_to(:author).of_type(User).as_inverse_of(:articles) }
|
27
27
|
it { should embed_many(:comments) }
|
28
|
+
it { should embed_one(:permalink) }
|
28
29
|
end
|
29
30
|
|
30
31
|
describe Comment do
|
data/spec/unit/document_spec.rb
CHANGED
@@ -7,6 +7,8 @@ describe "Document" do
|
|
7
7
|
|
8
8
|
describe Article do
|
9
9
|
it { should have_field(:published).of_type(Boolean).with_default_value_of(false) }
|
10
|
+
it { should have_field(:allow_comments).of_type(Boolean).with_default_value_of(true) }
|
11
|
+
it { should_not have_field(:allow_comments).of_type(Boolean).with_default_value_of(false) }
|
10
12
|
end
|
11
13
|
|
12
14
|
describe Article do
|