mongo_mapper-strict_keys 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,50 @@
|
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
require 'mongo_mapper/strict_keys/force_plugin'
|
|
4
|
+
|
|
5
|
+
describe 'MongoMapper::Plugins::StrictKeys -- Forced Plugin' do
|
|
6
|
+
class ForcedModel
|
|
7
|
+
include MongoMapper::Document
|
|
8
|
+
|
|
9
|
+
key :string_key, String
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'Instance attributes' do
|
|
13
|
+
before(:each) do
|
|
14
|
+
@fm = ForcedModel.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'attributes-as-methods' do
|
|
18
|
+
it 'should accept attributes-as-methods for pre-defined keys' do
|
|
19
|
+
lambda {
|
|
20
|
+
@fm.string_key = "I work!"
|
|
21
|
+
}.should_not raise_error
|
|
22
|
+
|
|
23
|
+
@fm.string_key.should == "I work!"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should reject attributes-as-methods for never-defined keys' do
|
|
27
|
+
lambda {
|
|
28
|
+
@fm.not_defined = 'blowed up'
|
|
29
|
+
}.should raise_error(NoMethodError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'attributes-in-brackets' do
|
|
34
|
+
it 'should accept attributes-in-brackets for pre-defined keys' do
|
|
35
|
+
lambda {
|
|
36
|
+
@fm[:string_key] = "I work!"
|
|
37
|
+
}.should_not raise_error
|
|
38
|
+
|
|
39
|
+
@fm[:string_key].should == "I work!"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should reject attributes-in-brackets for never-defined keys' do
|
|
43
|
+
lambda {
|
|
44
|
+
@fm[:not_defined] = 'blowed up'
|
|
45
|
+
}.should raise_error(ArgumentError)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 0.0.
|
|
8
|
+
- 2
|
|
9
|
+
version: 0.0.2
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Scott Gonyea
|
|
@@ -102,8 +102,10 @@ files:
|
|
|
102
102
|
- Rakefile
|
|
103
103
|
- lib/mongo_mapper-strict_keys.rb
|
|
104
104
|
- lib/mongo_mapper/strict_keys.rb
|
|
105
|
+
- lib/mongo_mapper/strict_keys/force_plugin.rb
|
|
105
106
|
- lib/mongo_mapper/strict_keys/version.rb
|
|
106
107
|
- mongo_mapper-strict_keys.gemspec
|
|
108
|
+
- spec/mongo_mapper/force_plugin_spec.rb
|
|
107
109
|
- spec/mongo_mapper/strict_keys_spec.rb
|
|
108
110
|
- spec/spec_helper.rb
|
|
109
111
|
has_rdoc: true
|
|
@@ -139,5 +141,6 @@ signing_key:
|
|
|
139
141
|
specification_version: 3
|
|
140
142
|
summary: Mongo Mapper Strict Keys Plugin
|
|
141
143
|
test_files:
|
|
144
|
+
- spec/mongo_mapper/force_plugin_spec.rb
|
|
142
145
|
- spec/mongo_mapper/strict_keys_spec.rb
|
|
143
146
|
- spec/spec_helper.rb
|