ricordami 0.0.2 → 0.0.3
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/CHANGELOG.md +5 -0
- data/lib/ricordami/can_be_serialized.rb +12 -0
- data/lib/ricordami/version.rb +1 -1
- data/spec/ricordami/can_be_serialized_spec.rb +26 -0
- metadata +5 -2
data/CHANGELOG.md
CHANGED
data/lib/ricordami/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "ricordami/can_be_serialized"
|
3
|
+
|
4
|
+
describe Ricordami::CanBeSerialized do
|
5
|
+
uses_constants("User", "Car")
|
6
|
+
|
7
|
+
it "returns a JSON representation string with #to_json" do
|
8
|
+
User.model_can :be_serialized
|
9
|
+
User.attribute :name
|
10
|
+
User.attribute :age
|
11
|
+
zhanna = User.create(:id => "plou", :name => "Zhannulia", :age => 29)
|
12
|
+
decoded = ActiveSupport::JSON.decode(zhanna.to_json)
|
13
|
+
decoded.should == {"user" => {"id" => "plou", "name" => "Zhannulia", "age" => "29"}}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns a XML representation string with #to_xml" do
|
17
|
+
Car.model_can :be_serialized
|
18
|
+
new_car = Car.create(:id => "prius")
|
19
|
+
new_car.to_xml.should ==<<EOS
|
20
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
21
|
+
<car>
|
22
|
+
<id>prius</id>
|
23
|
+
</car>
|
24
|
+
EOS
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ricordami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mathieu Lajugie
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-12 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/ricordami.rb
|
150
150
|
- lib/ricordami/attribute.rb
|
151
151
|
- lib/ricordami/can_be_queried.rb
|
152
|
+
- lib/ricordami/can_be_serialized.rb
|
152
153
|
- lib/ricordami/can_be_validated.rb
|
153
154
|
- lib/ricordami/can_have_relationships.rb
|
154
155
|
- lib/ricordami/configuration.rb
|
@@ -173,6 +174,7 @@ files:
|
|
173
174
|
- spec/acceptance_helper.rb
|
174
175
|
- spec/ricordami/attribute_spec.rb
|
175
176
|
- spec/ricordami/can_be_queried_spec.rb
|
177
|
+
- spec/ricordami/can_be_serialized_spec.rb
|
176
178
|
- spec/ricordami/can_be_validated_spec.rb
|
177
179
|
- spec/ricordami/can_have_relationships_spec.rb
|
178
180
|
- spec/ricordami/configuration_spec.rb
|
@@ -235,6 +237,7 @@ test_files:
|
|
235
237
|
- spec/acceptance_helper.rb
|
236
238
|
- spec/ricordami/attribute_spec.rb
|
237
239
|
- spec/ricordami/can_be_queried_spec.rb
|
240
|
+
- spec/ricordami/can_be_serialized_spec.rb
|
238
241
|
- spec/ricordami/can_be_validated_spec.rb
|
239
242
|
- spec/ricordami/can_have_relationships_spec.rb
|
240
243
|
- spec/ricordami/configuration_spec.rb
|