mongoid-rspec 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
4
  - ruby-head
data/README.md CHANGED
@@ -27,6 +27,8 @@ Association Matchers
27
27
  it { should have_many(:articles).with_foreign_key(:author_id) }
28
28
 
29
29
  it { should have_one(:record) }
30
+ #can verify autobuild is set to true
31
+ it { should have_one(:record).with_autobuild }
30
32
 
31
33
  it { should have_many :comments }
32
34
 
@@ -166,6 +168,11 @@ Others
166
168
  it { should_not have_field(:number_of_comments).of_type(Integer).with_default_value_of(1) }
167
169
  end
168
170
 
171
+ Known issues
172
+ -
173
+
174
+ accept_nested_attributes_for matcher must test options [issue 91](https://github.com/evansagge/mongoid-rspec/issues/91).
175
+
169
176
  Acknowledgement
170
177
  -
171
178
  Thanks to [Durran Jordan](https://github.com/durran) for providing the changes necessary to make
@@ -57,6 +57,12 @@ module Mongoid
57
57
  self
58
58
  end
59
59
 
60
+ def with_autobuild
61
+ @association[:autobuild] = true
62
+ @expectation_message << " which specifies autobuild as #{@association[:autobuild].to_s}"
63
+ self
64
+ end
65
+
60
66
  def stored_as(store_as)
61
67
  raise NotImplementedError, "`references_many #{@association[:name]} :stored_as => :array` has been removed in Mongoid 2.0.0.rc, use `references_and_referenced_in_many #{@association[:name]}` instead"
62
68
  end
@@ -120,6 +126,15 @@ module Mongoid
120
126
  end
121
127
  end
122
128
 
129
+ if @association[:autobuild]
130
+ if metadata.autobuilding? != true
131
+ @negative_result_message = "#{@positive_result_message} which did not set autobuild"
132
+ return false
133
+ else
134
+ @positive_result_message = "#{@positive_result_message} which set autobuild"
135
+ end
136
+ end
137
+
123
138
  if @association[:index]
124
139
  if metadata.index != true
125
140
  @negative_result_message = "#{@positive_result_message} which did not set index"
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Rspec
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.0"
4
4
  end
5
5
  end
data/spec/models/user.rb CHANGED
@@ -14,7 +14,7 @@ class User
14
14
  has_many :articles, :foreign_key => :author_id
15
15
  has_many :comments, :dependent => :destroy, :autosave => true
16
16
  has_and_belongs_to_many :children, :class_name => "User"
17
- has_one :record
17
+ has_one :record, :autobuild => true
18
18
 
19
19
  embeds_one :profile
20
20
 
@@ -4,7 +4,7 @@ describe "Associations" do
4
4
  describe User do
5
5
  it { should have_many(:articles).with_foreign_key(:author_id) }
6
6
 
7
- it { should have_one(:record) }
7
+ it { should have_one(:record).with_autobuild }
8
8
 
9
9
  it { should have_many(:comments).with_dependent(:destroy).with_autosave }
10
10
 
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.6.0
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -127,15 +127,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  - - ! '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
+ segments:
131
+ - 0
132
+ hash: -1467103026555514284
130
133
  required_rubygems_version: !ruby/object:Gem::Requirement
131
134
  none: false
132
135
  requirements:
133
136
  - - ! '>='
134
137
  - !ruby/object:Gem::Version
135
138
  version: '0'
139
+ segments:
140
+ - 0
141
+ hash: -1467103026555514284
136
142
  requirements: []
137
143
  rubyforge_project: mongoid-rspec
138
- rubygems_version: 1.8.24
144
+ rubygems_version: 1.8.25
139
145
  signing_key:
140
146
  specification_version: 3
141
147
  summary: RSpec matchers for Mongoid