features/support/load_tests.rb in csvlint-0.4.0 vs features/support/load_tests.rb in csvlint-1.0.0
- old
+ new
@@ -1,10 +1,10 @@
require 'json'
require 'open-uri'
require 'uri'
-BASE_URI = "http://www.w3.org/2013/csvw/tests/"
+BASE_URI = "https://w3c.github.io/csvw/tests/"
BASE_PATH = File.join(File.dirname(__FILE__), "..", "fixtures", "csvw")
FEATURE_BASE_PATH = File.join(File.dirname(__FILE__), "..")
VALIDATION_FEATURE_FILE_PATH = File.join(FEATURE_BASE_PATH, "csvw_validation_tests.feature")
SCRIPT_FILE_PATH = File.join(File.dirname(__FILE__), "..", "..", "bin", "run-csvw-tests")
@@ -21,26 +21,26 @@
Dir.mkdir(dir) unless Dir.exist?(dir)
end
end
STDERR.puts("storing #{file} locally")
File.open(file, 'wb') do |f|
- f.puts open(uri, 'rb').read
+ f.puts URI.open(uri, 'rb').read
end
end
return uri, file
end
File.open(SCRIPT_FILE_PATH, 'w') do |file|
File.chmod(0755, SCRIPT_FILE_PATH)
- manifest = JSON.parse( open("http://www.w3.org/2013/csvw/tests/manifest-validation.jsonld").read )
+ manifest = JSON.parse( URI.open("#{BASE_URI}manifest-validation.jsonld").read )
manifest["entries"].each do |entry|
type = "valid"
- case entry["type"]
- when "csvt:WarningValidationTest"
- type = "warnings"
- when "csvt:NegativeValidationTest"
- type = "errors"
+ case entry["type"]
+ when "csvt:WarningValidationTest"
+ type = "warnings"
+ when "csvt:NegativeValidationTest"
+ type = "errors"
end
file.puts "echo \"#{entry["id"].split("#")[-1]}: #{entry["name"].gsub("`", "'")}\""
file.puts "echo \"#{type}: #{entry["comment"].gsub("\"", "\\\"").gsub("`", "'")}\""
if entry["action"].end_with?(".json")
file.puts "csvlint --schema=features/fixtures/csvw/#{entry["action"]}"
@@ -52,18 +52,18 @@
file.puts "echo"
end
end unless File.exist? SCRIPT_FILE_PATH
File.open(VALIDATION_FEATURE_FILE_PATH, 'w') do |file|
- file.puts "# Auto-generated file based on standard validation CSVW tests from http://www.w3.org/2013/csvw/tests/manifest-validation.jsonld"
+ file.puts "# Auto-generated file based on standard validation CSVW tests from #{BASE_URI}manifest-validation.jsonld"
file.puts ""
- manifest = JSON.parse( open("http://www.w3.org/2013/csvw/tests/manifest-validation.jsonld").read )
+ manifest = JSON.parse( URI.open("#{BASE_URI}manifest-validation.jsonld").read )
file.puts "Feature: #{manifest["label"]}"
file.puts ""
-
+
manifest["entries"].each do |entry|
action_uri, action_file = cache_file(entry["action"])
metadata = nil
provided_files = []
missing_files = []
@@ -83,10 +83,10 @@
file.puts "\t\tAnd I have a metadata file called \"csvw/#{entry["option"]["metadata"]}\""
file.puts "\t\tAnd the metadata is stored at the url \"#{metadata}\""
end
provided_files << action_uri.to_s
if entry["name"].include?("/.well-known/csvm")
- file.puts "\t\tAnd I have a file called \"w3.org/.well-known/csvm\" at the url \"http://www.w3.org/.well-known/csvm\""
+ file.puts "\t\tAnd I have a file called \"w3.org/.well-known/csvm\" at the url \"https://www.w3.org/.well-known/csvm\""
missing_files << "#{action_uri}.json"
missing_files << URI.join(action_uri, 'csvm.json').to_s
else
missing_files << URI.join(action_uri, '/.well-known/csvm').to_s
end