mongo_mapper 0.13.1 → 0.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +13 -5
  2. data/README.rdoc +3 -6
  3. data/lib/mongo_mapper.rb +1 -0
  4. data/lib/mongo_mapper/document.rb +2 -0
  5. data/lib/mongo_mapper/extensions/array.rb +14 -6
  6. data/lib/mongo_mapper/extensions/hash.rb +15 -3
  7. data/lib/mongo_mapper/extensions/object.rb +4 -0
  8. data/lib/mongo_mapper/extensions/string.rb +13 -5
  9. data/lib/mongo_mapper/plugins/accessible.rb +12 -11
  10. data/lib/mongo_mapper/plugins/associations.rb +7 -6
  11. data/lib/mongo_mapper/plugins/associations/base.rb +13 -12
  12. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +9 -8
  13. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +12 -11
  14. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +4 -4
  15. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +24 -23
  16. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +18 -16
  17. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +55 -48
  18. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +14 -13
  19. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +7 -6
  20. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +7 -5
  21. data/lib/mongo_mapper/plugins/associations/one_as_proxy.rb +14 -11
  22. data/lib/mongo_mapper/plugins/associations/one_embedded_polymorphic_proxy.rb +14 -13
  23. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +9 -9
  24. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +27 -26
  25. data/lib/mongo_mapper/plugins/associations/proxy.rb +29 -26
  26. data/lib/mongo_mapper/plugins/callbacks.rb +13 -0
  27. data/lib/mongo_mapper/plugins/counter_cache.rb +23 -4
  28. data/lib/mongo_mapper/plugins/dirty.rb +2 -2
  29. data/lib/mongo_mapper/plugins/dynamic_querying.rb +10 -9
  30. data/lib/mongo_mapper/plugins/dynamic_querying/dynamic_finder.rb +17 -16
  31. data/lib/mongo_mapper/plugins/embedded_callbacks.rb +1 -1
  32. data/lib/mongo_mapper/plugins/identity_map.rb +1 -1
  33. data/lib/mongo_mapper/plugins/indexes.rb +1 -1
  34. data/lib/mongo_mapper/plugins/keys.rb +158 -158
  35. data/lib/mongo_mapper/plugins/keys/key.rb +16 -10
  36. data/lib/mongo_mapper/plugins/keys/static.rb +45 -0
  37. data/lib/mongo_mapper/plugins/modifiers.rb +27 -26
  38. data/lib/mongo_mapper/plugins/partial_updates.rb +86 -0
  39. data/lib/mongo_mapper/plugins/persistence.rb +7 -6
  40. data/lib/mongo_mapper/plugins/protected.rb +6 -5
  41. data/lib/mongo_mapper/plugins/querying.rb +80 -43
  42. data/lib/mongo_mapper/plugins/querying/decorated_plucky_query.rb +14 -9
  43. data/lib/mongo_mapper/plugins/scopes.rb +78 -7
  44. data/lib/mongo_mapper/plugins/timestamps.rb +1 -0
  45. data/lib/mongo_mapper/plugins/validations.rb +0 -0
  46. data/lib/mongo_mapper/version.rb +1 -1
  47. data/lib/rails/generators/mongo_mapper/config/config_generator.rb +12 -13
  48. data/lib/rails/generators/mongo_mapper/model/model_generator.rb +9 -9
  49. data/spec/functional/accessible_spec.rb +12 -12
  50. data/spec/functional/associations/belongs_to_polymorphic_proxy_spec.rb +11 -11
  51. data/spec/functional/associations/belongs_to_proxy_spec.rb +14 -15
  52. data/spec/functional/associations/in_array_proxy_spec.rb +6 -6
  53. data/spec/functional/associations/many_documents_proxy_spec.rb +89 -18
  54. data/spec/functional/associations/many_embedded_polymorphic_proxy_spec.rb +11 -11
  55. data/spec/functional/associations/many_embedded_proxy_spec.rb +1 -1
  56. data/spec/functional/associations/one_as_proxy_spec.rb +14 -14
  57. data/spec/functional/associations/one_embedded_polymorphic_proxy_spec.rb +9 -9
  58. data/spec/functional/associations/one_embedded_proxy_spec.rb +3 -3
  59. data/spec/functional/associations/one_proxy_spec.rb +14 -14
  60. data/spec/functional/caching_spec.rb +8 -8
  61. data/spec/functional/callbacks_spec.rb +87 -0
  62. data/spec/functional/counter_cache_spec.rb +89 -0
  63. data/spec/functional/dirty_spec.rb +41 -41
  64. data/spec/functional/document_spec.rb +3 -3
  65. data/spec/functional/embedded_document_spec.rb +18 -18
  66. data/spec/functional/identity_map_spec.rb +28 -15
  67. data/spec/functional/indexes_spec.rb +4 -4
  68. data/spec/functional/keys_spec.rb +12 -3
  69. data/spec/functional/logger_spec.rb +1 -1
  70. data/spec/functional/modifiers_spec.rb +2 -2
  71. data/spec/functional/partial_updates_spec.rb +577 -0
  72. data/spec/functional/protected_spec.rb +13 -13
  73. data/spec/functional/querying_spec.rb +11 -10
  74. data/spec/functional/safe_spec.rb +2 -2
  75. data/spec/functional/sci_spec.rb +3 -3
  76. data/spec/functional/scopes_spec.rb +234 -1
  77. data/spec/functional/static_keys_spec.rb +153 -0
  78. data/spec/functional/stats_spec.rb +0 -4
  79. data/spec/functional/touch_spec.rb +1 -1
  80. data/spec/functional/validations_spec.rb +59 -57
  81. data/spec/quality_spec.rb +1 -1
  82. data/spec/spec_helper.rb +7 -3
  83. data/spec/support/matchers.rb +4 -13
  84. data/spec/unit/associations/base_spec.rb +12 -12
  85. data/spec/unit/associations/belongs_to_association_spec.rb +2 -2
  86. data/spec/unit/associations/many_association_spec.rb +2 -2
  87. data/spec/unit/associations/one_association_spec.rb +2 -2
  88. data/spec/unit/associations/proxy_spec.rb +13 -15
  89. data/spec/unit/document_spec.rb +5 -5
  90. data/spec/unit/dynamic_finder_spec.rb +8 -8
  91. data/spec/unit/embedded_document_spec.rb +14 -14
  92. data/spec/unit/extensions_spec.rb +17 -17
  93. data/spec/unit/identity_map_middleware_spec.rb +5 -5
  94. data/spec/unit/key_spec.rb +24 -21
  95. data/spec/unit/keys_spec.rb +5 -5
  96. data/spec/unit/mongo_mapper_spec.rb +26 -26
  97. data/spec/unit/rails_spec.rb +2 -2
  98. data/spec/unit/serialization_spec.rb +1 -1
  99. data/spec/unit/time_zones_spec.rb +2 -2
  100. data/spec/unit/validations_spec.rb +28 -15
  101. metadata +16 -14
  102. data/lib/mongo_mapper/connections/10gen.rb +0 -0
  103. data/lib/mongo_mapper/connections/moped.rb +0 -0
@@ -1,19 +1,10 @@
1
1
  RSpec::Matchers.define :have_error_on do |*args|
2
- @message = nil
3
- @attributes = [args]
4
-
5
- chain :or do |*args|
6
- @attributes << args
7
- end
8
-
9
2
  match do |model|
3
+ field = args.dup.shift
4
+ error_messages = args
5
+
10
6
  model.valid?
11
- @has_errors = @attributes.detect {|attribute| model.errors[attribute[0]].present? }
12
- if @message
13
- !!@has_errors && model.errors[@has_errors[0]].include?(@has_errors[1])
14
- else
15
- !!@has_errors
16
- end
7
+ model.errors[field].any?
17
8
  end
18
9
  end
19
10
 
@@ -12,7 +12,7 @@ module AssociationSpec
12
12
 
13
13
  it "should also allow options when initializing" do
14
14
  base = ManyAssociation.new(:foos, :polymorphic => true)
15
- base.options[:polymorphic].should be_true
15
+ base.options[:polymorphic].should be_truthy
16
16
  end
17
17
 
18
18
  context "klass" do
@@ -28,31 +28,31 @@ module AssociationSpec
28
28
 
29
29
  context "polymorphic?" do
30
30
  it "should be true if polymorphic" do
31
- ManyAssociation.new(:foos, :polymorphic => true).polymorphic?.should be_true
31
+ ManyAssociation.new(:foos, :polymorphic => true).polymorphic?.should be_truthy
32
32
  end
33
33
 
34
34
  it "should be false if not polymorphic" do
35
- ManyAssociation.new(:bars).polymorphic?.should be_false
35
+ ManyAssociation.new(:bars).polymorphic?.should be_falsey
36
36
  end
37
37
  end
38
38
 
39
39
  context "as?" do
40
40
  it "should be true if one" do
41
- OneAssociation.new(:foo, :as => :commentable).as?.should be_true
41
+ OneAssociation.new(:foo, :as => :commentable).as?.should be_truthy
42
42
  end
43
43
 
44
44
  it "should be false if not one" do
45
- ManyAssociation.new(:foo).as?.should be_false
45
+ ManyAssociation.new(:foo).as?.should be_falsey
46
46
  end
47
47
  end
48
48
 
49
49
  context "in_array?" do
50
50
  it "should be true if one" do
51
- OneAssociation.new(:foo, :in => :list_ids).in_array?.should be_true
51
+ OneAssociation.new(:foo, :in => :list_ids).in_array?.should be_truthy
52
52
  end
53
53
 
54
54
  it "should be false if not one" do
55
- ManyAssociation.new(:foo).in_array?.should be_false
55
+ ManyAssociation.new(:foo).in_array?.should be_falsey
56
56
  end
57
57
  end
58
58
 
@@ -98,15 +98,15 @@ module AssociationSpec
98
98
  context "embeddable?" do
99
99
  it "should be true if class is embeddable" do
100
100
  base = ManyAssociation.new(:medias)
101
- base.embeddable?.should be_true
101
+ base.embeddable?.should be_truthy
102
102
  end
103
103
 
104
104
  it "should be false if class is not embeddable" do
105
105
  base = ManyAssociation.new(:statuses)
106
- base.embeddable?.should be_false
106
+ base.embeddable?.should be_falsey
107
107
 
108
108
  base = BelongsToAssociation.new(:project)
109
- base.embeddable?.should be_false
109
+ base.embeddable?.should be_falsey
110
110
  end
111
111
  end
112
112
 
@@ -134,11 +134,11 @@ module AssociationSpec
134
134
 
135
135
  context "touch?" do
136
136
  it "should be true if touch" do
137
- BelongsToAssociation.new(:car, :touch => true).touch?.should be_true
137
+ BelongsToAssociation.new(:car, :touch => true).touch?.should be_truthy
138
138
  end
139
139
 
140
140
  it "should be false if not touch" do
141
- BelongsToAssociation.new(:car).touch?.should be_false
141
+ BelongsToAssociation.new(:car).touch?.should be_falsey
142
142
  end
143
143
  end
144
144
 
@@ -18,12 +18,12 @@ module BelongsToAssociation
18
18
  context "embeddable?" do
19
19
  it "should be false even if class is embeddable" do
20
20
  base = BelongsToAssociation.new(:address)
21
- base.embeddable?.should be_false
21
+ base.embeddable?.should be_falsey
22
22
  end
23
23
 
24
24
  it "should be false if class is not embeddable" do
25
25
  base = BelongsToAssociation.new(:project)
26
- base.embeddable?.should be_false
26
+ base.embeddable?.should be_falsey
27
27
  end
28
28
  end
29
29
  end
@@ -25,12 +25,12 @@ module ManyAssociationSpec
25
25
  context "embeddable?" do
26
26
  it "should be true if class is embeddable" do
27
27
  base = ManyAssociation.new(:medias)
28
- base.embeddable?.should be_true
28
+ base.embeddable?.should be_truthy
29
29
  end
30
30
 
31
31
  it "should be false if class is not embeddable" do
32
32
  base = ManyAssociation.new(:statuses)
33
- base.embeddable?.should be_false
33
+ base.embeddable?.should be_falsey
34
34
  end
35
35
  end
36
36
 
@@ -14,12 +14,12 @@ module OneAssociationSpec
14
14
  context "embeddable?" do
15
15
  it "should be true if class is embeddable" do
16
16
  base = OneAssociation.new(:media)
17
- base.embeddable?.should be_true
17
+ base.embeddable?.should be_truthy
18
18
  end
19
19
 
20
20
  it "should be false if class is not embeddable" do
21
21
  base = OneAssociation.new(:project)
22
- base.embeddable?.should be_false
22
+ base.embeddable?.should be_falsey
23
23
  end
24
24
  end
25
25
 
@@ -18,10 +18,8 @@ end
18
18
 
19
19
  describe "Proxy" do
20
20
  before do
21
- @owner = double('owner')
22
- @owner.stub(:new?).and_return(false)
23
- @association = double('association')
24
- @association.stub(:options).and_return({:extend => []})
21
+ @owner = double('owner', :new? => false)
22
+ @association = double('association', :options => {:extend => []})
25
23
 
26
24
  @proxy = FakeProxy.new(@owner, @association)
27
25
  @nil_proxy = FakeNilProxy.new(@owner, @association)
@@ -39,40 +37,40 @@ describe "Proxy" do
39
37
 
40
38
  context "nil?" do
41
39
  it "should be true if nil" do
42
- @nil_proxy.nil?.should be_true
40
+ @nil_proxy.nil?.should be_truthy
43
41
  end
44
42
 
45
43
  it "should be false if not nil" do
46
- @proxy.nil?.should be_false
44
+ @proxy.nil?.should be_falsey
47
45
  end
48
46
  end
49
47
 
50
48
  context "blank?" do
51
49
  it "should be true if blank" do
52
- @blank_proxy.blank?.should be_true
53
- @nil_proxy.blank?.should be_true
50
+ @blank_proxy.blank?.should be_truthy
51
+ @nil_proxy.blank?.should be_truthy
54
52
  end
55
53
 
56
54
  it "should be false if not blank" do
57
- @proxy.blank?.should be_false
55
+ @proxy.blank?.should be_falsey
58
56
  end
59
57
  end
60
58
 
61
59
  context "present?" do
62
60
  it "should be true if present" do
63
- @proxy.present?.should be_true
61
+ @proxy.present?.should be_truthy
64
62
  end
65
63
 
66
64
  it "should be false if not present" do
67
- @blank_proxy.present?.should be_false
68
- @nil_proxy.present?.should be_false
65
+ @blank_proxy.present?.should be_falsey
66
+ @nil_proxy.present?.should be_falsey
69
67
  end
70
68
  end
71
69
 
72
70
  it "should delegate respond_to? to target" do
73
- @proxy.respond_to?(:each).should be_true
74
- @proxy.respond_to?(:size).should be_true
75
- @proxy.respond_to?(:gsub).should be_false
71
+ @proxy.respond_to?(:each).should be_truthy
72
+ @proxy.respond_to?(:size).should be_truthy
73
+ @proxy.respond_to?(:gsub).should be_falsey
76
74
  end
77
75
 
78
76
  it "should alias proxy owner to owner" do
@@ -8,7 +8,7 @@ describe "Document" do
8
8
  end
9
9
 
10
10
  it "should return false for embeddable" do
11
- Doc().embeddable?.should be_false
11
+ Doc().embeddable?.should be_falsey
12
12
  end
13
13
 
14
14
  it "should have logger method" do
@@ -122,8 +122,8 @@ describe "Document" do
122
122
  it "should use default values if defined for keys" do
123
123
  @document.key :active, Boolean, :default => true
124
124
 
125
- @document.new.active.should be_true
126
- @document.new(:active => false).active.should be_false
125
+ @document.new.active.should be_truthy
126
+ @document.new(:active => false).active.should be_falsey
127
127
  end
128
128
 
129
129
  it "should use default values if defined even when custom data type" do
@@ -147,14 +147,14 @@ describe "Document" do
147
147
 
148
148
  context "new?" do
149
149
  it "should be true if no id" do
150
- @document.new.new?.should be_true
150
+ @document.new.new?.should be_truthy
151
151
  end
152
152
 
153
153
  it "should be true if id but using custom id and not saved yet" do
154
154
  @document.key :_id, String
155
155
  doc = silence_stderr { @document.new }
156
156
  doc.id = '1234'
157
- doc.new?.should be_true
157
+ doc.new?.should be_truthy
158
158
  end
159
159
  end
160
160
 
@@ -10,28 +10,28 @@ describe "DynamicFinder" do
10
10
 
11
11
  context "found?" do
12
12
  it "should be true for find_by" do
13
- DynamicFinder.new(:find_by_foo).found?.should be_true
13
+ DynamicFinder.new(:find_by_foo).found?.should be_truthy
14
14
  end
15
15
 
16
16
  it "should be true for find_by with !" do
17
- DynamicFinder.new(:find_by_foo!).found?.should be_true
17
+ DynamicFinder.new(:find_by_foo!).found?.should be_truthy
18
18
  end
19
19
 
20
20
  it "should be true for find_all_by" do
21
- DynamicFinder.new(:find_all_by_foo).found?.should be_true
21
+ DynamicFinder.new(:find_all_by_foo).found?.should be_truthy
22
22
  end
23
23
 
24
24
  it "should be true for find_or_initialize_by" do
25
- DynamicFinder.new(:find_or_initialize_by_foo).found?.should be_true
25
+ DynamicFinder.new(:find_or_initialize_by_foo).found?.should be_truthy
26
26
  end
27
27
 
28
28
  it "should be true for find_or_create_by" do
29
- DynamicFinder.new(:find_or_create_by_foo).found?.should be_true
29
+ DynamicFinder.new(:find_or_create_by_foo).found?.should be_truthy
30
30
  end
31
31
 
32
32
  it "should be false for anything else" do
33
33
  [:foobar, :bazwick].each do |method|
34
- DynamicFinder.new(method).found?.should be_false
34
+ DynamicFinder.new(method).found?.should be_falsey
35
35
  end
36
36
  end
37
37
  end
@@ -65,7 +65,7 @@ describe "DynamicFinder" do
65
65
  end
66
66
 
67
67
  it "should set bang to false" do
68
- DynamicFinder.new(:find_by_foo).bang.should be_false
68
+ DynamicFinder.new(:find_by_foo).bang.should be_falsey
69
69
  end
70
70
  end
71
71
 
@@ -83,7 +83,7 @@ describe "DynamicFinder" do
83
83
  end
84
84
 
85
85
  it "should set bang to true" do
86
- DynamicFinder.new(:find_by_foo!).bang.should be_true
86
+ DynamicFinder.new(:find_by_foo!).bang.should be_truthy
87
87
  end
88
88
  end
89
89
 
@@ -66,12 +66,12 @@ describe "EmbeddedDocument" do
66
66
  end
67
67
 
68
68
  it "should know it is using object id" do
69
- @klass.using_object_id?.should be_true
69
+ @klass.using_object_id?.should be_truthy
70
70
  end
71
71
 
72
72
  it "should know it is not using object id if _id type is changed" do
73
73
  @klass.key :_id, String
74
- @klass.using_object_id?.should be_false
74
+ @klass.using_object_id?.should be_falsey
75
75
  end
76
76
  end
77
77
 
@@ -83,7 +83,7 @@ describe "EmbeddedDocument" do
83
83
  end
84
84
 
85
85
  it "should return false for embeddable" do
86
- EDoc().embeddable?.should be_true
86
+ EDoc().embeddable?.should be_truthy
87
87
  end
88
88
 
89
89
  context "#to_mongo" do
@@ -96,7 +96,7 @@ describe "EmbeddedDocument" do
96
96
  it "should convert to_mongo for other values" do
97
97
  doc = @klass.new(:foo => 'bar')
98
98
  to_mongo = @klass.to_mongo(doc)
99
- to_mongo.is_a?(Hash).should be_true
99
+ to_mongo.is_a?(Hash).should be_truthy
100
100
  to_mongo['foo'].should == 'bar'
101
101
  end
102
102
  end
@@ -115,7 +115,7 @@ describe "EmbeddedDocument" do
115
115
 
116
116
  it "should be instance if hash of attributes" do
117
117
  doc = @klass.from_mongo({:foo => 'bar'})
118
- doc.instance_of?(@klass).should be_true
118
+ doc.instance_of?(@klass).should be_truthy
119
119
  doc.foo.should == 'bar'
120
120
  end
121
121
  end
@@ -140,13 +140,13 @@ describe "EmbeddedDocument" do
140
140
  key = @document.key(:name, String, :required => true)
141
141
  key.name.should == 'name'
142
142
  key.type.should == String
143
- key.options[:required].should be_true
143
+ key.options[:required].should be_truthy
144
144
  end
145
145
 
146
146
  it "should work with name and options" do
147
147
  key = @document.key(:name, :required => true)
148
148
  key.name.should == 'name'
149
- key.options[:required].should be_true
149
+ key.options[:required].should be_truthy
150
150
  end
151
151
 
152
152
  it "should be tracked per document" do
@@ -206,7 +206,7 @@ describe "EmbeddedDocument" do
206
206
  end
207
207
 
208
208
  it "should not add anonymous objects to the ancestor tree" do
209
- OtherChild.ancestors.any? { |a| a.name.blank? }.should be_false
209
+ OtherChild.ancestors.any? { |a| a.name.blank? }.should be_falsey
210
210
  end
211
211
 
212
212
  it "should not include descendant keys" do
@@ -422,7 +422,7 @@ describe "EmbeddedDocument" do
422
422
  it "should create key and write value for missing key" do
423
423
  doc = @document.new
424
424
  doc[:foo] = 'string'
425
- doc.class.keys.include?('foo').should be_true
425
+ doc.class.keys.include?('foo').should be_truthy
426
426
  doc[:foo].should == 'string'
427
427
  end
428
428
 
@@ -550,9 +550,9 @@ describe "EmbeddedDocument" do
550
550
  context "checking if a keys value is present" do
551
551
  it "should work for defined keys" do
552
552
  doc = @document.new
553
- doc.name?.should be_false
553
+ doc.name?.should be_falsey
554
554
  doc.name = 'John'
555
- doc.name?.should be_true
555
+ doc.name?.should be_truthy
556
556
  end
557
557
 
558
558
  it "should raise no method error for undefined keys" do
@@ -590,16 +590,16 @@ describe "EmbeddedDocument" do
590
590
  end
591
591
 
592
592
  it "should be equal if id and class are the same" do
593
- (@document.new('_id' => @oid) == @document.new('_id' => @oid)).should be_true
593
+ (@document.new('_id' => @oid) == @document.new('_id' => @oid)).should be_truthy
594
594
  end
595
595
 
596
596
  it "should not be equal if class same but id different" do
597
- (@document.new('_id' => @oid) == @document.new('_id' => BSON::ObjectId.new)).should be_false
597
+ (@document.new('_id' => @oid) == @document.new('_id' => BSON::ObjectId.new)).should be_falsey
598
598
  end
599
599
 
600
600
  it "should not be equal if id same but class different" do
601
601
  another_document = Doc()
602
- (@document.new('_id' => @oid) == another_document.new('_id' => @oid)).should be_false
602
+ (@document.new('_id' => @oid) == another_document.new('_id' => @oid)).should be_falsey
603
603
  end
604
604
  end
605
605
 
@@ -21,11 +21,11 @@ describe "Support" do
21
21
 
22
22
  context "Binary.to_mongo" do
23
23
  it "should convert to binary if not binary" do
24
- Binary.to_mongo('asdfsadasdfs').is_a?(BSON::Binary).should be_true
24
+ Binary.to_mongo('asdfsadasdfs').is_a?(BSON::Binary).should be_truthy
25
25
  end
26
26
 
27
27
  it "should be binary if binary" do
28
- Binary.to_mongo(BSON::Binary.new('asdfsadasdfs')).is_a?(BSON::Binary).should be_true
28
+ Binary.to_mongo(BSON::Binary.new('asdfsadasdfs')).is_a?(BSON::Binary).should be_truthy
29
29
  end
30
30
 
31
31
  it "should be nil if nil" do
@@ -42,23 +42,23 @@ describe "Support" do
42
42
 
43
43
  context "Boolean.to_mongo" do
44
44
  it "should be true for true" do
45
- Boolean.to_mongo(true).should be_true
45
+ Boolean.to_mongo(true).should be_truthy
46
46
  end
47
47
 
48
48
  it "should be false for false" do
49
- Boolean.to_mongo(false).should be_false
49
+ Boolean.to_mongo(false).should be_falsey
50
50
  end
51
51
 
52
52
  it "should handle odd assortment of other values" do
53
- Boolean.to_mongo('true').should be_true
54
- Boolean.to_mongo('t').should be_true
55
- Boolean.to_mongo('1').should be_true
56
- Boolean.to_mongo(1).should be_true
53
+ Boolean.to_mongo('true').should be_truthy
54
+ Boolean.to_mongo('t').should be_truthy
55
+ Boolean.to_mongo('1').should be_truthy
56
+ Boolean.to_mongo(1).should be_truthy
57
57
 
58
- Boolean.to_mongo('false').should be_false
59
- Boolean.to_mongo('f').should be_false
60
- Boolean.to_mongo('0').should be_false
61
- Boolean.to_mongo(0).should be_false
58
+ Boolean.to_mongo('false').should be_falsey
59
+ Boolean.to_mongo('f').should be_falsey
60
+ Boolean.to_mongo('0').should be_falsey
61
+ Boolean.to_mongo(0).should be_falsey
62
62
  end
63
63
 
64
64
  it "should be nil for nil" do
@@ -68,11 +68,11 @@ describe "Support" do
68
68
 
69
69
  context "Boolean.from_mongo" do
70
70
  it "should be true for true" do
71
- Boolean.from_mongo(true).should be_true
71
+ Boolean.from_mongo(true).should be_truthy
72
72
  end
73
73
 
74
74
  it "should be false for false" do
75
- Boolean.from_mongo(false).should be_false
75
+ Boolean.from_mongo(false).should be_falsey
76
76
  end
77
77
 
78
78
  it "should be nil for nil" do
@@ -153,7 +153,7 @@ describe "Support" do
153
153
  it "should be hash if nil" do
154
154
  hash = Hash.from_mongo(nil)
155
155
  hash.should == {}
156
- hash.is_a?(HashWithIndifferentAccess).should be_true
156
+ hash.is_a?(HashWithIndifferentAccess).should be_truthy
157
157
  end
158
158
  end
159
159
 
@@ -207,7 +207,7 @@ describe "Support" do
207
207
  context "ObjectId#to_mongo" do
208
208
  it "should call class to_mongo with self" do
209
209
  object = Object.new
210
- object.class.should_receive(:to_mongo).with(object)
210
+ expect(object.class).to receive(:to_mongo).with(object)
211
211
  object.to_mongo
212
212
  end
213
213
  end
@@ -359,7 +359,7 @@ describe "Support" do
359
359
 
360
360
  time = Time.from_mongo(Time.utc(2009, 10, 1))
361
361
  time.should == Time.zone.local(2009, 9, 30, 14)
362
- time.is_a?(ActiveSupport::TimeWithZone).should be_true
362
+ time.is_a?(ActiveSupport::TimeWithZone).should be_truthy
363
363
 
364
364
  Time.zone = nil
365
365
  end