mongodb_model 0.0.1 → 0.0.2

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.
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'validatable'
3
+
4
+ describe "Integration with validatable2" do
5
+ with_mongo_model
6
+
7
+ before do
8
+ class Unit
9
+ inherit Mongo::Model
10
+ collection :units
11
+
12
+ include Validatable
13
+
14
+ attr_accessor :name, :status
15
+
16
+ validates_presence_of :name
17
+ end
18
+ end
19
+
20
+ after{remove_constants :Unit}
21
+
22
+ it "ActiveModel integration smoke test" do
23
+ unit = Unit.new
24
+ unit.should_not be_valid
25
+ unit.errors.size.should == 1
26
+ unit.errors.first.first.should == :name
27
+ unit.save.should be_false
28
+
29
+ unit.name = 'Zeratul'
30
+ unit.should be_valid
31
+ unit.errors.should be_empty
32
+ unit.save.should be_true
33
+ end
34
+
35
+ it "should not save errors as instance variables" do
36
+ unit = Unit.new
37
+ unit.valid?
38
+ unit.instance_variables.select{|iv_name| iv_name !~ /^@_/}.should be_empty
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Validations" do
4
+ with_mongo_model
5
+
6
+ before do
7
+ class Unit
8
+ inherit Mongo::Model
9
+ collection :units
10
+
11
+ attr_accessor :errors
12
+
13
+ attr_accessor :name
14
+ end
15
+ end
16
+ after{remove_constants :Unit}
17
+
18
+ it "should not save model with errors" do
19
+ unit = Unit.build name: 'Zeratul'
20
+ unit.save.should be_true
21
+
22
+ unit.errors = []
23
+ unit.save.should be_true
24
+
25
+ unit.errors = ['hairy error']
26
+ unit.save.should be_false
27
+
28
+ unit.errors = {name: 'hairy error'}
29
+ unit.save.should be_false
30
+ end
31
+
32
+ it "should check :errors only and ignore valid? method" do
33
+ unit = Unit.build name: 'Zeratul'
34
+ unit.should_not_receive(:valid?)
35
+ unit.save.should be_true
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,51 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2011-08-28 00:00:00.000000000Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: i18n
16
+ requirement: &2785140 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0.5'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2785140
25
+ - !ruby/object:Gem::Dependency
26
+ name: validatable2
27
+ requirement: &2784840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2784840
36
+ - !ruby/object:Gem::Dependency
37
+ name: mongodb
38
+ requirement: &2784550 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2784550
47
+ - !ruby/object:Gem::Dependency
48
+ name: ruby_ext
49
+ requirement: &2784260 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2784260
14
58
  description:
15
59
  email:
16
60
  executables: []
@@ -19,6 +63,31 @@ extra_rdoc_files: []
19
63
  files:
20
64
  - Rakefile
21
65
  - readme.md
66
+ - lib/mongodb_model/assignment.rb
67
+ - lib/mongodb_model/attribute_convertors.rb
68
+ - lib/mongodb_model/callbacks.rb
69
+ - lib/mongodb_model/crud.rb
70
+ - lib/mongodb_model/db.rb
71
+ - lib/mongodb_model/gems.rb
72
+ - lib/mongodb_model/misc.rb
73
+ - lib/mongodb_model/model.rb
74
+ - lib/mongodb_model/query.rb
75
+ - lib/mongodb_model/scope.rb
76
+ - lib/mongodb_model/spec.rb
77
+ - lib/mongodb_model/support/types.rb
78
+ - lib/mongodb_model/validation.rb
79
+ - lib/mongodb_model.rb
80
+ - spec/assignment_spec.rb
81
+ - spec/attribute_convertors_spec.rb
82
+ - spec/callbacks_spec.rb
83
+ - spec/crud_spec.rb
84
+ - spec/db_spec.rb
85
+ - spec/misc_spec.rb
86
+ - spec/query_spec.rb
87
+ - spec/scope_spec.rb
88
+ - spec/spec_helper.rb
89
+ - spec/validatable2_spec.rb
90
+ - spec/validation_spec.rb
22
91
  homepage: http://github.com/alexeypetrushin/mongodb_model
23
92
  licenses: []
24
93
  post_install_message: