ananke 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ananke/serialize.rb +1 -1
- data/lib/version.rb +1 -1
- data/spec/lib/serialize_spec.rb +65 -0
- metadata +6 -4
data/lib/ananke/serialize.rb
CHANGED
data/lib/version.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
require './lib/ananke/serialize'
|
3
|
+
|
4
|
+
class Simple
|
5
|
+
attr_accessor :name, :surname
|
6
|
+
def initialize(name, surname)
|
7
|
+
@name = name
|
8
|
+
@surname = surname
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class SimplePlus
|
13
|
+
attr_accessor :name, :surname, :cars
|
14
|
+
def initialize(name, surname, cars)
|
15
|
+
@name = name
|
16
|
+
@surname = surname
|
17
|
+
@cars = cars
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Nested
|
22
|
+
attr_accessor :id, :simple_plus
|
23
|
+
def initialize(id, simple_plus)
|
24
|
+
@id = id
|
25
|
+
@simple_plus = simple_plus
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Serialize, '#self.to_hash' do
|
30
|
+
|
31
|
+
it "should serialize a simple class to hash form" do
|
32
|
+
obj = Simple.new('test', 'test')
|
33
|
+
Serialize.to_h(obj).should == {"name"=>"test", "surname" => "test"}
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should serialize a simple class with a hash to hash form" do
|
37
|
+
obj = SimplePlus.new('test', 'test', {:one => 1, :two => 2})
|
38
|
+
Serialize.to_h(obj).should == {"name" => "test", "surname" => "test", "cars" => {:one => 1, :two => 2}}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should serialize a nested class to hash form" do
|
42
|
+
obj = Nested.new(1, SimplePlus.new('test', 'test', {:one => 1, :two => 2}))
|
43
|
+
Serialize.to_h(obj).should == {"id" => 1, "simple_plus" => {"name" => "test", "surname" => "test", "cars" => {:one => 1, :two => 2}}}
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe Serialize, '#self.to_json' do
|
49
|
+
|
50
|
+
it "should serialize a simple class to json" do
|
51
|
+
obj = Simple.new('test', 'test')
|
52
|
+
Serialize.to_j(obj).should == '{"name":"test","surname":"test"}'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should serialize a simple class with a hash to json" do
|
56
|
+
obj = SimplePlus.new('test', 'test', {:one => 1, :two => 2})
|
57
|
+
Serialize.to_j(obj).should == '{"name":"test","surname":"test","cars":{"one":1,"two":2}}'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should serialize a nested class to json" do
|
61
|
+
obj = Nested.new(1, SimplePlus.new('test', 'test', {:one => 1, :two => 2}))
|
62
|
+
Serialize.to_j(obj).should == '{"id":1,"simple_plus":{"name":"test","surname":"test","cars":{"one":1,"two":2}}}'
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ananke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andries Coetzee
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-28 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- spec/lib/validation_spec.rb
|
114
114
|
- spec/lib/out_spec.rb
|
115
115
|
- spec/lib/json_spec.rb
|
116
|
+
- spec/lib/serialize_spec.rb
|
116
117
|
- spec/lib/link_to_spec.rb
|
117
118
|
- spec/lib/route_for_spec.rb
|
118
119
|
- spec/lib/error_spec.rb
|
@@ -130,7 +131,7 @@ licenses: []
|
|
130
131
|
post_install_message: |
|
131
132
|
**************************************************
|
132
133
|
|
133
|
-
Thank you for installing ananke-1.0
|
134
|
+
Thank you for installing ananke-1.1.0
|
134
135
|
|
135
136
|
Please be sure to look at README.rdoc to see what might have changed
|
136
137
|
since the last release and how to use this GEM.
|
@@ -159,7 +160,7 @@ rubyforge_project:
|
|
159
160
|
rubygems_version: 1.5.0
|
160
161
|
signing_key:
|
161
162
|
specification_version: 3
|
162
|
-
summary: ananke-1.0
|
163
|
+
summary: ananke-1.1.0
|
163
164
|
test_files:
|
164
165
|
- spec/dumping.rb
|
165
166
|
- spec/cov_adapter.rb
|
@@ -167,6 +168,7 @@ test_files:
|
|
167
168
|
- spec/lib/validation_spec.rb
|
168
169
|
- spec/lib/out_spec.rb
|
169
170
|
- spec/lib/json_spec.rb
|
171
|
+
- spec/lib/serialize_spec.rb
|
170
172
|
- spec/lib/link_to_spec.rb
|
171
173
|
- spec/lib/route_for_spec.rb
|
172
174
|
- spec/lib/error_spec.rb
|