frizzle 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +151 -0
- data/Rakefile +10 -0
- data/frizzle.gemspec +30 -0
- data/lib/frizzle.rb +43 -0
- data/lib/frizzle/agencies.rb +32 -0
- data/lib/frizzle/arrival_estimates.rb +41 -0
- data/lib/frizzle/base.rb +58 -0
- data/lib/frizzle/exceptions.rb +8 -0
- data/lib/frizzle/routes.rb +25 -0
- data/lib/frizzle/segments.rb +32 -0
- data/lib/frizzle/stops.rb +23 -0
- data/lib/frizzle/vehicles.rb +41 -0
- data/lib/frizzle/version.rb +3 -0
- data/spec/fixtures/dish_cassettes/agencies.yml +214 -0
- data/spec/fixtures/dish_cassettes/agencies_find_options.yml +50 -0
- data/spec/fixtures/dish_cassettes/agencies_geo_default_radius.yml +54 -0
- data/spec/fixtures/dish_cassettes/agencies_geo_rectangle.yml +59 -0
- data/spec/fixtures/dish_cassettes/agencies_id_geo.yml +45 -0
- data/spec/fixtures/dish_cassettes/agency_geo_radius.yml +54 -0
- data/spec/fixtures/dish_cassettes/agency_id.yml +49 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies.yml +1353 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies_routes.yml +45 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies_routes_stops.yml +45 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_agencies_stops.yml +45 -0
- data/spec/fixtures/dish_cassettes/arrival_estimates_find_options.yml +1444 -0
- data/spec/fixtures/dish_cassettes/routes_agencies.yml +846 -0
- data/spec/fixtures/dish_cassettes/routes_agencies_geo.yml +336 -0
- data/spec/fixtures/dish_cassettes/routes_find_options.yml +846 -0
- data/spec/fixtures/dish_cassettes/segments_agency_and_geo_area.yml +48 -0
- data/spec/fixtures/dish_cassettes/segments_agency_and_route.yml +64 -0
- data/spec/fixtures/dish_cassettes/segments_agency_id.yml +245 -0
- data/spec/fixtures/dish_cassettes/segments_find_options.yml +242 -0
- data/spec/fixtures/dish_cassettes/stops_agency_id.yml +3841 -0
- data/spec/fixtures/dish_cassettes/stops_find_options.yml +3841 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies.yml +760 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies_geo_area.yml +45 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies_routes.yml +82 -0
- data/spec/fixtures/dish_cassettes/vehicles_agencies_routes_geo_area.yml +45 -0
- data/spec/fixtures/dish_cassettes/vehicles_find_options.yml +845 -0
- data/spec/lib/frizzle/agencies_spec.rb +169 -0
- data/spec/lib/frizzle/arrival_estimates_spec.rb +97 -0
- data/spec/lib/frizzle/base_spec.rb +105 -0
- data/spec/lib/frizzle/exceptions_spec.rb +0 -0
- data/spec/lib/frizzle/routes_spec.rb +85 -0
- data/spec/lib/frizzle/segments_spec.rb +91 -0
- data/spec/lib/frizzle/stops_spec.rb +63 -0
- data/spec/lib/frizzle/vehicles_spec.rb +99 -0
- data/spec/lib/frizzle/version_spec.rb +9 -0
- data/spec/spec_helper.rb +18 -0
- metadata +244 -0
@@ -0,0 +1,169 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe "Agencies" do
|
4
|
+
|
5
|
+
describe "match method to class" do
|
6
|
+
it "must match" do
|
7
|
+
Frizzle.agencies.must_be_same_as Frizzle::Agencies
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "GET agencies" do
|
12
|
+
let(:agencies) { Frizzle::Agencies.all }
|
13
|
+
|
14
|
+
before do
|
15
|
+
VCR.insert_cassette 'agencies', :record => :new_episodes
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
VCR.eject_cassette
|
20
|
+
end
|
21
|
+
|
22
|
+
it "records the fixture" do
|
23
|
+
Frizzle::Agencies.all
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must get the right agency name" do
|
27
|
+
agencies[0]['long_name'].must_equal "Chapel Hill Transit"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must get the right agency language" do
|
31
|
+
agencies[0]['language'].must_equal "en"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must return the right agency id" do
|
35
|
+
agencies[0]['agency_id'].must_equal "8"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "GET agencies with option hash" do
|
40
|
+
let(:agencies_find_options) { Frizzle::Agencies.find({:agencies => "12", :geo_area => "35.80176,-78.64347|100"}) }
|
41
|
+
|
42
|
+
before do
|
43
|
+
VCR.insert_cassette 'agencies_find_options'
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
VCR.eject_cassette
|
48
|
+
end
|
49
|
+
|
50
|
+
it "records the fixture" do
|
51
|
+
Frizzle::Agencies.find({:agencies => "12", :geo_area => "35.80176,-78.64347|100"})
|
52
|
+
end
|
53
|
+
|
54
|
+
it "must get the right agency name" do
|
55
|
+
agencies_find_options[0]['long_name'].must_equal "Triangle Transit"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "must return the right agency id" do
|
59
|
+
agencies_find_options[0]['agency_id'].must_equal "12"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "GET agencies by id" do
|
65
|
+
let(:agencies_id) { Frizzle::Agencies.find_by_id("168") }
|
66
|
+
|
67
|
+
before do
|
68
|
+
VCR.insert_cassette 'agency_id', :record => :new_episodes
|
69
|
+
end
|
70
|
+
|
71
|
+
after do
|
72
|
+
VCR.eject_cassette
|
73
|
+
end
|
74
|
+
|
75
|
+
it "records the fixture" do
|
76
|
+
Frizzle::Agencies.find_by_id("168")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must get the right agency name" do
|
80
|
+
agencies_id[0]['long_name'].must_equal "Kennesaw State University"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "must get the right agency language" do
|
84
|
+
agencies_id[0]['language'].must_equal "en"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "must return the right agency id" do
|
88
|
+
agencies_id[0]['agency_id'].must_equal "168"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "GET agencies by id and geo area" do
|
93
|
+
let(:agencies_id_geo) { Frizzle::Agencies.find_by_id_and_geo_area("168", [35.80176,-78.64347]) }
|
94
|
+
|
95
|
+
before do
|
96
|
+
VCR.insert_cassette 'agencies_id_geo', :record => :new_episodes
|
97
|
+
end
|
98
|
+
|
99
|
+
after do
|
100
|
+
VCR.eject_cassette
|
101
|
+
end
|
102
|
+
|
103
|
+
it "records the fixture" do
|
104
|
+
Frizzle::Agencies.find_by_id_and_geo_area("168", [35.80176,-78.64347])
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "GET agencies by geo radius" do
|
110
|
+
let(:agencies_geo_radius) { Frizzle::Agencies.find_by_geo_area([35.80176,-78.64347], 75.5) }
|
111
|
+
|
112
|
+
before do
|
113
|
+
VCR.insert_cassette 'agency_geo_radius', :record => :new_episodes
|
114
|
+
end
|
115
|
+
|
116
|
+
after do
|
117
|
+
VCR.eject_cassette
|
118
|
+
end
|
119
|
+
|
120
|
+
it "records the fixture" do
|
121
|
+
Frizzle::Agencies.find_by_geo_area([35.80176,-78.64347], 75.5)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "must get the right first agency name" do
|
125
|
+
agencies_geo_radius[0]['long_name'].must_equal "Triangle Transit"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "GET agencies by geo radius with default radius" do
|
130
|
+
let(:agencies_geo_default_radius) { Frizzle::Agencies.find_by_geo_area([35.80176,-78.64347]) }
|
131
|
+
|
132
|
+
before do
|
133
|
+
VCR.insert_cassette 'agencies_geo_default_radius', :record => :new_episodes
|
134
|
+
end
|
135
|
+
|
136
|
+
after do
|
137
|
+
VCR.eject_cassette
|
138
|
+
end
|
139
|
+
|
140
|
+
it "records the fixture" do
|
141
|
+
Frizzle::Agencies.find_by_geo_area([35.80176,-78.64347])
|
142
|
+
end
|
143
|
+
|
144
|
+
it "must get the right first agency name" do
|
145
|
+
agencies_geo_default_radius[0]['long_name'].must_equal "Triangle Transit"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "GET agencies by geo rectangle" do
|
150
|
+
let(:agencies_geo_rectangle) { Frizzle::Agencies.find_by_geo_area([35.80176,-78.64347], [35.78061,-78.68218]) }
|
151
|
+
|
152
|
+
before do
|
153
|
+
VCR.insert_cassette 'agencies_geo_rectangle', :record => :new_episodes
|
154
|
+
end
|
155
|
+
|
156
|
+
after do
|
157
|
+
VCR.eject_cassette
|
158
|
+
end
|
159
|
+
|
160
|
+
it "records the fixture" do
|
161
|
+
Frizzle::Agencies.find_by_geo_area([35.80176,-78.64347], [35.78061,-78.68218])
|
162
|
+
end
|
163
|
+
|
164
|
+
it "must get the right first agency name" do
|
165
|
+
agencies_geo_rectangle[0]['long_name'].must_equal "Triangle Transit"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "Arrival Estimates" do
|
5
|
+
|
6
|
+
describe "match method to class" do
|
7
|
+
it "must match" do
|
8
|
+
Frizzle.arrival_estimates.must_be_same_as Frizzle::ArrivalEstimates
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "find arrival estimates with hash" do
|
13
|
+
let(:arrival_estimates_find_options) { Frizzle::ArrivalEstimates.find({:agencies => "24"}) }
|
14
|
+
|
15
|
+
before do
|
16
|
+
VCR.insert_cassette 'arrival_estimates_find_options'
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
VCR.eject_cassette
|
21
|
+
end
|
22
|
+
|
23
|
+
it "records the fixture" do
|
24
|
+
Frizzle::ArrivalEstimates.find({:agencies => "24"})
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must have the correct route id" do
|
28
|
+
arrival_estimates_find_options[0]['arrivals'][0]['route_id'].must_equal "4000092"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "find arrival estimates with agencies" do
|
34
|
+
let(:arrival_estimates_agencies) { Frizzle::ArrivalEstimates.find_by_agencies("24") }
|
35
|
+
|
36
|
+
before do
|
37
|
+
VCR.insert_cassette 'arrival_estimates_agencies'
|
38
|
+
end
|
39
|
+
|
40
|
+
after do
|
41
|
+
VCR.eject_cassette
|
42
|
+
end
|
43
|
+
|
44
|
+
it "records the fixture" do
|
45
|
+
Frizzle::ArrivalEstimates.find_by_agencies("24")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "find arrival estimates with agencies and routes" do
|
50
|
+
let(:arrival_estimates_agencies_routes) { Frizzle::ArrivalEstimates.find_by_agencies_and_routes("24", ["4003034","4003038"]) }
|
51
|
+
|
52
|
+
before do
|
53
|
+
VCR.insert_cassette 'arrival_estimates_agencies_routes'
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
VCR.eject_cassette
|
58
|
+
end
|
59
|
+
|
60
|
+
it "records the fixture" do
|
61
|
+
Frizzle::ArrivalEstimates.find_by_agencies_and_routes("24", ["4003034","4003038"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "find arrival estimates with agencies and stops" do
|
66
|
+
let(:arrival_estimates_agencies_stops) { Frizzle::ArrivalEstimates.find_by_agencies_and_stops("24", "1029") }
|
67
|
+
|
68
|
+
before do
|
69
|
+
VCR.insert_cassette 'arrival_estimates_agencies_stops'
|
70
|
+
end
|
71
|
+
|
72
|
+
after do
|
73
|
+
VCR.eject_cassette
|
74
|
+
end
|
75
|
+
|
76
|
+
it "records the fixture" do
|
77
|
+
Frizzle::ArrivalEstimates.find_by_agencies_and_stops("24", "1029")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "find arrival estimates with agencies and stops" do
|
82
|
+
let(:arrival_estimates_agencies_routes_stops) { Frizzle::ArrivalEstimates.find_by_agencies_and_routes_and_stops("24", ["4003034","4003038"], "1029") }
|
83
|
+
|
84
|
+
before do
|
85
|
+
VCR.insert_cassette 'arrival_estimates_agencies_routes_stops'
|
86
|
+
end
|
87
|
+
|
88
|
+
after do
|
89
|
+
VCR.eject_cassette
|
90
|
+
end
|
91
|
+
|
92
|
+
it "records the fixture" do
|
93
|
+
Frizzle::ArrivalEstimates.find_by_agencies_and_routes_and_stops("24",["4003034","4003038"], "1029")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe "Base" do
|
4
|
+
|
5
|
+
describe "default attributes" do
|
6
|
+
|
7
|
+
it "must include default HTTParty attributes" do
|
8
|
+
Frizzle::Base.must_include HTTParty
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must include the Singleton class" do
|
12
|
+
Frizzle::Base.must_include Singleton
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "must include correct constants" do
|
18
|
+
|
19
|
+
it "must have the base url set to the Transloc API endpoint" do
|
20
|
+
Frizzle::Base.base_uri.must_equal "http://api.transloc.com/#{Frizzle::Base::API_VERSION}"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must have the API version match the Transloc API version" do
|
24
|
+
Frizzle::Base::API_VERSION.must_equal "1.2"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "it must use methods correctly" do
|
30
|
+
|
31
|
+
it "must detect if number is a number correctly" do
|
32
|
+
Frizzle::Base.is_numeric?(9).must_equal true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "must detect if number is a number correctly" do
|
36
|
+
Frizzle::Base.is_numeric?("9").must_equal true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must detect if a non-number isn't a number correctly" do
|
40
|
+
Frizzle::Base.is_numeric?("asdf").must_equal false
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must detect if an array isn't a number correctly" do
|
44
|
+
Frizzle::Base.is_numeric?([98,12]).must_equal false
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must format arrays correctly" do
|
48
|
+
Frizzle::Base.formatted_list(["123,644,901"]).must_equal "123,644,901"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "must format strings correctly" do
|
52
|
+
Frizzle::Base.formatted_list("123,644,901").must_equal "123,644,901"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "must format strings correctly" do
|
56
|
+
Frizzle::Base.formatted_list("123,644,901").must_equal "123,644,901"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "must format numbers correctly" do
|
60
|
+
Frizzle::Base.formatted_list(123).must_equal "123"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "must format number arrays correctly" do
|
64
|
+
Frizzle::Base.formatted_list([123,456,789]).must_equal "123,456,789"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "must format geo rectangle correctly" do
|
68
|
+
Frizzle::Base.formatted_geo_area([36,36],[87,87]).must_equal "36,36|87,87"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "must format geo rectangle correctly" do
|
72
|
+
Frizzle::Base.formatted_geo_area(['36','36'],['87','87']).must_equal "36,36|87,87"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "must format geo radius correctly" do
|
76
|
+
Frizzle::Base.formatted_geo_area(['36','36'],65).must_equal "36,36|65"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must format geo radius correctly with strings in array" do
|
80
|
+
Frizzle::Base.formatted_geo_area(['36','36'],65).must_equal "36,36|65"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "must format geo radius correctly with numbers in array" do
|
84
|
+
Frizzle::Base.formatted_geo_area([36,36],65).must_equal "36,36|65"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "must format geo radius correctly with radius as string" do
|
88
|
+
Frizzle::Base.formatted_geo_area([36,36],'65').must_equal "36,36|65"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "must format attributes correctly" do
|
92
|
+
lambda { Frizzle::Base.formatted_geo_area(65,65) }.must_raise ArgumentError
|
93
|
+
end
|
94
|
+
|
95
|
+
it "must have correct number of attributes" do
|
96
|
+
lambda { Frizzle::Base.formatted_geo_area(65) }.must_raise ArgumentError
|
97
|
+
end
|
98
|
+
|
99
|
+
it "must have default radius of 100 meters" do
|
100
|
+
Frizzle::Base.formatted_geo_area([35,-78]).must_equal "35,-78|100"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
File without changes
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe "Routes" do
|
4
|
+
|
5
|
+
describe "match method to class" do
|
6
|
+
it "must match" do
|
7
|
+
Frizzle.routes.must_be_same_as Frizzle::Routes
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "find routes with hash" do
|
12
|
+
let(:routes_find_options) { Frizzle::Routes.find({:agencies => "24"}) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
VCR.insert_cassette 'routes_find_options'
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
VCR.eject_cassette
|
20
|
+
end
|
21
|
+
|
22
|
+
it "records the fixture" do
|
23
|
+
Frizzle::Routes.find({:agencies => "24"})
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must match the right route id" do
|
27
|
+
routes_find_options['24'][0]['route_id'].must_equal "4000076"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must match the right route color" do
|
31
|
+
routes_find_options['24'][0]['color'].must_equal "23a135"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "find routes by agencies" do
|
36
|
+
let(:routes_agencies) { Frizzle::Routes.find_by_agencies("24") }
|
37
|
+
|
38
|
+
before do
|
39
|
+
VCR.insert_cassette 'routes_agencies'
|
40
|
+
end
|
41
|
+
|
42
|
+
after do
|
43
|
+
VCR.eject_cassette
|
44
|
+
end
|
45
|
+
|
46
|
+
it "records the fixture" do
|
47
|
+
Frizzle::Routes.find_by_agencies("24")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "must match the right route id" do
|
51
|
+
routes_agencies['24'][0]['route_id'].must_equal "4000076"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "must match the right route color" do
|
55
|
+
routes_agencies['24'][0]['color'].must_equal "23a135"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "find routes by agencies and geo area" do
|
61
|
+
let(:routes_agencies_geo) { Frizzle::Routes.find_by_agencies_and_geo_area(24, [35.98974,-78.90292]) }
|
62
|
+
|
63
|
+
before do
|
64
|
+
VCR.insert_cassette 'routes_agencies_geo'
|
65
|
+
end
|
66
|
+
|
67
|
+
after do
|
68
|
+
VCR.eject_cassette
|
69
|
+
end
|
70
|
+
|
71
|
+
it "records the fixture" do
|
72
|
+
Frizzle::Routes.find_by_agencies_and_geo_area(24, [35.98974,-78.90292])
|
73
|
+
end
|
74
|
+
|
75
|
+
it "must match the right route id" do
|
76
|
+
routes_agencies_geo['24'][0]['route_id'].must_equal "4000079"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must match the right route color" do
|
80
|
+
routes_agencies_geo['24'][0]['color'].must_equal "a05728"
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|