csvlint 0.4.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +11 -0
  3. data/.github/workflows/push.yml +35 -0
  4. data/.gitignore +1 -0
  5. data/.ruby-version +1 -1
  6. data/.standard_todo.yml +43 -0
  7. data/CHANGELOG.md +38 -0
  8. data/Dockerfile +16 -0
  9. data/Gemfile +2 -2
  10. data/README.md +13 -10
  11. data/Rakefile +7 -7
  12. data/bin/create_schema +2 -2
  13. data/csvlint.gemspec +19 -22
  14. data/docker_notes_for_windows.txt +20 -0
  15. data/features/step_definitions/cli_steps.rb +11 -11
  16. data/features/step_definitions/information_steps.rb +4 -4
  17. data/features/step_definitions/parse_csv_steps.rb +11 -11
  18. data/features/step_definitions/schema_validation_steps.rb +10 -10
  19. data/features/step_definitions/sources_steps.rb +1 -1
  20. data/features/step_definitions/validation_errors_steps.rb +19 -19
  21. data/features/step_definitions/validation_info_steps.rb +9 -9
  22. data/features/step_definitions/validation_warnings_steps.rb +11 -11
  23. data/features/support/aruba.rb +10 -9
  24. data/features/support/earl_formatter.rb +39 -39
  25. data/features/support/env.rb +10 -11
  26. data/features/support/load_tests.rb +109 -105
  27. data/features/support/webmock.rb +3 -1
  28. data/lib/csvlint/cli.rb +136 -142
  29. data/lib/csvlint/csvw/column.rb +279 -280
  30. data/lib/csvlint/csvw/date_format.rb +90 -92
  31. data/lib/csvlint/csvw/metadata_error.rb +1 -3
  32. data/lib/csvlint/csvw/number_format.rb +40 -32
  33. data/lib/csvlint/csvw/property_checker.rb +714 -717
  34. data/lib/csvlint/csvw/table.rb +49 -52
  35. data/lib/csvlint/csvw/table_group.rb +24 -23
  36. data/lib/csvlint/error_collector.rb +2 -0
  37. data/lib/csvlint/error_message.rb +0 -1
  38. data/lib/csvlint/field.rb +153 -141
  39. data/lib/csvlint/schema.rb +35 -43
  40. data/lib/csvlint/validate.rb +173 -151
  41. data/lib/csvlint/version.rb +1 -1
  42. data/lib/csvlint.rb +22 -23
  43. data/spec/csvw/column_spec.rb +15 -16
  44. data/spec/csvw/date_format_spec.rb +5 -7
  45. data/spec/csvw/number_format_spec.rb +2 -4
  46. data/spec/csvw/table_group_spec.rb +103 -105
  47. data/spec/csvw/table_spec.rb +71 -73
  48. data/spec/field_spec.rb +116 -121
  49. data/spec/schema_spec.rb +131 -141
  50. data/spec/spec_helper.rb +6 -6
  51. data/spec/validator_spec.rb +167 -203
  52. metadata +41 -85
  53. data/.travis.yml +0 -37
@@ -1,7 +1,6 @@
1
- require 'spec_helper'
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: { "base" => "http://www.w3.org/2001/XMLSchema#string", "minLength" => 4 })
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({ :invalid => "bar" })
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: { "base" => "http://www.w3.org/2001/XMLSchema#string", "minLength" => 4 })
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=<<-EOL
26
+ @desc = <<-EOL
28
27
  {
29
28
  "name": "countryCode"
30
29
  }
31
30
  EOL
32
- json = JSON.parse( @desc )
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({ "@id" => "http://www.w3.org/2001/XMLSchema#string" })
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=<<-EOL
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( @desc )
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({ "@id" => "http://www.w3.org/2001/XMLSchema#string" })
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({ "und" => [ "countryCode" ]})
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=<<-EOL
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({ "base" => "http://www.w3.org/2001/XMLSchema#string", "minLength" => 3 })
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=<<-EOL
99
+ @desc = <<-EOL
101
100
  {
102
101
  "name": "countryCode",
103
102
  "null": true
104
103
  }
105
104
  EOL
106
- json = JSON.parse( @desc )
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 'spec_helper'
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({ :hour => 12, :minute => 34, :second => 56.0, :string => "12:34:56", :dateTime => DateTime.new(0,1,1,12,34,56.0,"+00:00") })
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({ :hour => 12, :minute => 34, :second => 56.0, :string => "12:34:56", :dateTime => DateTime.new(0,1,1,12,34,56.0,"+00:00") })
21
- 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") })
22
- 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") })
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 'spec_helper'
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 'spec_helper'
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=<<-EOL
7
- {
8
- "@context": "http://www.w3.org/ns/csvw",
9
- "null": true,
10
- "tables": [{
11
- "url": "test040.csv",
12
- "tableSchema": {
13
- "columns": [{
14
- "titles": "null"
15
- }, {
16
- "titles": "lang"
17
- }, {
18
- "titles": "textDirection"
19
- }, {
20
- "titles": "separator"
21
- }, {
22
- "titles": "ordered"
23
- }, {
24
- "titles": "default"
25
- }, {
26
- "titles": "datatype"
27
- }, {
28
- "titles": "aboutUrl"
29
- }, {
30
- "titles": "propertyUrl"
31
- }, {
32
- "titles": "valueUrl"
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( @metadata )
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=<<-EOL
60
- {
61
- "@context": "http://www.w3.org/ns/csvw",
62
- "tables": [{
63
- "url": "countries.csv",
64
- "tableSchema": {
65
- "columns": [{
66
- "name": "countryCode",
67
- "titles": "countryCode",
68
- "datatype": "string",
69
- "propertyUrl": "http://www.geonames.org/ontology{#_name}"
70
- }, {
71
- "name": "latitude",
72
- "titles": "latitude",
73
- "datatype": "number"
74
- }, {
75
- "name": "longitude",
76
- "titles": "longitude",
77
- "datatype": "number"
78
- }, {
79
- "name": "name",
80
- "titles": "name",
81
- "datatype": "string"
82
- }],
83
- "aboutUrl": "http://example.org/countries.csv{#countryCode}",
84
- "propertyUrl": "http://schema.org/{_name}",
85
- "primaryKey": "countryCode"
86
- }
87
- }, {
88
- "url": "country_slice.csv",
89
- "tableSchema": {
90
- "columns": [{
91
- "name": "countryRef",
92
- "titles": "countryRef",
93
- "valueUrl": "http://example.org/countries.csv{#countryRef}"
94
- }, {
95
- "name": "year",
96
- "titles": "year",
97
- "datatype": "gYear"
98
- }, {
99
- "name": "population",
100
- "titles": "population",
101
- "datatype": "integer"
102
- }],
103
- "foreignKeys": [{
104
- "columnReference": "countryRef",
105
- "reference": {
106
- "resource": "countries.csv",
107
- "columnReference": "countryCode"
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
- EOL
114
- stub_request(:get, "http://w3c.github.io/csvw/tests/countries.json").to_return(:status => 200, :body => @metadata)
115
- @countries=<<-EOL
116
- countryCode,latitude,longitude,name
117
- AD,42.546245,1.601554,Andorra
118
- AE,23.424076,53.847818,"United Arab Emirates"
119
- AF,33.93911,67.709953,Afghanistan
120
- EOL
121
- stub_request(:get, "http://w3c.github.io/csvw/tests/countries.csv").to_return(:status => 200, :body => @countries)
122
- @country_slice=<<-EOL
123
- countryRef,year,population
124
- AF,1960,9616353
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( @metadata )
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)
@@ -1,84 +1,82 @@
1
- require 'spec_helper'
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=<<-EOL
9
- {
10
- "@context": "http://www.w3.org/ns/csvw",
11
- "tables": [{
12
- "url": "countries.csv",
13
- "tableSchema": {
14
- "columns": [{
15
- "name": "countryCode",
16
- "titles": "countryCode",
17
- "datatype": "string",
18
- "propertyUrl": "http://www.geonames.org/ontology{#_name}"
19
- }, {
20
- "name": "latitude",
21
- "titles": "latitude",
22
- "datatype": "number"
23
- }, {
24
- "name": "longitude",
25
- "titles": "longitude",
26
- "datatype": "number"
27
- }, {
28
- "name": "name",
29
- "titles": "name",
30
- "datatype": "string"
31
- }],
32
- "aboutUrl": "http://example.org/countries.csv{#countryCode}",
33
- "propertyUrl": "http://schema.org/{_name}",
34
- "primaryKey": "countryCode"
35
- }
36
- }, {
37
- "url": "country_slice.csv",
38
- "tableSchema": {
39
- "columns": [{
40
- "name": "countryRef",
41
- "titles": "countryRef",
42
- "valueUrl": "http://example.org/countries.csv{#countryRef}"
43
- }, {
44
- "name": "year",
45
- "titles": "year",
46
- "datatype": "gYear"
47
- }, {
48
- "name": "population",
49
- "titles": "population",
50
- "datatype": "integer"
51
- }],
52
- "foreignKeys": [{
53
- "columnReference": "countryRef",
54
- "reference": {
55
- "resource": "countries.csv",
56
- "columnReference": "countryCode"
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
- EOL
63
- stub_request(:get, "http://w3c.github.io/csvw/tests/countries.json").to_return(:status => 200, :body => @metadata)
64
- @countries=<<-EOL
65
- countryCode,latitude,longitude,name
66
- AD,42.546245,1.601554,Andorra
67
- AE,23.424076,53.847818,"United Arab Emirates"
68
- AF,33.93911,67.709953,Afghanistan
69
- EOL
70
- stub_request(:get, "http://w3c.github.io/csvw/tests/countries.csv").to_return(:status => 200, :body => @countries)
71
- @country_slice=<<-EOL
72
- countryRef,year,population
73
- AF,1960,9616353
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( @metadata )
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)