Skip to content

Commit

Permalink
Merge pull request #164 from pd/enable-refremote-specs
Browse files Browse the repository at this point in the history
Enable refremote specs
  • Loading branch information
RST-J committed Oct 31, 2014
2 parents e20175d + 879a8a1 commit 6f16522
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec

gem "json", platform: :ruby_18
gem "json", :platform => :ruby_18

group :development do
gem "rake"
Expand Down
2 changes: 2 additions & 0 deletions json-schema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 1.8.7"
s.license = "MIT"
s.required_rubygems_version = ">= 1.8"

s.add_development_dependency "webmock"
end
10 changes: 10 additions & 0 deletions test/test_bad_schema_ref.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
require 'test/unit'
require 'webmock'
require 'socket'
require File.dirname(__FILE__) + '/../lib/json-schema'

class BadSchemaRefTest < Test::Unit::TestCase

def setup
WebMock.allow_net_connect!
end

def teardown
WebMock.disable_net_connect!
end

def test_bad_uri_ref
schema = {
"$schema" => "http://json-schema.org/draft-04/schema#",
Expand All @@ -25,6 +34,7 @@ def test_bad_host_ref
}

data = [1,2,3]

assert_raise(SocketError, OpenURI::HTTPError) do
JSON::Validator.validate(schema,data)
end
Expand Down
21 changes: 18 additions & 3 deletions test/test_common_test_suite.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test/unit'
require 'webmock'
require File.expand_path('../../lib/json-schema', __FILE__)

class CommonTestSuiteTest < Test::Unit::TestCase
Expand All @@ -16,11 +17,25 @@ class CommonTestSuiteTest < Test::Unit::TestCase
"ECMA 262 regex dialect recognition/ECMA 262 has no support for lookbehind",
"ECMA 262 regex dialect recognition/[^] is a valid regex",
],
"draft3/refRemote.json" => :all,
"draft4/optional/format.json" => :all,
"draft4/refRemote.json" => :all,
"draft4/optional/format.json" => :all
})

include WebMock::API

def setup
WebMock.enable!

Dir["#{TEST_DIR}/../remotes/**/*.json"].each do |path|
schema = path.sub(%r{^.*/remotes/}, '')
stub_request(:get, "http://localhost:1234/#{schema}").
to_return(:body => File.read(path), :status => 200)
end
end

def teardown
WebMock.disable!
end

Dir["#{TEST_DIR}/*"].each do |suite|
version = File.basename(suite).to_sym
Dir["#{suite}/**/*.json"].each do |tfile|
Expand Down

0 comments on commit 6f16522

Please sign in to comment.