eaternet 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,96 @@
1
+ require 'test_helper'
2
+
3
+ require 'eaternet/framework/lives_1_0'
4
+ require 'eaternet/agencies/nyc'
5
+
6
+ CASSETTE = 'nyc'
7
+ MORRIS_PARK_CSV = 'test/fixtures/morris-park-bake-shop.csv'
8
+
9
+ class NycAdapterTest < Minitest::Test
10
+ @@nyc = Eaternet::Agencies::Nyc.new(csv_path: MORRIS_PARK_CSV)
11
+
12
+ #
13
+ # Businesses
14
+ #
15
+
16
+ def test_businesses_returns_an_enumerator_of_business
17
+ assert enumerable_of? Business, @@nyc.businesses
18
+ end
19
+
20
+ def test_businesses_returns_lives_attributes
21
+ b = @@nyc.businesses.first
22
+ assert_equal '30075445', b.business_id
23
+ assert_equal 'MORRIS PARK BAKE SHOP', b.name
24
+ assert_equal '1007 MORRIS PARK AVE', b.address
25
+ assert_equal 'BRONX', b.city
26
+ assert_equal '10462', b.postal_code
27
+ end
28
+
29
+ def test_businesses_returns_unique_rows
30
+ assert_equal 1, @@nyc.businesses.to_a.size
31
+ end
32
+
33
+ #
34
+ # Inspections
35
+ #
36
+
37
+ def test_inspections_returns_an_enumerable_of_inspection
38
+ assert enumerable_of? Inspection, @@nyc.inspections
39
+ end
40
+
41
+ # Use the wiki analysis document as a test.
42
+ # @see https://github.com/eaternet/adapters/wiki/Agency:-New-York-City
43
+ def test_inspections_finds_correct_dates
44
+ expected_dates = %w(
45
+ 02/09/2015
46
+ 03/03/2014
47
+ 09/11/2013
48
+ 08/14/2013
49
+ 01/24/2013
50
+ 12/31/2012).map{ |d| Date.strptime(d, '%m/%d/%Y')}
51
+ actual_dates = @@nyc.inspections.map(&:date).to_a
52
+ assert_equal expected_dates, actual_dates
53
+ end
54
+
55
+ def test_inspections_returns_lives_attributes
56
+ i = @@nyc.inspections.first(6).last
57
+ assert_equal '30075445', i.business_id
58
+ assert_equal Date.new(2012, 12, 31), i.date
59
+ assert_equal 75, i.score
60
+ end
61
+
62
+
63
+ #
64
+ # Violations
65
+ #
66
+
67
+ def test_violations_returns_an_enumerable_of_violation
68
+ assert enumerable_of? Violation, @@nyc.violations
69
+ end
70
+
71
+ def test_violations_returns_lives_attributes
72
+ v = @@nyc.violations.first
73
+ assert_equal '30075445', v.business_id
74
+ assert_equal Date.new(2015, 2, 9), v.date
75
+ assert_equal '06C', v.code
76
+ end
77
+
78
+ def test_finds_correct_violations
79
+ expected_violations = %w(06C 10F 04L 04N 04C 04L 06A 06C 08A 10F 02G 10F 02G 04L 06C 08A 10F)
80
+ actual_violations = @@nyc.violations.to_a.map(&:code)
81
+ assert_equal expected_violations, actual_violations
82
+ end
83
+
84
+ #
85
+ # metadata
86
+ #
87
+
88
+ def test_implements_feed_info
89
+ assert_instance_of FeedInfo, @@nyc.feed_info
90
+ end
91
+
92
+ def test_has_legends
93
+ assert_instance_of LegendGroup, @@nyc.legends
94
+ end
95
+
96
+ end
@@ -0,0 +1,99 @@
1
+ require 'test_helper'
2
+ require 'eaternet'
3
+
4
+ # Tests for the Southern Nevada Health District / Las Vegas
5
+
6
+ SNHD_CASSETTE = 'snhd'
7
+
8
+ class SnhdAdapterTest < Minitest::Test
9
+ @@snhd = Snhd.new
10
+
11
+ def test_businesses_returns_an_enumerator
12
+ VCR.use_cassette(SNHD_CASSETTE) do
13
+ assert_kind_of Enumerable, @@snhd.businesses
14
+ end
15
+ end
16
+
17
+ def test_businesses_returns_business_data_objects
18
+ VCR.use_cassette(SNHD_CASSETTE) do
19
+ assert_kind_of BusinessData, @@snhd.businesses.first
20
+ end
21
+ end
22
+
23
+ def test_businesses_returns_correct_data
24
+ VCR.use_cassette(SNHD_CASSETTE) do
25
+ b = @@snhd.businesses.first
26
+ assert_equal 'PR0000002', b.orig_key
27
+ assert_equal "McDonald's #3549 D HOTEL", b.name
28
+ assert_equal '301 Fremont St', b.address
29
+ assert_equal 'Las Vegas', b.city
30
+ assert_equal '89101-5600', b.zipcode
31
+ end
32
+ end
33
+
34
+ def test_inspections_returns_an_enumerable
35
+ VCR.use_cassette(SNHD_CASSETTE) do
36
+ assert_kind_of Enumerable, @@snhd.inspections
37
+ end
38
+ end
39
+
40
+ def test_inspections_returns_inspection_data_objects
41
+ VCR.use_cassette(SNHD_CASSETTE) do
42
+ assert_kind_of InspectionData, @@snhd.inspections.first
43
+ end
44
+ end
45
+
46
+ def test_inspections_returns_correct_data
47
+ VCR.use_cassette(SNHD_CASSETTE) do
48
+ i = @@snhd.inspections.first(6).last
49
+ assert_equal 'DA0001095', i.orig_key
50
+ assert_equal 'PR0000411', i.business_orig_key
51
+ assert_equal 'A', i.score
52
+ assert_equal '1994-04-15 00:00:00', i.date
53
+ end
54
+ end
55
+
56
+ def test_violations_returns_an_enumerable
57
+ VCR.use_cassette(SNHD_CASSETTE) do
58
+ assert_kind_of Enumerable, @@snhd.violations
59
+ end
60
+ end
61
+
62
+ def test_violations_returns_violation_data_objects
63
+ VCR.use_cassette(SNHD_CASSETTE) do
64
+ assert_kind_of ViolationData, @@snhd.violations.first
65
+ end
66
+ end
67
+
68
+ def test_violations_returns_correct_data
69
+ VCR.use_cassette(SNHD_CASSETTE) do
70
+ v = @@snhd.violations.first
71
+ assert_equal '1488', v.orig_key
72
+ assert_equal '537', v.inspection_id
73
+ assert_equal '64', v.violation_kind_id
74
+ end
75
+ end
76
+
77
+ def test_violation_kinds_returns_an_enumerable
78
+ VCR.use_cassette(SNHD_CASSETTE) do
79
+ assert_kind_of Enumerable, @@snhd.violation_kinds
80
+ end
81
+ end
82
+
83
+ def test_violation_kinds_returns_violation_kind_data_objects
84
+ VCR.use_cassette(SNHD_CASSETTE) do
85
+ assert_kind_of ViolationKindData, @@snhd.violation_kinds.first
86
+ end
87
+ end
88
+
89
+ def test_violation_kinds_returns_correct_data
90
+ VCR.use_cassette(SNHD_CASSETTE) do
91
+ v = @@snhd.violation_kinds.first
92
+ assert_equal '1', v.orig_key
93
+ assert_equal '1', v.code
94
+ assert_equal '6', v.demerits
95
+ assert_equal 'Food not obtained from approved sources and/or improperly identified.',
96
+ v.description
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,14 @@
1
+ require 'minitest/autorun'
2
+ require 'pry'
3
+ require 'vcr'
4
+
5
+ VCR.configure do |c|
6
+ c.cassette_library_dir = 'test/vcr_cassettes'
7
+ c.hook_into :webmock
8
+ end
9
+
10
+
11
+ def enumerable_of?(a_class, obj)
12
+ assert_kind_of Enumerable, obj
13
+ assert_kind_of a_class, obj.first
14
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eaternet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Robb Shecter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-utils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activemodel
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 4.2.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 4.2.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubyzip
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: A framework for easily retrieving a region's health scores in a standardized
140
+ way.
141
+ email:
142
+ - robb@eaternet.io
143
+ executables: []
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - eaternet.gemspec
154
+ - lib/eaternet.rb
155
+ - lib/eaternet/agencies/nyc.rb
156
+ - lib/eaternet/agencies/snhd.rb
157
+ - lib/eaternet/agencies/snhd_config.rb
158
+ - lib/eaternet/framework/lives_1_0.rb
159
+ - lib/eaternet/framework/prototype.rb
160
+ - lib/eaternet/util.rb
161
+ - lib/eaternet/version.rb
162
+ - lib/ext/lazy.rb
163
+ - test/fixtures/morris-park-bake-shop.csv
164
+ - test/lives_1_0/business_test.rb
165
+ - test/lives_1_0/feed_info_test.rb
166
+ - test/lives_1_0/inspection_test.rb
167
+ - test/lives_1_0/legend_test.rb
168
+ - test/nyc_adapter_test.rb
169
+ - test/snhd_adapter_test.rb
170
+ - test/test_helper.rb
171
+ homepage: https://github.com/eaternet/adapters-ruby
172
+ licenses:
173
+ - Apache
174
+ metadata: {}
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: 2.1.0
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 2.4.6
192
+ signing_key:
193
+ specification_version: 4
194
+ summary: Regional adapters for restaurant health scores
195
+ test_files:
196
+ - test/fixtures/morris-park-bake-shop.csv
197
+ - test/lives_1_0/business_test.rb
198
+ - test/lives_1_0/feed_info_test.rb
199
+ - test/lives_1_0/inspection_test.rb
200
+ - test/lives_1_0/legend_test.rb
201
+ - test/nyc_adapter_test.rb
202
+ - test/snhd_adapter_test.rb
203
+ - test/test_helper.rb