Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (27 sloc) 1.158 kb
ad86d48 @guilhermesilveira integration specs for json
guilhermesilveira authored
1 require 'spec_helper'
2
3 describe Medie::Json do
4
5 before :all do
6 full_json = IO.read(File.dirname(__FILE__) + '/full_json.js')
7 @json = Medie::Json::Driver.new.unmarshal(full_json)
8 end
9
10 describe "JSON read" do
11
12 it "should be able to read a JSON object in many ways" do
13
14 @json["articles"]["link"].first["type"].should == "text/json"
15 @json.articles.link.first.type.should == "text/json"
16
17 @json.articles.links.search.href.should == "http://search.place.com"
18 @json.articles.links.unknow_rel.should == nil
19 end
20
21 end
22
23 describe "JSON write" do
24
25 it "should be able to write a JSON object in many ways" do
26 @json["articles"]["size"] = 10
27 @json["articles"]["size"].should == 10
28
29 @json.articles.link << {"href" => "http://dont.panic.com", "rel" => "towel"}
30 @json.articles.link.last.href.should == "http://dont.panic.com"
31 @json.articles.link.last.rel.should == "towel"
32 @json.articles.link.size.should == 3
33
34 @json.articles.link.last.type = "application/json"
35 @json.articles.link.last.type.should == "application/json"
36 end
37
38 end
39
40 end
Something went wrong with that request. Please try again.