csvlint 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +4 -0
- data/.github/workflows/push.yml +14 -2
- data/.ruby-version +1 -1
- data/.standard_todo.yml +43 -0
- data/Dockerfile +16 -0
- data/Gemfile +2 -2
- data/README.md +9 -9
- data/Rakefile +7 -7
- data/csvlint.gemspec +14 -16
- data/docker_notes_for_windows.txt +20 -0
- data/features/step_definitions/cli_steps.rb +11 -11
- data/features/step_definitions/information_steps.rb +4 -4
- data/features/step_definitions/parse_csv_steps.rb +11 -11
- data/features/step_definitions/schema_validation_steps.rb +10 -10
- data/features/step_definitions/sources_steps.rb +1 -1
- data/features/step_definitions/validation_errors_steps.rb +19 -19
- data/features/step_definitions/validation_info_steps.rb +9 -9
- data/features/step_definitions/validation_warnings_steps.rb +11 -11
- data/features/support/aruba.rb +6 -6
- data/features/support/earl_formatter.rb +39 -39
- data/features/support/env.rb +10 -11
- data/features/support/load_tests.rb +107 -103
- data/features/support/webmock.rb +2 -2
- data/lib/csvlint/cli.rb +133 -130
- data/lib/csvlint/csvw/column.rb +279 -280
- data/lib/csvlint/csvw/date_format.rb +90 -92
- data/lib/csvlint/csvw/metadata_error.rb +1 -3
- data/lib/csvlint/csvw/number_format.rb +40 -32
- data/lib/csvlint/csvw/property_checker.rb +714 -717
- data/lib/csvlint/csvw/table.rb +49 -52
- data/lib/csvlint/csvw/table_group.rb +24 -23
- data/lib/csvlint/error_collector.rb +2 -0
- data/lib/csvlint/error_message.rb +0 -1
- data/lib/csvlint/field.rb +153 -141
- data/lib/csvlint/schema.rb +34 -42
- data/lib/csvlint/validate.rb +161 -143
- data/lib/csvlint/version.rb +1 -1
- data/lib/csvlint.rb +22 -23
- data/spec/csvw/column_spec.rb +15 -16
- data/spec/csvw/date_format_spec.rb +5 -7
- data/spec/csvw/number_format_spec.rb +2 -4
- data/spec/csvw/table_group_spec.rb +103 -105
- data/spec/csvw/table_spec.rb +71 -73
- data/spec/field_spec.rb +116 -121
- data/spec/schema_spec.rb +129 -139
- data/spec/spec_helper.rb +6 -6
- data/spec/validator_spec.rb +167 -190
- metadata +22 -55
data/spec/csvw/column_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Csvlint::Csvw::Column do
|
4
|
-
|
5
4
|
it "shouldn't generate errors for string values" do
|
6
5
|
column = Csvlint::Csvw::Column.new(1, "foo")
|
7
6
|
value = column.validate("bar", 2)
|
@@ -9,14 +8,14 @@ describe Csvlint::Csvw::Column do
|
|
9
8
|
end
|
10
9
|
|
11
10
|
it "should generate errors for string values that aren't long enough" do
|
12
|
-
column = Csvlint::Csvw::Column.new(1, "foo", datatype: {
|
11
|
+
column = Csvlint::Csvw::Column.new(1, "foo", datatype: {"base" => "http://www.w3.org/2001/XMLSchema#string", "minLength" => 4})
|
13
12
|
value = column.validate("bar", 2)
|
14
|
-
expect(value).to eq({
|
13
|
+
expect(value).to eq({invalid: "bar"})
|
15
14
|
expect(column.errors.length).to eq(1)
|
16
15
|
end
|
17
16
|
|
18
17
|
it "shouldn't generate errors for string values that are long enough" do
|
19
|
-
column = Csvlint::Csvw::Column.new(1, "foo", datatype: {
|
18
|
+
column = Csvlint::Csvw::Column.new(1, "foo", datatype: {"base" => "http://www.w3.org/2001/XMLSchema#string", "minLength" => 4})
|
20
19
|
value = column.validate("barn", 2)
|
21
20
|
expect(value).to eq("barn")
|
22
21
|
expect(column.errors.length).to eq(0)
|
@@ -24,19 +23,19 @@ describe Csvlint::Csvw::Column do
|
|
24
23
|
|
25
24
|
context "when parsing CSVW column descriptions" do
|
26
25
|
it "should provide appropriate default values" do
|
27
|
-
@desc
|
26
|
+
@desc = <<-EOL
|
28
27
|
{
|
29
28
|
"name": "countryCode"
|
30
29
|
}
|
31
30
|
EOL
|
32
|
-
json = JSON.parse(
|
31
|
+
json = JSON.parse(@desc)
|
33
32
|
column = Csvlint::Csvw::Column.from_json(1, json)
|
34
33
|
|
35
34
|
expect(column).to be_a(Csvlint::Csvw::Column)
|
36
35
|
expect(column.number).to eq(1)
|
37
36
|
expect(column.name).to eq("countryCode")
|
38
37
|
expect(column.about_url).to eq(nil)
|
39
|
-
expect(column.datatype).to eq({
|
38
|
+
expect(column.datatype).to eq({"@id" => "http://www.w3.org/2001/XMLSchema#string"})
|
40
39
|
expect(column.default).to eq("")
|
41
40
|
expect(column.lang).to eq("und")
|
42
41
|
expect(column.null).to eq([""])
|
@@ -54,21 +53,21 @@ describe Csvlint::Csvw::Column do
|
|
54
53
|
end
|
55
54
|
|
56
55
|
it "should override default values" do
|
57
|
-
@desc
|
56
|
+
@desc = <<-EOL
|
58
57
|
{
|
59
58
|
"name": "countryCode",
|
60
59
|
"titles": "countryCode",
|
61
60
|
"propertyUrl": "http://www.geonames.org/ontology{#_name}"
|
62
61
|
}
|
63
62
|
EOL
|
64
|
-
json = JSON.parse(
|
63
|
+
json = JSON.parse(@desc)
|
65
64
|
column = Csvlint::Csvw::Column.from_json(2, json)
|
66
65
|
|
67
66
|
expect(column).to be_a(Csvlint::Csvw::Column)
|
68
67
|
expect(column.number).to eq(2)
|
69
68
|
expect(column.name).to eq("countryCode")
|
70
69
|
expect(column.about_url).to eq(nil)
|
71
|
-
expect(column.datatype).to eq({
|
70
|
+
expect(column.datatype).to eq({"@id" => "http://www.w3.org/2001/XMLSchema#string"})
|
72
71
|
expect(column.default).to eq("")
|
73
72
|
expect(column.lang).to eq("und")
|
74
73
|
expect(column.null).to eq([""])
|
@@ -79,31 +78,31 @@ describe Csvlint::Csvw::Column do
|
|
79
78
|
expect(column.source_number).to eq(2)
|
80
79
|
expect(column.suppress_output).to eq(false)
|
81
80
|
expect(column.text_direction).to eq(:inherit)
|
82
|
-
expect(column.titles).to eql({
|
81
|
+
expect(column.titles).to eql({"und" => ["countryCode"]})
|
83
82
|
expect(column.value_url).to eq(nil)
|
84
83
|
expect(column.virtual).to eq(false)
|
85
84
|
expect(column.annotations).to eql({})
|
86
85
|
end
|
87
86
|
|
88
87
|
it "should include the datatype" do
|
89
|
-
@desc
|
88
|
+
@desc = <<-EOL
|
90
89
|
{ "name": "Id", "required": true, "datatype": { "base": "string", "minLength": 3 } }
|
91
90
|
EOL
|
92
91
|
json = JSON.parse(@desc)
|
93
92
|
column = Csvlint::Csvw::Column.from_json(1, json)
|
94
93
|
expect(column.name).to eq("Id")
|
95
94
|
expect(column.required).to eq(true)
|
96
|
-
expect(column.datatype).to eql({
|
95
|
+
expect(column.datatype).to eql({"base" => "http://www.w3.org/2001/XMLSchema#string", "minLength" => 3})
|
97
96
|
end
|
98
97
|
|
99
98
|
it "should generate warnings for invalid null values" do
|
100
|
-
@desc
|
99
|
+
@desc = <<-EOL
|
101
100
|
{
|
102
101
|
"name": "countryCode",
|
103
102
|
"null": true
|
104
103
|
}
|
105
104
|
EOL
|
106
|
-
json = JSON.parse(
|
105
|
+
json = JSON.parse(@desc)
|
107
106
|
column = Csvlint::Csvw::Column.from_json(1, json)
|
108
107
|
expect(column.warnings.length).to eq(1)
|
109
108
|
expect(column.warnings[0].type).to eq(:invalid_value)
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Csvlint::Csvw::DateFormat do
|
4
|
-
|
5
4
|
it "should parse dates that match yyyy-MM-dd correctly" do
|
6
5
|
format = Csvlint::Csvw::DateFormat.new("yyyy-MM-dd")
|
7
6
|
expect(format.parse("2015-03-22")[:dateTime]).to eql(Date.new(2015, 3, 22))
|
@@ -11,15 +10,15 @@ describe Csvlint::Csvw::DateFormat do
|
|
11
10
|
|
12
11
|
it "should parse times that match HH:mm:ss correctly" do
|
13
12
|
format = Csvlint::Csvw::DateFormat.new("HH:mm:ss")
|
14
|
-
expect(format.parse("12:34:56")).to eql({
|
13
|
+
expect(format.parse("12:34:56")).to eql({hour: 12, minute: 34, second: 56.0, string: "12:34:56", dateTime: DateTime.new(0, 1, 1, 12, 34, 56.0, "+00:00")})
|
15
14
|
expect(format.parse("22/03/2015")).to eq(nil)
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should parse times that match HH:mm:ss.SSS correctly" do
|
19
18
|
format = Csvlint::Csvw::DateFormat.new("HH:mm:ss.SSS")
|
20
|
-
expect(format.parse("12:34:56")).to eql({
|
21
|
-
expect(format.parse("12:34:56.78")).to eql({
|
22
|
-
expect(format.parse("12:34:56.789")).to eql({
|
19
|
+
expect(format.parse("12:34:56")).to eql({hour: 12, minute: 34, second: 56.0, string: "12:34:56", dateTime: DateTime.new(0, 1, 1, 12, 34, 56.0, "+00:00")})
|
20
|
+
expect(format.parse("12:34:56.78")).to eql({hour: 12, minute: 34, second: 56.78, string: "12:34:56.78", dateTime: DateTime.new(0, 1, 1, 12, 34, 56.78, "+00:00")})
|
21
|
+
expect(format.parse("12:34:56.789")).to eql({hour: 12, minute: 34, second: 56.789, string: "12:34:56.789", dateTime: DateTime.new(0, 1, 1, 12, 34, 56.789, "+00:00")})
|
23
22
|
expect(format.parse("12:34:56.7890")).to eql(nil)
|
24
23
|
expect(format.parse("22/03/2015")).to eq(nil)
|
25
24
|
end
|
@@ -45,5 +44,4 @@ describe Csvlint::Csvw::DateFormat do
|
|
45
44
|
expect(format.parse("2015-03-15T15:02:37")).to eql(nil)
|
46
45
|
expect(format.parse("3/15/2015 15:02")[:dateTime]).to eql(DateTime.new(2015, 3, 15, 15, 2))
|
47
46
|
end
|
48
|
-
|
49
47
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Csvlint::Csvw::NumberFormat do
|
4
|
-
|
5
4
|
it "should correctly parse #,##0.##" do
|
6
5
|
format = Csvlint::Csvw::NumberFormat.new("#,##0.##")
|
7
6
|
expect(format.pattern).to eq("#,##0.##")
|
@@ -397,7 +396,7 @@ describe Csvlint::Csvw::NumberFormat do
|
|
397
396
|
end
|
398
397
|
|
399
398
|
it "should parse numbers normally when there is no pattern" do
|
400
|
-
format = Csvlint::Csvw::NumberFormat.new
|
399
|
+
format = Csvlint::Csvw::NumberFormat.new
|
401
400
|
expect(format.parse("1")).to eql(1)
|
402
401
|
expect(format.parse("-1")).to eql(-1)
|
403
402
|
expect(format.parse("12.3")).to eql(12.3)
|
@@ -442,5 +441,4 @@ describe Csvlint::Csvw::NumberFormat do
|
|
442
441
|
expect(format.parse("1 234 567")).to eql(1234567)
|
443
442
|
expect(format.parse("1 234")).to eq(nil)
|
444
443
|
end
|
445
|
-
|
446
444
|
end
|
@@ -1,41 +1,40 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Csvlint::Csvw::TableGroup do
|
4
|
-
|
5
4
|
it "should inherit null to all columns" do
|
6
|
-
@metadata
|
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
|
-
}
|
5
|
+
@metadata = <<~EOL
|
6
|
+
{
|
7
|
+
"@context": "http://www.w3.org/ns/csvw",
|
8
|
+
"null": true,
|
9
|
+
"tables": [{
|
10
|
+
"url": "test040.csv",
|
11
|
+
"tableSchema": {
|
12
|
+
"columns": [{
|
13
|
+
"titles": "null"
|
14
|
+
}, {
|
15
|
+
"titles": "lang"
|
16
|
+
}, {
|
17
|
+
"titles": "textDirection"
|
18
|
+
}, {
|
19
|
+
"titles": "separator"
|
20
|
+
}, {
|
21
|
+
"titles": "ordered"
|
22
|
+
}, {
|
23
|
+
"titles": "default"
|
24
|
+
}, {
|
25
|
+
"titles": "datatype"
|
26
|
+
}, {
|
27
|
+
"titles": "aboutUrl"
|
28
|
+
}, {
|
29
|
+
"titles": "propertyUrl"
|
30
|
+
}, {
|
31
|
+
"titles": "valueUrl"
|
32
|
+
}]
|
33
|
+
}
|
34
|
+
}]
|
35
|
+
}
|
37
36
|
EOL
|
38
|
-
json = JSON.parse(
|
37
|
+
json = JSON.parse(@metadata)
|
39
38
|
table_group = Csvlint::Csvw::TableGroup.from_json("http://w3c.github.io/csvw/tests/test040-metadata.json", json)
|
40
39
|
|
41
40
|
expect(table_group.class).to eq(Csvlint::Csvw::TableGroup)
|
@@ -54,82 +53,81 @@ describe Csvlint::Csvw::TableGroup do
|
|
54
53
|
end
|
55
54
|
|
56
55
|
context "when parsing CSVW table group metadata" do
|
57
|
-
|
58
56
|
before(:each) do
|
59
|
-
@metadata
|
60
|
-
{
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
57
|
+
@metadata = <<~EOL
|
58
|
+
{
|
59
|
+
"@context": "http://www.w3.org/ns/csvw",
|
60
|
+
"tables": [{
|
61
|
+
"url": "countries.csv",
|
62
|
+
"tableSchema": {
|
63
|
+
"columns": [{
|
64
|
+
"name": "countryCode",
|
65
|
+
"titles": "countryCode",
|
66
|
+
"datatype": "string",
|
67
|
+
"propertyUrl": "http://www.geonames.org/ontology{#_name}"
|
68
|
+
}, {
|
69
|
+
"name": "latitude",
|
70
|
+
"titles": "latitude",
|
71
|
+
"datatype": "number"
|
72
|
+
}, {
|
73
|
+
"name": "longitude",
|
74
|
+
"titles": "longitude",
|
75
|
+
"datatype": "number"
|
76
|
+
}, {
|
77
|
+
"name": "name",
|
78
|
+
"titles": "name",
|
79
|
+
"datatype": "string"
|
80
|
+
}],
|
81
|
+
"aboutUrl": "http://example.org/countries.csv{#countryCode}",
|
82
|
+
"propertyUrl": "http://schema.org/{_name}",
|
83
|
+
"primaryKey": "countryCode"
|
84
|
+
}
|
85
|
+
}, {
|
86
|
+
"url": "country_slice.csv",
|
87
|
+
"tableSchema": {
|
88
|
+
"columns": [{
|
89
|
+
"name": "countryRef",
|
90
|
+
"titles": "countryRef",
|
91
|
+
"valueUrl": "http://example.org/countries.csv{#countryRef}"
|
92
|
+
}, {
|
93
|
+
"name": "year",
|
94
|
+
"titles": "year",
|
95
|
+
"datatype": "gYear"
|
96
|
+
}, {
|
97
|
+
"name": "population",
|
98
|
+
"titles": "population",
|
99
|
+
"datatype": "integer"
|
100
|
+
}],
|
101
|
+
"foreignKeys": [{
|
102
|
+
"columnReference": "countryRef",
|
103
|
+
"reference": {
|
104
|
+
"resource": "countries.csv",
|
105
|
+
"columnReference": "countryCode"
|
106
|
+
}
|
107
|
+
}]
|
108
|
+
}
|
109
|
+
}]
|
108
110
|
}
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
AF,1961,9799379
|
126
|
-
AF,1962,9989846
|
127
|
-
EOL
|
128
|
-
stub_request(:get, "http://w3c.github.io/csvw/tests/country_slice.csv").to_return(:status => 200, :body => @country_slice)
|
111
|
+
EOL
|
112
|
+
stub_request(:get, "http://w3c.github.io/csvw/tests/countries.json").to_return(status: 200, body: @metadata)
|
113
|
+
@countries = <<~EOL
|
114
|
+
countryCode,latitude,longitude,name
|
115
|
+
AD,42.546245,1.601554,Andorra
|
116
|
+
AE,23.424076,53.847818,"United Arab Emirates"
|
117
|
+
AF,33.93911,67.709953,Afghanistan
|
118
|
+
EOL
|
119
|
+
stub_request(:get, "http://w3c.github.io/csvw/tests/countries.csv").to_return(status: 200, body: @countries)
|
120
|
+
@country_slice = <<~EOL
|
121
|
+
countryRef,year,population
|
122
|
+
AF,1960,9616353
|
123
|
+
AF,1961,9799379
|
124
|
+
AF,1962,9989846
|
125
|
+
EOL
|
126
|
+
stub_request(:get, "http://w3c.github.io/csvw/tests/country_slice.csv").to_return(status: 200, body: @country_slice)
|
129
127
|
end
|
130
128
|
|
131
129
|
it "should create a table group from pre-parsed CSVW metadata" do
|
132
|
-
json = JSON.parse(
|
130
|
+
json = JSON.parse(@metadata)
|
133
131
|
table_group = Csvlint::Csvw::TableGroup.from_json("http://w3c.github.io/csvw/tests/countries.json", json)
|
134
132
|
|
135
133
|
expect(table_group.class).to eq(Csvlint::Csvw::TableGroup)
|
data/spec/csvw/table_spec.rb
CHANGED
@@ -1,84 +1,82 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Csvlint::Csvw::Table do
|
4
|
-
|
5
4
|
context "when parsing CSVW table metadata" do
|
6
|
-
|
7
5
|
before(:each) do
|
8
|
-
@metadata
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
6
|
+
@metadata = <<~EOL
|
7
|
+
{
|
8
|
+
"@context": "http://www.w3.org/ns/csvw",
|
9
|
+
"tables": [{
|
10
|
+
"url": "countries.csv",
|
11
|
+
"tableSchema": {
|
12
|
+
"columns": [{
|
13
|
+
"name": "countryCode",
|
14
|
+
"titles": "countryCode",
|
15
|
+
"datatype": "string",
|
16
|
+
"propertyUrl": "http://www.geonames.org/ontology{#_name}"
|
17
|
+
}, {
|
18
|
+
"name": "latitude",
|
19
|
+
"titles": "latitude",
|
20
|
+
"datatype": "number"
|
21
|
+
}, {
|
22
|
+
"name": "longitude",
|
23
|
+
"titles": "longitude",
|
24
|
+
"datatype": "number"
|
25
|
+
}, {
|
26
|
+
"name": "name",
|
27
|
+
"titles": "name",
|
28
|
+
"datatype": "string"
|
29
|
+
}],
|
30
|
+
"aboutUrl": "http://example.org/countries.csv{#countryCode}",
|
31
|
+
"propertyUrl": "http://schema.org/{_name}",
|
32
|
+
"primaryKey": "countryCode"
|
33
|
+
}
|
34
|
+
}, {
|
35
|
+
"url": "country_slice.csv",
|
36
|
+
"tableSchema": {
|
37
|
+
"columns": [{
|
38
|
+
"name": "countryRef",
|
39
|
+
"titles": "countryRef",
|
40
|
+
"valueUrl": "http://example.org/countries.csv{#countryRef}"
|
41
|
+
}, {
|
42
|
+
"name": "year",
|
43
|
+
"titles": "year",
|
44
|
+
"datatype": "gYear"
|
45
|
+
}, {
|
46
|
+
"name": "population",
|
47
|
+
"titles": "population",
|
48
|
+
"datatype": "integer"
|
49
|
+
}],
|
50
|
+
"foreignKeys": [{
|
51
|
+
"columnReference": "countryRef",
|
52
|
+
"reference": {
|
53
|
+
"resource": "countries.csv",
|
54
|
+
"columnReference": "countryCode"
|
55
|
+
}
|
56
|
+
}]
|
57
|
+
}
|
58
|
+
}]
|
57
59
|
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
AF,1961,9799379
|
75
|
-
AF,1962,9989846
|
76
|
-
EOL
|
77
|
-
stub_request(:get, "http://w3c.github.io/csvw/tests/country_slice.csv").to_return(:status => 200, :body => @country_slice)
|
60
|
+
EOL
|
61
|
+
stub_request(:get, "http://w3c.github.io/csvw/tests/countries.json").to_return(status: 200, body: @metadata)
|
62
|
+
@countries = <<~EOL
|
63
|
+
countryCode,latitude,longitude,name
|
64
|
+
AD,42.546245,1.601554,Andorra
|
65
|
+
AE,23.424076,53.847818,"United Arab Emirates"
|
66
|
+
AF,33.93911,67.709953,Afghanistan
|
67
|
+
EOL
|
68
|
+
stub_request(:get, "http://w3c.github.io/csvw/tests/countries.csv").to_return(status: 200, body: @countries)
|
69
|
+
@country_slice = <<~EOL
|
70
|
+
countryRef,year,population
|
71
|
+
AF,1960,9616353
|
72
|
+
AF,1961,9799379
|
73
|
+
AF,1962,9989846
|
74
|
+
EOL
|
75
|
+
stub_request(:get, "http://w3c.github.io/csvw/tests/country_slice.csv").to_return(status: 200, body: @country_slice)
|
78
76
|
end
|
79
77
|
|
80
78
|
it "should create a table from pre-parsed CSVW metadata" do
|
81
|
-
json = JSON.parse(
|
79
|
+
json = JSON.parse(@metadata)
|
82
80
|
table = Csvlint::Csvw::Table.from_json(json["tables"][0], "http://w3c.github.io/csvw/tests/countries.json")
|
83
81
|
|
84
82
|
expect(table).to be_a(Csvlint::Csvw::Table)
|