Skip to content

Commit

Permalink
Group all json specs together in spec/opal/json
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 26, 2013
1 parent dae89e5 commit 6969618
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 98 deletions.
9 changes: 0 additions & 9 deletions spec/opal/array/to_json_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/opal/boolean/to_json_spec.rb

This file was deleted.

16 changes: 0 additions & 16 deletions spec/opal/hash/allocate_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/opal/hash/dup_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/opal/hash/new_spec.rb

This file was deleted.

11 changes: 0 additions & 11 deletions spec/opal/hash/to_json_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/opal/hash/to_s_spec.rb

This file was deleted.

48 changes: 48 additions & 0 deletions spec/opal/json/ext_spec.rb
@@ -0,0 +1,48 @@
require 'json'

describe "Hash#to_json" do
it "returns a string of all key and value pairs" do
{}.to_json.should == "{}"
{"a" => 1, "b" => 2}.to_json.should == '{"a": 1, "b": 2}'

hash = {"a" => 1, "b" => false, "c" => nil, "d" => true}
JSON.parse(hash.to_json).should == hash
end
end

describe "Array#to_json" do
it "returns a string of all array elements converted to json" do
[].to_json.should == "[]"
[1, 2, 3].to_json.should == "[1, 2, 3]"
[true, nil, false, "3", 42].to_json.should == '[true, null, false, "3", 42]'
end
end

describe "Boolean#to_json" do
it "returns 'true' when true" do
true.to_json.should == "true"
end

it "returns 'false' when false" do
false.to_json.should == "false"
end
end

describe "Kernel#to_json" do
it "returns an escaped #to_s of the receiver" do
self.to_json.should be_kind_of(String)
end
end

describe "NilClass#to_json" do
it "returns 'null'" do
nil.to_json.should == "null"
end
end

describe "String#to_json" do
it "returns an escaped string" do
"foo".to_json.should == "\"foo\""
"bar\nbaz".to_json.should == "\"bar\\nbaz\""
end
end
7 changes: 0 additions & 7 deletions spec/opal/kernel/to_json_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/opal/nil/to_json_spec.rb

This file was deleted.

8 changes: 0 additions & 8 deletions spec/opal/string/to_json_spec.rb

This file was deleted.

0 comments on commit 6969618

Please sign in to comment.