Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmario committed Jun 18, 2009
1 parent 8753c54 commit b30c6f0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/json_gem_compatibility/compatibility_spec.rb
Expand Up @@ -127,4 +127,43 @@ class Dummy; end
{"1"=>2}.should == parsed_json
end
end

context "ported fixture tests" do
fixtures = File.join(File.dirname(__FILE__), '../parsing/fixtures/*.json')
passed, failed = Dir[fixtures].partition { |f| f['pass'] }
PASSED = passed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
FAILED = failed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort

FAILED.each do |name, source|
it "should not be able to parse #{File.basename(name)} as an IO" do
lambda {
JSON.parse(StringIO.new(source))
}.should raise_error(Yajl::ParseError)
end
end

FAILED.each do |name, source|
it "should not be able to parse #{File.basename(name)} as a string" do
lambda {
JSON.parse(source)
}.should raise_error(Yajl::ParseError)
end
end

PASSED.each do |name, source|
it "should be able to parse #{File.basename(name)} as an IO" do
lambda {
JSON.parse(StringIO.new(source))
}.should_not raise_error(Yajl::ParseError)
end
end

PASSED.each do |name, source|
it "should be able to parse #{File.basename(name)} as a string" do
lambda {
JSON.parse(source)
}.should_not raise_error(Yajl::ParseError)
end
end
end
end

0 comments on commit b30c6f0

Please sign in to comment.