forked from bsiggelkow/jsonify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_value_spec.rb
44 lines (36 loc) · 1.03 KB
/
json_value_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'spec_helper'
describe Jsonify::JsonValue do
describe Jsonify::JsonPair do
let(:pair) { Jsonify::JsonPair.new('key','value') }
it 'should be constructed of a key and value' do
pair.key.should == 'key'
end
it 'should evaluate to key:value' do
pair.encode_as_json.should == "\"key\":\"value\""
end
end
describe Jsonify::JsonTrue do
it 'should have a value of true' do
Jsonify::JsonTrue.new.encode_as_json.should == 'true'
end
end
describe Jsonify::JsonFalse do
it 'should have a value of false' do
Jsonify::JsonFalse.new.encode_as_json.should == 'false'
end
end
describe Jsonify::JsonNull do
it 'should have a value of true' do
Jsonify::JsonNull.new.encode_as_json.should == 'null'
end
end
describe 'strings' do
it 'should quote the value' do
'foo'.encode_as_json.should == "\"foo\""
end
it 'should encode unicode' do
unicode = 'goober'.concat(16)
unicode.encode_as_json.should == "\"goober\\u0010\""
end
end
end