dm-types 0.10.2 → 1.0.0.rc1
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 +36 -0
- data/Gemfile +147 -0
- data/Rakefile +7 -8
- data/VERSION +1 -1
- data/dm-types.gemspec +61 -20
- data/lib/dm-types.rb +24 -19
- data/lib/dm-types/bcrypt_hash.rb +17 -13
- data/lib/dm-types/comma_separated_list.rb +11 -16
- data/lib/dm-types/csv.rb +11 -11
- data/lib/dm-types/enum.rb +33 -50
- data/lib/dm-types/epoch_time.rb +11 -11
- data/lib/dm-types/file_path.rb +13 -10
- data/lib/dm-types/flag.rb +17 -25
- data/lib/dm-types/ip_address.rb +15 -11
- data/lib/dm-types/json.rb +17 -14
- data/lib/dm-types/paranoid/base.rb +38 -0
- data/lib/dm-types/paranoid_boolean.rb +23 -0
- data/lib/dm-types/paranoid_datetime.rb +22 -0
- data/lib/dm-types/regexp.rb +8 -8
- data/lib/dm-types/slug.rb +7 -12
- data/lib/dm-types/uri.rb +21 -9
- data/lib/dm-types/uuid.rb +18 -11
- data/lib/dm-types/yaml.rb +12 -10
- data/spec/fixtures/article.rb +0 -2
- data/spec/fixtures/bookmark.rb +0 -2
- data/spec/fixtures/network_node.rb +0 -2
- data/spec/fixtures/person.rb +0 -2
- data/spec/fixtures/software_package.rb +0 -2
- data/spec/fixtures/ticket.rb +2 -4
- data/spec/fixtures/tshirt.rb +3 -5
- data/spec/integration/bcrypt_hash_spec.rb +33 -31
- data/spec/integration/comma_separated_list_spec.rb +55 -53
- data/spec/integration/enum_spec.rb +55 -53
- data/spec/integration/file_path_spec.rb +105 -103
- data/spec/integration/flag_spec.rb +42 -40
- data/spec/integration/ip_address_spec.rb +91 -89
- data/spec/integration/json_spec.rb +41 -39
- data/spec/integration/slug_spec.rb +36 -34
- data/spec/integration/uri_spec.rb +82 -79
- data/spec/integration/uuid_spec.rb +63 -61
- data/spec/integration/yaml_spec.rb +37 -35
- data/spec/spec_helper.rb +7 -36
- data/spec/unit/bcrypt_hash_spec.rb +18 -10
- data/spec/unit/csv_spec.rb +92 -80
- data/spec/unit/enum_spec.rb +27 -42
- data/spec/unit/epoch_time_spec.rb +18 -7
- data/spec/unit/file_path_spec.rb +15 -10
- data/spec/unit/flag_spec.rb +13 -36
- data/spec/unit/ip_address_spec.rb +13 -10
- data/spec/unit/json_spec.rb +21 -14
- data/spec/unit/paranoid_boolean_spec.rb +138 -0
- data/spec/unit/paranoid_datetime_spec.rb +143 -0
- data/spec/unit/regexp_spec.rb +15 -5
- data/spec/unit/uri_spec.rb +13 -9
- data/spec/unit/yaml_spec.rb +16 -9
- data/tasks/local_gemfile.rake +18 -0
- data/tasks/spec.rake +0 -3
- metadata +122 -52
@@ -5,94 +5,96 @@ try_spec do
|
|
5
5
|
require './spec/fixtures/network_node'
|
6
6
|
|
7
7
|
describe DataMapper::Types::Fixtures::NetworkNode do
|
8
|
-
|
9
|
-
|
10
|
-
@uuid_string = 'b0fc632e-d744-4821-afe3-4ea0701859ee'
|
11
|
-
@uuid = UUIDTools::UUID.parse(@uuid_string)
|
12
|
-
@resource = DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
13
|
-
|
14
|
-
@resource.save.should be_true
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'when reloaded' do
|
8
|
+
supported_by :all do
|
9
|
+
describe 'with UUID set as UUID object' do
|
18
10
|
before :all do
|
19
|
-
@
|
20
|
-
|
11
|
+
@uuid_string = 'b0fc632e-d744-4821-afe3-4ea0701859ee'
|
12
|
+
@uuid = UUIDTools::UUID.parse(@uuid_string)
|
13
|
+
@resource = DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
21
14
|
|
22
|
-
|
23
|
-
@resource.uuid.to_s.should == @uuid_string
|
15
|
+
@resource.save.should be_true
|
24
16
|
end
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
describe 'when reloaded' do
|
19
|
+
before :all do
|
20
|
+
@resource.reload
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'has the same UUID string' do
|
24
|
+
@resource.uuid.to_s.should == @uuid_string
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
it 'returns UUID as an object' do
|
28
|
+
@resource.uuid.should be_an_instance_of(UUIDTools::UUID)
|
29
|
+
end
|
30
|
+
end
|
36
31
|
end
|
37
32
|
|
38
|
-
describe '
|
33
|
+
describe 'with UUID set as a valid UUID string' do
|
39
34
|
before :all do
|
40
|
-
@
|
35
|
+
@uuid = 'b0fc632e-d744-4821-afe3-4ea0701859ee'
|
36
|
+
@resource = DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
41
37
|
end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
describe 'when reloaded' do
|
40
|
+
before :all do
|
41
|
+
@resource.reload
|
42
|
+
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
44
|
+
it 'has the same UUID string' do
|
45
|
+
@resource.uuid.to_s.should == @uuid
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@operation = lambda do
|
57
|
-
DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
48
|
+
it 'returns UUID as an object' do
|
49
|
+
@resource.uuid.should be_an_instance_of(UUIDTools::UUID)
|
50
|
+
end
|
58
51
|
end
|
59
52
|
end
|
60
53
|
|
61
|
-
describe '
|
62
|
-
|
63
|
-
@
|
54
|
+
describe 'with UUID set as invalid UUID string' do
|
55
|
+
before :all do
|
56
|
+
@uuid = 'meh'
|
57
|
+
@operation = lambda do
|
58
|
+
DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
59
|
+
end
|
64
60
|
end
|
65
|
-
end
|
66
|
-
end
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
62
|
+
describe 'when assigned UUID' do
|
63
|
+
it 'raises ArgumentError' do
|
64
|
+
@operation.should raise_error(ArgumentError, /Invalid UUID format/)
|
65
|
+
end
|
73
66
|
end
|
74
67
|
end
|
75
68
|
|
76
|
-
describe '
|
77
|
-
|
78
|
-
@
|
69
|
+
describe 'with UUID set as a blank string' do
|
70
|
+
before :all do
|
71
|
+
@uuid = ''
|
72
|
+
@operation = lambda do
|
73
|
+
DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
74
|
+
end
|
79
75
|
end
|
80
|
-
end
|
81
|
-
end
|
82
76
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
77
|
+
describe 'when assigned UUID' do
|
78
|
+
it 'raises ArgumentError' do
|
79
|
+
@operation.should raise_error(ArgumentError, /Invalid UUID format/)
|
80
|
+
end
|
81
|
+
end
|
87
82
|
end
|
88
83
|
|
89
|
-
describe '
|
84
|
+
describe 'with missing UUID' do
|
90
85
|
before :all do
|
91
|
-
@
|
86
|
+
@uuid = nil
|
87
|
+
@resource = DataMapper::Types::Fixtures::NetworkNode.new(:uuid => @uuid)
|
92
88
|
end
|
93
89
|
|
94
|
-
|
95
|
-
|
90
|
+
describe 'when reloaded' do
|
91
|
+
before :all do
|
92
|
+
@resource.reload
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'has no UUID' do
|
96
|
+
@resource.uuid.should be_nil
|
97
|
+
end
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
@@ -6,60 +6,62 @@ try_spec do
|
|
6
6
|
require './spec/fixtures/invention'
|
7
7
|
|
8
8
|
describe DataMapper::Types::Fixtures::Person do
|
9
|
-
|
10
|
-
@resource = DataMapper::Types::Fixtures::Person.new(:name => '')
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'with no inventions information' do
|
9
|
+
supported_by :all do
|
14
10
|
before :all do
|
15
|
-
@resource
|
11
|
+
@resource = DataMapper::Types::Fixtures::Person.new(:name => '')
|
16
12
|
end
|
17
13
|
|
18
|
-
describe '
|
14
|
+
describe 'with no inventions information' do
|
19
15
|
before :all do
|
20
|
-
@resource.
|
21
|
-
@resource.reload
|
16
|
+
@resource.inventions = nil
|
22
17
|
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
describe 'when dumped and loaded again' do
|
20
|
+
before :all do
|
21
|
+
@resource.save.should be_true
|
22
|
+
@resource.reload
|
23
|
+
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
DataMapper::Types::Fixtures::Invention.new(name)
|
25
|
+
it 'has nil inventions list' do
|
26
|
+
@resource.inventions.should be_nil
|
27
|
+
end
|
34
28
|
end
|
35
|
-
@resource.inventions = @input
|
36
29
|
end
|
37
30
|
|
38
|
-
describe '
|
31
|
+
describe 'with a few items on the inventions list' do
|
39
32
|
before :all do
|
40
|
-
@
|
41
|
-
|
33
|
+
@input = [ 'carbon telephone transmitter', 'light bulb', 'electric grid' ].map do |name|
|
34
|
+
DataMapper::Types::Fixtures::Invention.new(name)
|
35
|
+
end
|
36
|
+
@resource.inventions = @input
|
42
37
|
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
describe 'when dumped and loaded again' do
|
40
|
+
before :all do
|
41
|
+
@resource.save.should be_true
|
42
|
+
@resource.reload
|
43
|
+
end
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
it 'loads inventions list to the state when it was dumped/persisted with keys being strings' do
|
46
|
+
@resource.inventions.should == @input
|
47
|
+
end
|
48
|
+
end
|
53
49
|
end
|
54
50
|
|
55
|
-
describe '
|
51
|
+
describe 'with inventions information given as empty list' do
|
56
52
|
before :all do
|
57
|
-
@resource.
|
58
|
-
@resource.reload
|
53
|
+
@resource.inventions = []
|
59
54
|
end
|
60
55
|
|
61
|
-
|
62
|
-
|
56
|
+
describe 'when dumped and loaded again' do
|
57
|
+
before :all do
|
58
|
+
@resource.save.should be_true
|
59
|
+
@resource.reload
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'has empty inventions list' do
|
63
|
+
@resource.inventions.should == []
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,45 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
# TODO: autovalidation hooks are needed badly,
|
4
|
-
# otherwise plugin devs will have to abuse
|
5
|
-
# alising and load order even further and it kinda makes
|
6
|
-
# me sad -- MK
|
7
|
-
|
8
|
-
# use local dm-core if running from a typical dev checkout.
|
9
|
-
lib = File.join('..', '..', 'dm-core', 'lib')
|
10
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
11
|
-
require 'dm-core'
|
12
|
-
|
13
|
-
# use local dm-validations if running from a typical dev checkout.
|
14
|
-
lib = File.join('..', 'dm-validations', 'lib')
|
15
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
16
|
-
require 'dm-validations'
|
17
|
-
|
18
|
-
# Support running specs with 'rake spec' and 'spec'
|
19
|
-
$LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
|
1
|
+
require 'dm-core/spec/setup'
|
2
|
+
require 'dm-core/spec/lib/adapter_helpers'
|
20
3
|
|
21
4
|
require 'dm-types'
|
5
|
+
require 'dm-migrations'
|
6
|
+
require 'dm-validations'
|
22
7
|
|
23
|
-
|
24
|
-
return false if ENV['ADAPTER'] != name.to_s
|
8
|
+
DataMapper::Spec.setup
|
25
9
|
|
26
|
-
|
27
|
-
|
28
|
-
DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
|
29
|
-
true
|
30
|
-
rescue LoadError => e
|
31
|
-
warn "Could not load do_#{name}: #{e}"
|
32
|
-
false
|
33
|
-
end
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.extend(DataMapper::Spec::Adapters::Helpers)
|
34
12
|
end
|
35
13
|
|
36
|
-
ENV['ADAPTER'] ||= 'sqlite3'
|
37
|
-
|
38
|
-
HAS_SQLITE3 = load_driver(:sqlite3, 'sqlite3::memory:')
|
39
|
-
HAS_MYSQL = load_driver(:mysql, 'mysql://localhost/dm_core_test')
|
40
|
-
HAS_POSTGRES = load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
|
41
|
-
|
42
|
-
|
43
14
|
DEPENDENCIES = {
|
44
15
|
'bcrypt' => 'bcrypt-ruby',
|
45
16
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
try_spec do
|
4
|
-
describe DataMapper::
|
4
|
+
describe DataMapper::Property::BCryptHash do
|
5
5
|
before :all do
|
6
6
|
@clear_password = 'DataMapper R0cks!'
|
7
7
|
@crypted_password = BCrypt::Password.create(@clear_password)
|
@@ -13,13 +13,21 @@ try_spec do
|
|
13
13
|
@b = 'Hi There'
|
14
14
|
end
|
15
15
|
@nonstandard_type2 = TestType.new
|
16
|
+
|
17
|
+
class User
|
18
|
+
include DataMapper::Resource
|
19
|
+
property :id, Serial
|
20
|
+
property :password, BCryptHash
|
21
|
+
end
|
22
|
+
|
23
|
+
@bcrypt_hash = User.properties[:password]
|
16
24
|
end
|
17
25
|
|
18
26
|
describe '.dump' do
|
19
27
|
describe 'when argument is a string' do
|
20
28
|
before :all do
|
21
29
|
@input = 'DataMapper'
|
22
|
-
@result =
|
30
|
+
@result = @bcrypt_hash.dump(@input)
|
23
31
|
end
|
24
32
|
|
25
33
|
it 'returns instance of BCrypt::Password' do
|
@@ -34,7 +42,7 @@ try_spec do
|
|
34
42
|
describe 'when argument is nil' do
|
35
43
|
before :all do
|
36
44
|
@input = nil
|
37
|
-
@result =
|
45
|
+
@result = @bcrypt_hash.dump(@input)
|
38
46
|
end
|
39
47
|
|
40
48
|
it 'returns nil' do
|
@@ -47,7 +55,7 @@ try_spec do
|
|
47
55
|
describe 'when argument is a string' do
|
48
56
|
before :all do
|
49
57
|
@input = 'DataMapper'
|
50
|
-
@result =
|
58
|
+
@result = @bcrypt_hash.load(@crypted_password)
|
51
59
|
end
|
52
60
|
|
53
61
|
it 'returns instance of BCrypt::Password' do
|
@@ -62,7 +70,7 @@ try_spec do
|
|
62
70
|
describe 'when argument is nil' do
|
63
71
|
before :all do
|
64
72
|
@input = nil
|
65
|
-
@result =
|
73
|
+
@result = @bcrypt_hash.load(@input)
|
66
74
|
end
|
67
75
|
|
68
76
|
it 'returns nil' do
|
@@ -75,7 +83,7 @@ try_spec do
|
|
75
83
|
describe 'when argument is a string' do
|
76
84
|
before :all do
|
77
85
|
@input = 'bcrypt hash'
|
78
|
-
@result =
|
86
|
+
@result = @bcrypt_hash.typecast(@input)
|
79
87
|
end
|
80
88
|
|
81
89
|
it 'casts argument to BCrypt::Password' do
|
@@ -90,7 +98,7 @@ try_spec do
|
|
90
98
|
describe 'when argument is a blank string' do
|
91
99
|
before :all do
|
92
100
|
@input = ''
|
93
|
-
@result =
|
101
|
+
@result = @bcrypt_hash.typecast(@input)
|
94
102
|
end
|
95
103
|
|
96
104
|
it 'casts argument to BCrypt::Password' do
|
@@ -105,7 +113,7 @@ try_spec do
|
|
105
113
|
describe 'when argument is integer' do
|
106
114
|
before :all do
|
107
115
|
@input = 2249
|
108
|
-
@result =
|
116
|
+
@result = @bcrypt_hash.typecast(@input)
|
109
117
|
end
|
110
118
|
|
111
119
|
it 'casts argument to BCrypt::Password' do
|
@@ -120,7 +128,7 @@ try_spec do
|
|
120
128
|
describe 'when argument is hash' do
|
121
129
|
before :all do
|
122
130
|
@input = { :cryptic => 'obscure' }
|
123
|
-
@result =
|
131
|
+
@result = @bcrypt_hash.typecast(@input)
|
124
132
|
end
|
125
133
|
|
126
134
|
it 'casts argument to BCrypt::Password' do
|
@@ -135,7 +143,7 @@ try_spec do
|
|
135
143
|
describe 'when argument is nil' do
|
136
144
|
before :all do
|
137
145
|
@input = nil
|
138
|
-
@result =
|
146
|
+
@result = @bcrypt_hash.typecast(@input)
|
139
147
|
end
|
140
148
|
|
141
149
|
it 'returns nil' do
|
data/spec/unit/csv_spec.rb
CHANGED
@@ -1,117 +1,129 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
try_spec do
|
4
|
-
describe DataMapper::
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
describe DataMapper::Property::Csv do
|
5
|
+
supported_by :all do
|
6
|
+
before :all do
|
7
|
+
class User
|
8
|
+
include DataMapper::Resource
|
9
|
+
property :id, Serial
|
10
|
+
property :things, Csv
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
@result.should == [ %w[ uno due tre ] ]
|
14
|
-
end
|
13
|
+
@property = User.properties[:things]
|
15
14
|
end
|
16
15
|
|
17
|
-
describe '
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
describe '.load' do
|
17
|
+
describe 'when argument is a comma separated string' do
|
18
|
+
before :all do
|
19
|
+
@input = 'uno,due,tre'
|
20
|
+
@result = @property.load(@input)
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
it 'parses the argument using CVS parser' do
|
24
|
+
@result.should == [ %w[ uno due tre ] ]
|
25
|
+
end
|
25
26
|
end
|
26
|
-
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
describe 'when argument is an empty array' do
|
29
|
+
before :all do
|
30
|
+
@input = []
|
31
|
+
@result = @property.load(@input)
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
it 'does not change the input' do
|
35
|
+
@result.should == @input
|
36
|
+
end
|
36
37
|
end
|
37
|
-
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
describe 'when argument is an empty hash' do
|
40
|
+
before :all do
|
41
|
+
@input = {}
|
42
|
+
@result = @property.load(@input)
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
it 'returns nil' do
|
46
|
+
@result.should be_nil
|
47
|
+
end
|
47
48
|
end
|
48
|
-
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
describe 'when argument is nil' do
|
51
|
+
before :all do
|
52
|
+
@input = nil
|
53
|
+
@result = @property.load(@input)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
it 'returns nil' do
|
57
|
+
@result.should be_nil
|
58
|
+
end
|
58
59
|
end
|
59
|
-
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
describe 'when argument is an integer' do
|
62
|
+
before :all do
|
63
|
+
@input = 7
|
64
|
+
@result = @property.load(@input)
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
it 'returns nil' do
|
68
|
+
@result.should be_nil
|
69
|
+
end
|
69
70
|
end
|
70
|
-
end
|
71
|
-
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
72
|
+
describe 'when argument is a float' do
|
73
|
+
before :all do
|
74
|
+
@input = 7.0
|
75
|
+
@result = @property.load(@input)
|
76
|
+
end
|
79
77
|
|
80
|
-
|
81
|
-
|
78
|
+
it 'returns nil' do
|
79
|
+
@result.should be_nil
|
80
|
+
end
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
85
|
-
describe '
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
describe '.dump' do
|
85
|
+
describe 'when value is a list of lists' do
|
86
|
+
before :all do
|
87
|
+
@input = [ %w[ uno due tre ], %w[ uno dos tres ] ]
|
88
|
+
@result = @property.dump(@input)
|
89
|
+
end
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
it 'dumps value to comma separated string' do
|
92
|
+
@result.should == "uno,due,tre\nuno,dos,tres\n"
|
93
|
+
end
|
93
94
|
end
|
94
|
-
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
describe 'when value is a string' do
|
97
|
+
before :all do
|
98
|
+
@input = 'beauty hides in the deep'
|
99
|
+
@result = @property.dump(@input)
|
100
|
+
end
|
101
101
|
|
102
|
-
|
103
|
-
|
102
|
+
it 'returns input as is' do
|
103
|
+
@result.should == @input
|
104
|
+
end
|
104
105
|
end
|
105
|
-
end
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
describe 'when value is nil' do
|
108
|
+
before :all do
|
109
|
+
@input = nil
|
110
|
+
@result = @property.dump(@input)
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'returns nil' do
|
114
|
+
@result.should be_nil
|
115
|
+
end
|
111
116
|
end
|
112
117
|
|
113
|
-
|
114
|
-
|
118
|
+
describe 'when value is a hash' do
|
119
|
+
before :all do
|
120
|
+
@input = { :library => 'DataMapper', :language => 'Ruby' }
|
121
|
+
@result = @property.dump(@input)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'returns nil' do
|
125
|
+
@result.should be_nil
|
126
|
+
end
|
115
127
|
end
|
116
128
|
end
|
117
129
|
end
|