ninja-model 0.9.3 → 0.9.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/.gitignore CHANGED
@@ -2,7 +2,7 @@
2
2
  *.cache
3
3
  *.log
4
4
  *.pid
5
- tmp/**/*
5
+ tmp/
6
6
  doc/*
7
7
  .DS_Store
8
8
  *.sqlite3
@@ -12,7 +12,7 @@ doc/plugins
12
12
  doc/*.dot
13
13
  coverage/*
14
14
  *.sw?
15
- vendor/plugins/ns_web
15
+ vendor/bundle
16
16
  Gemfile.lock
17
17
  .bundle
18
18
  *.gem
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec', :version => 2 do
4
+ guard 'rspec' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { "spec" }
@@ -152,6 +152,24 @@ module NinjaModel
152
152
  compute_type(klass)
153
153
  end
154
154
 
155
+ def attribute_for_inspect(attr_name)
156
+ value = read_attribute(attr_name)
157
+ if value.is_a?(String) && value.length > 50
158
+ "#{value[0..50]}...".inspect
159
+ elsif value.is_a?(Date) || value.is_a?(Time)
160
+ %("#{value.to_s(:db)}")
161
+ else
162
+ value.inspect
163
+ end
164
+ end
165
+
166
+ def inspect
167
+ attributes_as_nice_string = self.class.attribute_names.collect { |attr|
168
+ "#{attr}: #{attribute_for_inspect(attr)}"
169
+ }.compact.join(', ')
170
+ "#<#{self.class} #{attributes_as_nice_string}>"
171
+ end
172
+
155
173
 
156
174
  private
157
175
 
@@ -6,7 +6,6 @@ module NinjaModel
6
6
  included do
7
7
  include ActiveModel::Validations
8
8
  include ActiveModel::Validations::Callbacks
9
- define_model_callbacks :validation
10
9
  end
11
10
 
12
11
  def save(options={})
@@ -22,7 +21,7 @@ module NinjaModel
22
21
  protected
23
22
 
24
23
  def perform_validations(options)
25
- perform_validation = options[:validate] != false
24
+ perform_validation = options[:validat] != false
26
25
  perform_validation ? valid?(options[:context]) : true
27
26
  end
28
27
  end
@@ -1,3 +1,3 @@
1
1
  module NinjaModel
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
data/ninja-model.gemspec CHANGED
@@ -18,15 +18,15 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency 'activerecord', '~> 3.1.0'
22
- s.add_dependency 'rake', '~> 0.9.2'
21
+ s.add_dependency 'activerecord', '~> 3.1.12'
22
+ s.add_dependency 'rake'
23
23
 
24
- s.add_development_dependency 'rspec', '~> 2.8.0'
25
- s.add_development_dependency 'mocha', '~> 0.10.0'
26
- s.add_development_dependency 'guard-rspec', '~> 0.5.10'
24
+ s.add_development_dependency 'rspec', '~> 2.13.0'
25
+ s.add_development_dependency 'mocha', '~> 0.13.0'
26
+ s.add_development_dependency 'guard-rspec', '~> 3.0.0'
27
27
  s.add_development_dependency 'libnotify', '~> 0.6.0'
28
28
  s.add_development_dependency 'yard', '~> 0.7.4'
29
29
  s.add_development_dependency 'redcarpet', '~> 2.0.0'
30
30
  s.add_development_dependency 'sqlite3', '~> 1.3.5'
31
- s.add_development_dependency 'factory_girl', '~> 2.5.0'
31
+ s.add_development_dependency 'factory_girl', '~> 4.2.0'
32
32
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NinjaModel::Associations::BelongsToAssociation do
4
- let(:user) { Factory(:user) }
5
- let(:post) { Factory(:post, :user_id => user.id) }
4
+ let(:user) { FactoryGirl.create(:user) }
5
+ let(:post) { FactoryGirl.create(:post, user_id: user.id) }
6
6
 
7
7
  context 'with an ActiveRecord parent' do
8
8
  describe 'accessing the association directly' do
@@ -28,12 +28,12 @@ describe NinjaModel::Associations::BelongsToAssociation do
28
28
  describe 'accessing the association directly' do
29
29
  it 'should trigger a fetch' do
30
30
  NinjaModel::Relation.any_instance.expects(:to_a).returns(post)
31
- t = Tag.new(:post_id => post.id)
31
+ t = Tag.new(post_id: post.id)
32
32
  t.post
33
33
  end
34
34
 
35
35
  it 'should assign the proper predicates' do
36
- t = Tag.new(:post_id => post.id)
36
+ t = Tag.new(post_id: post.id)
37
37
  predicates = t.association(:post).scoped.predicates
38
38
  predicates.count.should eql(1)
39
39
  predicates.first.attribute.should eql(:id)
@@ -47,12 +47,12 @@ describe NinjaModel::Associations::BelongsToAssociation do
47
47
  describe 'accessing the association directly' do
48
48
  it 'should trigger a fetch' do
49
49
  NinjaModel::Relation.any_instance.expects(:to_a).returns(post)
50
- c = Category.new(:post_id => post.id)
50
+ c = Category.new(post_id: post.id)
51
51
  c.post
52
52
  end
53
53
 
54
54
  it 'should assign the proper predicates' do
55
- c = Category.new(:post_id => post.id)
55
+ c = Category.new(post_id: post.id)
56
56
  predicates = c.association(:post).scoped.predicates
57
57
  predicates.count.should eql(1)
58
58
  predicates.first.attribute.should eql(:id)
@@ -68,7 +68,7 @@ describe NinjaModel::Associations::BelongsToAssociation do
68
68
  end
69
69
 
70
70
  it 'should properly update the ids when assigning a new instance' do
71
- t = Factory(:tag)
71
+ t = FactoryGirl.create(:tag)
72
72
  t.post = post
73
73
  t.post_id.should eql(post.id)
74
74
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NinjaModel::Associations::HasManyAssociation do
4
- let(:user) { Factory(:user) }
4
+ let(:user) { FactoryGirl.create(:user) }
5
5
 
6
6
  context 'with an ActiveRecord parent' do
7
7
 
@@ -48,8 +48,8 @@ describe NinjaModel::Associations::HasManyAssociation do
48
48
 
49
49
  context 'with a NinjaModel parent' do
50
50
 
51
- let(:post) { Factory(:post) }
52
- let!(:tags) { FactoryGirl.create_list(:tag, 2, :post_id => 1) }
51
+ let(:post) { FactoryGirl.create(:post) }
52
+ let!(:tags) { FactoryGirl.create_list(:tag, 2, post_id: 1) }
53
53
 
54
54
  context 'and an ActiveRecord association' do
55
55
  it 'should return an Array' do
@@ -61,7 +61,7 @@ describe NinjaModel::Associations::HasManyAssociation do
61
61
  end
62
62
 
63
63
  it 'should allow chaining queries' do
64
- post.tags.where(:name => 'Tag 2').count.should eql(1)
64
+ post.tags.where(name: 'Tag 2').count.should eql(1)
65
65
  end
66
66
 
67
67
  describe 'building an associated object' do
@@ -88,7 +88,7 @@ describe NinjaModel::Associations::HasManyAssociation do
88
88
  end
89
89
 
90
90
  it 'should allow chaining' do
91
- predicates = post.categories.where(:name => 'foo').predicates
91
+ predicates = post.categories.where(name: 'foo').predicates
92
92
  predicates.count.should eql(2)
93
93
  predicates.first.attribute.should eql(:post_id)
94
94
  predicates.first.meth.should eql(:eq)
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NinjaModel::Associations::HasOneAssociation do
4
- let(:user) { Factory(:user) }
5
- let(:post) { Factory(:post, :user_id => user.id) }
6
- let(:bio) { Factory(:bio, :user_id => user.id) }
4
+ let(:user) { FactoryGirl.create(:user) }
5
+ let(:post) { FactoryGirl.create(:post, user: user) }
6
+ let(:bio) { FactoryGirl.create(:bio, user: user) }
7
7
 
8
8
  context 'with an ActiveRecord parent' do
9
9
  describe 'accessing the association directly' do
@@ -24,7 +24,7 @@ describe NinjaModel::Associations::HasOneAssociation do
24
24
 
25
25
  context 'with a NinjaModel parent' do
26
26
  context 'and an ActiveRecord child' do
27
- let!(:email_address) { Factory(:email_address, :bio_id => bio.id) }
27
+ let!(:email_address) { FactoryGirl.create(:email_address, bio: bio) }
28
28
  describe 'accessing the association directly' do
29
29
  it 'should retrieve the record' do
30
30
  bio.email_address.should be_kind_of(EmailAddress)
@@ -38,12 +38,12 @@ describe NinjaModel::Associations::HasOneAssociation do
38
38
  end
39
39
 
40
40
  it 'should allow creating the association' do
41
- bio.create_email_address(:email => 'foo@bar.com').should be_true
41
+ bio.create_email_address(email: 'foo@bar.com').should be_true
42
42
  end
43
43
  end
44
44
 
45
45
  context 'and a NinjaModel child' do
46
- let(:body) { Factory(:body, :post_id => post.id) }
46
+ let(:body) { FactoryGirl.create(:body, post: post) }
47
47
  describe 'accessing the association directly' do
48
48
  it 'should trigger a fetch' do
49
49
  NinjaModel::Relation.any_instance.expects(:to_a).returns([body])
@@ -64,14 +64,14 @@ describe NinjaModel::Associations::HasOneAssociation do
64
64
  # We have to stub to_a here because building will try and retrieve the
65
65
  # existing record to remove ownership
66
66
  #
67
- NinjaModel::Relation.any_instance.stubs(:to_a).returns([])
67
+ NinjaModel::Relation.any_instance.stubs(to_a: [])
68
68
  body = post.build_body
69
69
  body.should be_kind_of(Body)
70
70
  body.post_id.should eql(post.id)
71
71
  end
72
72
 
73
73
  it 'should allow creating the association' do
74
- NinjaModel::Relation.any_instance.stubs(:to_a).returns([])
74
+ NinjaModel::Relation.any_instance.stubs(to_a: [])
75
75
  Body.any_instance.stubs(:create).returns(true)
76
76
  post.create_body(:text => 'Foobar')
77
77
  end
@@ -0,0 +1,257 @@
1
+ require 'spec_helper'
2
+
3
+ describe NinjaModel::Callbacks do
4
+ let(:adapter) { mock('Adapter') }
5
+ class CallbackModel < NinjaModel::Base
6
+ attribute :testing, :integer
7
+
8
+ before_validation :before_validation_callback
9
+ after_validation :after_validation_callback
10
+
11
+ before_save :before_save_callback
12
+ after_save :after_save_callback
13
+ around_save :around_save_callback
14
+
15
+ before_create :before_create_callback
16
+ after_create :after_create_callback
17
+ around_create :around_create_callback
18
+
19
+ before_update :before_update_callback
20
+ after_update :after_update_callback
21
+ around_update :around_update_callback
22
+
23
+ before_destroy :before_destroy_callback
24
+ after_destroy :after_destroy_callback
25
+ around_destroy :around_destroy_callback
26
+
27
+ def before_validation_callback; true; end
28
+ def after_validation_callback; true; end
29
+
30
+ def before_save_callback; true; end
31
+ def after_save_callback; true; end
32
+ def around_save_callback; yield; end
33
+
34
+ def before_create_callback; true; end
35
+ def after_create_callback; true; end
36
+ def around_create_callback; yield; end
37
+
38
+ def before_update_callback; true; end
39
+ def after_update_callback; true; end
40
+ def around_update_callback; yield; end
41
+
42
+ def before_destroy_callback; true; end
43
+ def after_destroy_callback; true; end
44
+ def around_destroy_callback; yield; end
45
+ end
46
+
47
+ before {
48
+ @obj = CallbackModel.new
49
+ @obj.class.stubs(adapter: adapter)
50
+ }
51
+
52
+ describe 'save' do
53
+ context 'on a new record' do
54
+ before do
55
+ @obj.stubs(new_record?: true)
56
+ adapter.stubs(create: true)
57
+ end
58
+
59
+ it 'should call the before_validation callback' do
60
+ @obj.expects(:before_validation_callback)
61
+ @obj.save
62
+ end
63
+ it 'should call the after_validation callback' do
64
+ @obj.expects(:after_validation_callback)
65
+ @obj.save
66
+ end
67
+
68
+ it 'should call the before_create callback' do
69
+ @obj.expects(:before_create_callback)
70
+ @obj.save
71
+ end
72
+ it 'should call the after_create callback' do
73
+ @obj.expects(:after_create_callback)
74
+ @obj.save
75
+ end
76
+ it 'should call the around_create callback' do
77
+ @obj.expects(:around_create_callback).yields
78
+ @obj.save
79
+ end
80
+
81
+ it 'should call the before_save callback' do
82
+ @obj.expects(:before_save_callback)
83
+ @obj.save
84
+ end
85
+ it 'should call the after_save callback' do
86
+ @obj.expects(:after_save_callback)
87
+ @obj.save
88
+ end
89
+ it 'should call the around_save callback' do
90
+ @obj.expects(:around_save_callback).yields
91
+ @obj.save
92
+ end
93
+
94
+ it 'should not call the before_update_callback' do
95
+ @obj.expects(:before_update_callback).never
96
+ @obj.save
97
+ end
98
+ it 'should not call the after_update_callback' do
99
+ @obj.expects(:after_update_callback).never
100
+ @obj.save
101
+ end
102
+ it 'should not call the around_update_callback' do
103
+ @obj.expects(:around_update_callback).never
104
+ @obj.save
105
+ end
106
+
107
+ it 'should not call the before_destroy_callback' do
108
+ @obj.expects(:before_destroy_callback).never
109
+ @obj.save
110
+ end
111
+ it 'should not call the after_destroy_callback' do
112
+ @obj.expects(:after_destroy_callback).never
113
+ @obj.save
114
+ end
115
+ it 'should not call the around_destroy_callback' do
116
+ @obj.expects(:around_destroy_callback).never
117
+ @obj.save
118
+ end
119
+ end
120
+
121
+ context 'on an existing record' do
122
+ before do
123
+ @obj.stubs(new_record?: false)
124
+ adapter.stubs(update: true)
125
+ end
126
+
127
+ it 'should call the before_validation callback' do
128
+ @obj.expects(:before_validation_callback)
129
+ @obj.save
130
+ end
131
+ it 'should call the after_validation callback' do
132
+ @obj.expects(:after_validation_callback)
133
+ @obj.save
134
+ end
135
+
136
+ it 'should not call the before_create callback' do
137
+ @obj.expects(:before_create_callback).never
138
+ @obj.save
139
+ end
140
+ it 'should not call the after_create callback' do
141
+ @obj.expects(:after_create_callback).never
142
+ @obj.save
143
+ end
144
+ it 'should not call the around_create callback' do
145
+ @obj.expects(:around_create_callback).never
146
+ @obj.save
147
+ end
148
+
149
+ it 'should call the before_save callback' do
150
+ @obj.expects(:before_save_callback)
151
+ @obj.save
152
+ end
153
+ it 'should call the after_save callback' do
154
+ @obj.expects(:after_save_callback)
155
+ @obj.save
156
+ end
157
+ it 'should call the around_save callback' do
158
+ @obj.expects(:around_save_callback).yields
159
+ @obj.save
160
+ end
161
+
162
+ it 'should call the before_update_callback' do
163
+ @obj.expects(:before_update_callback)
164
+ @obj.save
165
+ end
166
+ it 'should call the after_update_callback' do
167
+ @obj.expects(:after_update_callback)
168
+ @obj.save
169
+ end
170
+ it 'should call the around_update_callback' do
171
+ @obj.expects(:around_update_callback)
172
+ @obj.save
173
+ end
174
+
175
+ it 'should not call the before_destroy_callback' do
176
+ @obj.expects(:before_destroy_callback).never
177
+ @obj.save
178
+ end
179
+ it 'should not call the after_destroy_callback' do
180
+ @obj.expects(:after_destroy_callback).never
181
+ @obj.save
182
+ end
183
+ it 'should not call the around_destroy_callback' do
184
+ @obj.expects(:around_destroy_callback).never
185
+ @obj.save
186
+ end
187
+ end
188
+ end
189
+
190
+ describe 'destroy' do
191
+ before do
192
+ @obj.stubs(new_record?: false)
193
+ adapter.stubs(destroy: true)
194
+ end
195
+
196
+ it 'should not call the before_validation callback' do
197
+ @obj.expects(:before_validation_callback).never
198
+ @obj.destroy
199
+ end
200
+ it 'should not call the after_validation callback' do
201
+ @obj.expects(:after_validation_callback).never
202
+ @obj.destroy
203
+ end
204
+
205
+ it 'should not call the before_create callback' do
206
+ @obj.expects(:before_create_callback).never
207
+ @obj.destroy
208
+ end
209
+ it 'should not call the after_create callback' do
210
+ @obj.expects(:after_create_callback).never
211
+ @obj.destroy
212
+ end
213
+ it 'should not call the around_create callback' do
214
+ @obj.expects(:around_create_callback).never
215
+ @obj.destroy
216
+ end
217
+
218
+ it 'should not call the before_save callback' do
219
+ @obj.expects(:before_save_callback).never
220
+ @obj.destroy
221
+ end
222
+ it 'should not call the after_save callback' do
223
+ @obj.expects(:after_save_callback).never
224
+ @obj.destroy
225
+ end
226
+ it 'should not call the around_save callback' do
227
+ @obj.expects(:around_save_callback).never
228
+ @obj.destroy
229
+ end
230
+
231
+ it 'should not call the before_update_callback' do
232
+ @obj.expects(:before_update_callback).never
233
+ @obj.destroy
234
+ end
235
+ it 'should not call the after_update_callback' do
236
+ @obj.expects(:after_update_callback).never
237
+ @obj.destroy
238
+ end
239
+ it 'should not call the around_update_callback' do
240
+ @obj.expects(:around_update_callback).never
241
+ @obj.destroy
242
+ end
243
+
244
+ it 'should call the before_destroy_callback' do
245
+ @obj.expects(:before_destroy_callback)
246
+ @obj.destroy
247
+ end
248
+ it 'should call the after_destroy_callback' do
249
+ @obj.expects(:after_destroy_callback)
250
+ @obj.destroy
251
+ end
252
+ it 'should call the around_destroy_callback' do
253
+ @obj.expects(:around_destroy_callback).yields
254
+ @obj.destroy
255
+ end
256
+ end
257
+ end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NinjaModel::Persistence do
4
+ let(:adapter) { mock('Adapter') }
4
5
  class PersistenceModel < NinjaModel::Base
5
6
  attribute :testing, :integer
6
7
  end
7
8
 
8
9
  before {
9
10
  @obj = PersistenceModel.new
10
- @adapter = mock('Adapter')
11
- @obj.class.stubs(:adapter).returns(@adapter)
11
+ @obj.class.stubs(adapter: adapter)
12
12
  }
13
13
  subject { @obj }
14
14
  it { should respond_to(:save) }
@@ -25,94 +25,64 @@ describe NinjaModel::Persistence do
25
25
  its(:destroyed?) { should be_false }
26
26
 
27
27
  describe 'save' do
28
- before { subject.stubs(:run_callbacks).yields(true) }
29
- it 'should run the save callbacks' do
30
- subject.expects(:run_callbacks).with(:save)
31
- subject.save
32
- end
33
-
34
28
  it 'should call create for a new record' do
35
- subject.stubs(:new_record?).returns(true)
29
+ subject.stubs(new_record?: true)
36
30
  subject.expects(:create)
37
31
  subject.save
38
32
  end
39
33
 
40
34
  it 'should call update for a persisted record' do
41
- subject.stubs(:new_record?).returns(false)
35
+ subject.stubs(new_record?: false)
42
36
  subject.expects(:update)
43
37
  subject.save
44
38
  end
45
39
 
46
40
  it 'should clear the changed attributes after successful save' do
47
41
  attributes = {}
48
- subject.stubs(:changed_attributes).returns(attributes)
49
- subject.stubs(:new_record?).returns(false)
50
- subject.stubs(:update).returns(true)
42
+ subject.stubs(changed_attributes: attributes, new_record?: false, update: true)
51
43
  attributes.expects(:clear)
52
44
  subject.save
53
45
  end
54
46
 
55
47
  it 'should not clear the changed attributes after unsuccessful save' do
56
48
  attributes = {}
57
- subject.stubs(:changed_attributes).returns(attributes)
58
- subject.stubs(:new_record?).returns(false)
59
- subject.stubs(:update).returns(false)
49
+ subject.stubs(changed_attributes: attributes, new_record?: false, update: false)
60
50
  attributes.expects(:clear).never
61
51
  subject.save
62
52
  end
63
53
  end
64
54
 
65
55
  describe 'create' do
66
- before {
67
- subject.stubs(:run_callbacks).yields(true)
68
- @adapter.stubs(:create).returns(true)
69
- }
70
- it 'should run the create callbacks' do
71
- subject.expects(:run_callbacks).with(:create)
72
- subject.create
73
- end
74
56
  it 'should call create on the adapter' do
75
- @adapter.expects(:create).with(subject)
57
+ adapter.expects(:create).with(subject)
76
58
  subject.create
77
59
  end
78
60
  it 'should update the persisted status' do
61
+ adapter.stubs(create: true)
79
62
  subject.create
80
63
  subject.persisted?.should be_true
81
64
  end
82
65
  end
83
66
 
84
67
  describe 'update' do
85
- before {
86
- subject.stubs(:run_callbacks).yields(true)
87
- @adapter.stubs(:update).returns(true)
88
- }
89
- it 'should run the update callbacks' do
90
- subject.expects(:run_callbacks).with(:update)
91
- subject.update
92
- end
93
68
  it 'should call update on the adapter' do
94
- @adapter.expects(:update).with(subject)
69
+ adapter.expects(:update).with(subject)
95
70
  subject.update
96
71
  end
97
72
  end
98
73
 
99
74
  describe 'destroy' do
100
- before {
101
- @adapter.stubs(:destroy).returns(true)
102
- }
103
- it 'should run the destroy callbacks' do
104
- subject.expects(:run_callbacks).with(:destroy)
105
- subject.destroy
106
- end
107
75
  it 'should call destroy on the adapter' do
108
- @adapter.expects(:destroy).with(subject)
76
+ adapter.expects(:destroy).with(subject)
109
77
  subject.destroy
110
78
  end
111
79
  it 'should update the destroyed? status' do
80
+ adapter.stubs(destroy: true)
112
81
  subject.destroy
113
82
  subject.destroyed?.should be_true
114
83
  end
115
84
  it 'should not be persisted afterwards' do
85
+ adapter.stubs(destroy: true)
116
86
  subject.destroy
117
87
  subject.persisted?.should be_false
118
88
  end
@@ -120,7 +90,7 @@ describe NinjaModel::Persistence do
120
90
 
121
91
  describe 'reload' do
122
92
  it 'should call reload on the adapter' do
123
- @adapter.expects(:reload).with(subject)
93
+ adapter.expects(:reload).with(subject)
124
94
  subject.reload
125
95
  end
126
96
  end
@@ -128,7 +98,7 @@ describe NinjaModel::Persistence do
128
98
  describe 'update_attributes' do
129
99
  it 'update the attributes hash and save' do
130
100
  subject.expects(:save)
131
- subject.update_attributes(:testing => 2)
101
+ subject.update_attributes(testing: 2)
132
102
  subject.testing.should eql(2)
133
103
  end
134
104
  end
@@ -14,5 +14,10 @@ describe NinjaModel::Validation do
14
14
  it { should respond_to(:valid?) }
15
15
 
16
16
  describe 'save' do
17
+ it 'should run the validation callbacks' do
18
+ subject.expects(:run_callbacks).with(:validation).yields
19
+ subject.expects(:run_callbacks).with(:validate)
20
+ subject.save
21
+ end
17
22
  end
18
23
  end
@@ -4,8 +4,7 @@ FactoryGirl.define do
4
4
  sequence(:name) { |n| "Name #{n}" }
5
5
  to_create { |model|
6
6
  model.write_attribute(:id, 1)
7
- model.stubs(:persisted?).returns(true)
8
- model.stubs(:new_record?).returns(false)
7
+ model.stubs(persisted?: true, new_record?: false)
9
8
  }
10
9
  end
11
10
  end
@@ -4,8 +4,7 @@ FactoryGirl.define do
4
4
  sequence(:text) { |n| "Body #{n}" }
5
5
  to_create { |model|
6
6
  model.write_attribute(:id, 1)
7
- model.stubs(:persisted?).returns(true)
8
- model.stubs(:new_record?).returns(false)
7
+ model.stubs(persisted?: true, new_record?: false)
9
8
  }
10
9
  end
11
10
  end
@@ -5,8 +5,7 @@ FactoryGirl.define do
5
5
  published false
6
6
  to_create { |model|
7
7
  model.write_attribute(:id, 1)
8
- model.stubs(:persisted?).returns(true)
9
- model.stubs(:new_record?).returns(false)
8
+ model.stubs(persisted?: true, new_record?: false)
10
9
  }
11
10
  end
12
11
  end
metadata CHANGED
@@ -1,136 +1,132 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ninja-model
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.4
4
5
  prerelease:
5
- version: 0.9.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Josh Williams
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-11-08 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-07-04 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: activerecord
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &16193800 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
18
+ requirements:
20
19
  - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 3.1.0
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.12
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *16193800
25
+ - !ruby/object:Gem::Dependency
27
26
  name: rake
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &16192980 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 0.9.2
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *16192980
36
+ - !ruby/object:Gem::Dependency
38
37
  name: rspec
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &16192100 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
40
+ requirements:
42
41
  - - ~>
43
- - !ruby/object:Gem::Version
44
- version: 2.8.0
42
+ - !ruby/object:Gem::Version
43
+ version: 2.13.0
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *16192100
47
+ - !ruby/object:Gem::Dependency
49
48
  name: mocha
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &16191220 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
51
+ requirements:
53
52
  - - ~>
54
- - !ruby/object:Gem::Version
55
- version: 0.10.0
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.0
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *16191220
58
+ - !ruby/object:Gem::Dependency
60
59
  name: guard-rspec
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &16177320 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
62
+ requirements:
64
63
  - - ~>
65
- - !ruby/object:Gem::Version
66
- version: 0.5.10
64
+ - !ruby/object:Gem::Version
65
+ version: 3.0.0
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *16177320
69
+ - !ruby/object:Gem::Dependency
71
70
  name: libnotify
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &16176640 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
73
+ requirements:
75
74
  - - ~>
76
- - !ruby/object:Gem::Version
75
+ - !ruby/object:Gem::Version
77
76
  version: 0.6.0
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *16176640
80
+ - !ruby/object:Gem::Dependency
82
81
  name: yard
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &16175840 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
84
+ requirements:
86
85
  - - ~>
87
- - !ruby/object:Gem::Version
86
+ - !ruby/object:Gem::Version
88
87
  version: 0.7.4
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *16175840
91
+ - !ruby/object:Gem::Dependency
93
92
  name: redcarpet
94
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ requirement: &16174900 !ruby/object:Gem::Requirement
95
94
  none: false
96
- requirements:
95
+ requirements:
97
96
  - - ~>
98
- - !ruby/object:Gem::Version
97
+ - !ruby/object:Gem::Version
99
98
  version: 2.0.0
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *16174900
102
+ - !ruby/object:Gem::Dependency
104
103
  name: sqlite3
105
- requirement: &id009 !ruby/object:Gem::Requirement
104
+ requirement: &16174300 !ruby/object:Gem::Requirement
106
105
  none: false
107
- requirements:
106
+ requirements:
108
107
  - - ~>
109
- - !ruby/object:Gem::Version
108
+ - !ruby/object:Gem::Version
110
109
  version: 1.3.5
111
110
  type: :development
112
111
  prerelease: false
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
112
+ version_requirements: *16174300
113
+ - !ruby/object:Gem::Dependency
115
114
  name: factory_girl
116
- requirement: &id010 !ruby/object:Gem::Requirement
115
+ requirement: &16173560 !ruby/object:Gem::Requirement
117
116
  none: false
118
- requirements:
117
+ requirements:
119
118
  - - ~>
120
- - !ruby/object:Gem::Version
121
- version: 2.5.0
119
+ - !ruby/object:Gem::Version
120
+ version: 4.2.0
122
121
  type: :development
123
122
  prerelease: false
124
- version_requirements: *id010
123
+ version_requirements: *16173560
125
124
  description: Pseudo-ORM for Ruby/Rails with an ActiveRecord-like interface
126
125
  email: theprime@codingprime.com
127
126
  executables: []
128
-
129
127
  extensions: []
130
-
131
128
  extra_rdoc_files: []
132
-
133
- files:
129
+ files:
134
130
  - .gitignore
135
131
  - .rvmrc
136
132
  - Gemfile
@@ -194,6 +190,7 @@ files:
194
190
  - spec/lib/ninja_model/attribute_methods_spec.rb
195
191
  - spec/lib/ninja_model/attribute_spec.rb
196
192
  - spec/lib/ninja_model/base_spec.rb
193
+ - spec/lib/ninja_model/callbacks_spec.rb
197
194
  - spec/lib/ninja_model/identity_spec.rb
198
195
  - spec/lib/ninja_model/persistence_spec.rb
199
196
  - spec/lib/ninja_model/predicate_spec.rb
@@ -222,38 +219,35 @@ files:
222
219
  - spec/support/matchers/convert.rb
223
220
  homepage: http://github.com/t3hpr1m3/ninja-model.git
224
221
  licenses: []
225
-
226
222
  post_install_message:
227
223
  rdoc_options: []
228
-
229
- require_paths:
224
+ require_paths:
230
225
  - lib
231
- required_ruby_version: !ruby/object:Gem::Requirement
226
+ required_ruby_version: !ruby/object:Gem::Requirement
232
227
  none: false
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- hash: 483263405
237
- segments:
228
+ requirements:
229
+ - - ! '>='
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ segments:
238
233
  - 0
239
- version: "0"
240
- required_rubygems_version: !ruby/object:Gem::Requirement
234
+ hash: 2346852410491861994
235
+ required_rubygems_version: !ruby/object:Gem::Requirement
241
236
  none: false
242
- requirements:
243
- - - ">="
244
- - !ruby/object:Gem::Version
245
- hash: 483263405
246
- segments:
237
+ requirements:
238
+ - - ! '>='
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
241
+ segments:
247
242
  - 0
248
- version: "0"
243
+ hash: 2346852410491861994
249
244
  requirements: []
250
-
251
245
  rubyforge_project: ninja-model
252
- rubygems_version: 1.8.24
246
+ rubygems_version: 1.8.10
253
247
  signing_key:
254
248
  specification_version: 3
255
249
  summary: Pseudo-ORM for Ruby
256
- test_files:
250
+ test_files:
257
251
  - spec/db/schema.rb
258
252
  - spec/lib/ninja_model/adapters/abstract_adapter_spec.rb
259
253
  - spec/lib/ninja_model/adapters/adapter_manager_spec.rb
@@ -265,6 +259,7 @@ test_files:
265
259
  - spec/lib/ninja_model/attribute_methods_spec.rb
266
260
  - spec/lib/ninja_model/attribute_spec.rb
267
261
  - spec/lib/ninja_model/base_spec.rb
262
+ - spec/lib/ninja_model/callbacks_spec.rb
268
263
  - spec/lib/ninja_model/identity_spec.rb
269
264
  - spec/lib/ninja_model/persistence_spec.rb
270
265
  - spec/lib/ninja_model/predicate_spec.rb