ninoxe 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/chouette/vehicle_journey_at_stop.rb +5 -5
  3. data/lib/ninoxe/version.rb +1 -1
  4. data/spec/dummy/README.rdoc +28 -0
  5. data/spec/dummy/Rakefile +6 -0
  6. data/spec/dummy/app/assets/images/.keep +0 -0
  7. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  8. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  9. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  10. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  11. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  12. data/spec/dummy/app/mailers/.keep +0 -0
  13. data/spec/dummy/app/models/.keep +0 -0
  14. data/spec/dummy/app/models/concerns/.keep +0 -0
  15. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  16. data/spec/dummy/bin/bundle +3 -0
  17. data/spec/dummy/bin/rails +4 -0
  18. data/spec/dummy/bin/rake +4 -0
  19. data/spec/dummy/config.ru +4 -0
  20. data/spec/dummy/config/application.rb +28 -0
  21. data/spec/dummy/config/boot.rb +5 -0
  22. data/spec/dummy/config/database.yml +19 -0
  23. data/spec/dummy/config/environment.rb +5 -0
  24. data/spec/dummy/config/environments/development.rb +29 -0
  25. data/spec/dummy/config/environments/production.rb +80 -0
  26. data/spec/dummy/config/environments/test.rb +36 -0
  27. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  28. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  29. data/spec/dummy/config/initializers/inflections.rb +16 -0
  30. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  31. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  32. data/spec/dummy/config/initializers/session_store.rb +3 -0
  33. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  34. data/spec/dummy/config/locales/en.yml +23 -0
  35. data/spec/dummy/config/locales/fr.yml +23 -0
  36. data/spec/dummy/config/routes.rb +4 -0
  37. data/spec/dummy/db/schema.rb +490 -0
  38. data/spec/dummy/db/test.sqlite3 +0 -0
  39. data/spec/dummy/lib/assets/.keep +0 -0
  40. data/spec/dummy/log/.keep +0 -0
  41. data/spec/dummy/public/404.html +58 -0
  42. data/spec/dummy/public/422.html +58 -0
  43. data/spec/dummy/public/500.html +57 -0
  44. data/spec/dummy/public/favicon.ico +0 -0
  45. data/spec/dummy/script/rails +6 -0
  46. data/spec/factories/chouette_access_links.rb +13 -0
  47. data/spec/factories/chouette_access_points.rb +12 -0
  48. data/spec/factories/chouette_companies.rb +9 -0
  49. data/spec/factories/chouette_connection_links.rb +13 -0
  50. data/spec/factories/chouette_footnotes.rb +10 -0
  51. data/spec/factories/chouette_group_of_lines.rb +9 -0
  52. data/spec/factories/chouette_journey_pattern.rb +40 -0
  53. data/spec/factories/chouette_lines.rb +44 -0
  54. data/spec/factories/chouette_networks.rb +9 -0
  55. data/spec/factories/chouette_routes.rb +26 -0
  56. data/spec/factories/chouette_stop_areas.rb +12 -0
  57. data/spec/factories/chouette_stop_points.rb +10 -0
  58. data/spec/factories/chouette_time_table.rb +37 -0
  59. data/spec/factories/chouette_vehicle_journey.rb +66 -0
  60. data/spec/factories/chouette_vehicle_journey_at_stop.rb +8 -0
  61. data/spec/models/chouette/access_link_spec.rb +82 -0
  62. data/spec/models/chouette/access_point_spec.rb +269 -0
  63. data/spec/models/chouette/active_record_spec.rb +121 -0
  64. data/spec/models/chouette/area_type_spec.rb +53 -0
  65. data/spec/models/chouette/company_spec.rb +48 -0
  66. data/spec/models/chouette/connection_link_spec.rb +60 -0
  67. data/spec/models/chouette/direction_spec.rb +60 -0
  68. data/spec/models/chouette/exporter_spec.rb +28 -0
  69. data/spec/models/chouette/file_validator_spec.rb +28 -0
  70. data/spec/models/chouette/footnote_spec.rb +9 -0
  71. data/spec/models/chouette/group_of_line_spec.rb +31 -0
  72. data/spec/models/chouette/journey_pattern_spec.rb +64 -0
  73. data/spec/models/chouette/line_spec.rb +120 -0
  74. data/spec/models/chouette/loader_spec.rb +69 -0
  75. data/spec/models/chouette/network_spec.rb +19 -0
  76. data/spec/models/chouette/object_id_spec.rb +149 -0
  77. data/spec/models/chouette/route_spec.rb +238 -0
  78. data/spec/models/chouette/stop_area_spec.rb +443 -0
  79. data/spec/models/chouette/stop_point_spec.rb +41 -0
  80. data/spec/models/chouette/time_table_period_spec.rb +66 -0
  81. data/spec/models/chouette/time_table_spec.rb +1266 -0
  82. data/spec/models/chouette/transport_mode_spec.rb +64 -0
  83. data/spec/models/chouette/trident_active_record_spec.rb +115 -0
  84. data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +47 -0
  85. data/spec/models/chouette/vehicle_journey_spec.rb +223 -0
  86. data/spec/presenters/chouette/geometry/general_presenter.rb +1 -0
  87. data/spec/presenters/chouette/geometry/line_presenter_spec.rb +13 -0
  88. data/spec/spec_helper.rb +58 -0
  89. metadata +178 -10
  90. data/config/database.yml.me +0 -11
  91. data/lib/ninoxe.rb~ +0 -7
@@ -0,0 +1,66 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :vehicle_journey_common, :class => Chouette::VehicleJourney do
4
+ sequence(:objectid) { |n| "test:VehicleJourney:#{n}" }
5
+
6
+ factory :vehicle_journey do
7
+ association :journey_pattern, :factory => :journey_pattern
8
+
9
+ after(:build) do |vehicle_journey|
10
+ vehicle_journey.route = vehicle_journey.journey_pattern.route
11
+ end
12
+
13
+ after(:create) do |vehicle_journey|
14
+ vehicle_journey.journey_pattern.stop_points.each_with_index do |stop_point, index|
15
+ vehicle_journey.vehicle_journey_at_stops << create(:vehicle_journey_at_stop,
16
+ :vehicle_journey => vehicle_journey,
17
+ :stop_point => stop_point,
18
+ :arrival_time => (-1 * index).minutes.ago,
19
+ :departure_time => (-1 * index).minutes.ago)
20
+ end
21
+ end
22
+
23
+ factory :vehicle_journey_odd do
24
+ association :journey_pattern, :factory => :journey_pattern_odd
25
+ end
26
+
27
+ factory :vehicle_journey_even do
28
+ association :journey_pattern, :factory => :journey_pattern_even
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ # after(:build) do |vehicle_journey|
35
+ # vehicle_journey.route_id = vehicle_journey.journey_pattern.route_id
36
+ # end
37
+ #
38
+ # after(:create) do |vehicle_journey|
39
+ # vehicle_journey.journey_pattern.stop_points.each_with_index do |stop_point, index|
40
+ # vehicle_journey.vehicle_journey_at_stops.create(:vehicle_journey_at_stop,
41
+ # :vehicle_journey => vehicle_journey,
42
+ # :stop_point => stop_point,
43
+ # :arrival_time => (-1 * index).minutes.ago,
44
+ # :departure_time => (-1 * index).minutes.ago)
45
+ # end
46
+ # end
47
+ # end
48
+ #
49
+ # after(:build) do |vehicle_journey|
50
+ # vehicle_journey.route_id = vehicle_journey.journey_pattern.route_id
51
+ # end
52
+ #
53
+ # after(:create) do |vehicle_journey|
54
+ # vehicle_journey.journey_pattern.stop_points.each_with_index do |stop_point, index|
55
+ # vehicle_journey.vehicle_journey_at_stops.create(:vehicle_journey_at_stop,
56
+ # :vehicle_journey => vehicle_journey,
57
+ # :stop_point => stop_point,
58
+ # :arrival_time => (-1 * index).minutes.ago,
59
+ # :departure_time => (-1 * index).minutes.ago)
60
+ # end
61
+ # end
62
+ # end
63
+ #
64
+ # end
65
+ #end
66
+ #
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :vehicle_journey_at_stop, :class => Chouette::VehicleJourneyAtStop do
4
+ association :vehicle_journey, :factory => :vehicle_journey
5
+ end
6
+
7
+ end
8
+
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::AccessLink, :type => :model do
4
+ subject { create(:access_link) }
5
+
6
+ it { is_expected.to validate_uniqueness_of :objectid }
7
+
8
+ describe '#objectid' do
9
+ subject { super().objectid }
10
+ it { is_expected.to be_kind_of(Chouette::ObjectId) }
11
+ end
12
+
13
+ it { is_expected.to validate_presence_of :name }
14
+ #it { is_expected.to validate_presence_of :link_type }
15
+ it { is_expected.to validate_presence_of :link_orientation }
16
+
17
+ describe "#access_link_type" do
18
+
19
+ def self.legacy_link_types
20
+ %w{Underground Mixed Overground}
21
+ end
22
+
23
+ legacy_link_types.each do |link_type|
24
+ context "when link_type is #{link_type}" do
25
+ access_link_type = Chouette::ConnectionLinkType.new(link_type.underscore)
26
+ it "should be #{access_link_type}" do
27
+ subject.link_type = link_type
28
+ expect(subject.access_link_type).to eq(access_link_type)
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#access_link_type=" do
35
+
36
+ it "should change link_type with ConnectionLinkType#name" do
37
+ subject.access_link_type = "underground"
38
+ expect(subject.link_type).to eq("Underground")
39
+ end
40
+
41
+ end
42
+
43
+ describe "#link_orientation_type" do
44
+
45
+ def self.legacy_link_orientations
46
+ %w{AccessPointToStopArea StopAreaToAccessPoint}
47
+ end
48
+
49
+ legacy_link_orientations.each do |link_orientation|
50
+ context "when link_orientation is #{link_orientation}" do
51
+ link_orientation_type = Chouette::LinkOrientationType.new(link_orientation.underscore)
52
+ it "should be #{link_orientation_type}" do
53
+ subject.link_orientation = link_orientation
54
+ expect(subject.link_orientation_type).to eq(link_orientation_type)
55
+ end
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ describe "#link_orientation_type=" do
62
+
63
+ it "should change link_orientation with LinkOrientationType#name" do
64
+ subject.link_orientation_type = "access_point_to_stop_area"
65
+ expect(subject.link_orientation).to eq("AccessPointToStopArea")
66
+ end
67
+
68
+ end
69
+
70
+ describe "#link_key" do
71
+ it "should calculate link_key for access to area" do
72
+ subject.link_orientation_type = "access_point_to_stop_area"
73
+ expect(subject.link_key).to eq("A_#{subject.access_point.id}-S_#{subject.stop_area.id}")
74
+ end
75
+ it "should calculate link_key for area to access" do
76
+ subject.link_orientation_type = "stop_area_to_access_point"
77
+ expect(subject.link_key).to eq("S_#{subject.stop_area.id}-A_#{subject.access_point.id}")
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,269 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::AccessPoint, :type => :model do
4
+
5
+ describe '#objectid' do
6
+ subject { super().objectid }
7
+ it { is_expected.to be_kind_of(Chouette::ObjectId) }
8
+ end
9
+
10
+ it { is_expected.to validate_presence_of :name }
11
+ it { is_expected.to validate_numericality_of :latitude }
12
+ it { is_expected.to validate_numericality_of :longitude }
13
+
14
+ describe ".latitude" do
15
+ it "should accept -90 value" do
16
+ subject = create :access_point
17
+ subject.latitude = -90
18
+ expect(subject.valid?).to be_truthy
19
+ end
20
+ it "should reject < -90 value" do
21
+ subject = create :access_point
22
+ subject.latitude = -90.0001
23
+ expect(subject.valid?).to be_falsey
24
+ end
25
+ it "should accept 90 value" do
26
+ subject = create :access_point
27
+ subject.latitude = 90
28
+ expect(subject.valid?).to be_truthy
29
+ end
30
+ it "should reject > 90 value" do
31
+ subject = create :access_point
32
+ subject.latitude = 90.0001
33
+ expect(subject.valid?).to be_falsey
34
+ end
35
+ end
36
+
37
+ describe ".longitude" do
38
+ it "should accept -180 value" do
39
+ subject = create :access_point
40
+ subject.longitude = -180
41
+ expect(subject.valid?).to be_truthy
42
+ end
43
+ it "should reject < -180 value" do
44
+ subject = create :access_point
45
+ subject.longitude = -180.0001
46
+ expect(subject.valid?).to be_falsey
47
+ end
48
+ it "should accept 180 value" do
49
+ subject = create :access_point
50
+ subject.longitude = 180
51
+ expect(subject.valid?).to be_truthy
52
+ end
53
+ it "should reject > 180 value" do
54
+ subject = create :access_point
55
+ subject.longitude = 180.0001
56
+ expect(subject.valid?).to be_falsey
57
+ end
58
+ end
59
+
60
+ describe ".long_lat" do
61
+ it "should accept longitude and latitude both as nil" do
62
+ subject = create :access_point
63
+ subject.longitude = nil
64
+ subject.latitude = nil
65
+ expect(subject.valid?).to be_truthy
66
+ end
67
+ it "should accept longitude and latitude both numerical" do
68
+ subject = create :access_point
69
+ subject.longitude = 10
70
+ subject.latitude = 10
71
+ expect(subject.valid?).to be_truthy
72
+ end
73
+ it "should reject longitude nil with latitude numerical" do
74
+ subject = create :access_point
75
+ subject.longitude = nil
76
+ subject.latitude = 10
77
+ expect(subject.valid?).to be_falsey
78
+ end
79
+ it "should reject longitude numerical with latitude nil" do
80
+ subject = create :access_point
81
+ subject.longitude = 10
82
+ subject.latitude = nil
83
+ expect(subject.valid?).to be_falsey
84
+ end
85
+ end
86
+
87
+ describe "#access_type" do
88
+ def self.legacy_access_types
89
+ %w{In Out InOut}
90
+ end
91
+
92
+ legacy_access_types.each do |access_type|
93
+ context "when access_type is #{access_type}" do
94
+ access_point_type = Chouette::AccessPointType.new(access_type.underscore)
95
+ it "should be #{access_point_type}" do
96
+ subject.access_type = access_type
97
+ expect(subject.access_point_type).to eq(access_point_type)
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ describe "#access_point_type=" do
104
+ it "should change access_type with Chouette::AccessPointType#name" do
105
+ subject.access_point_type = "in_out"
106
+ expect(subject.access_type).to eq("InOut")
107
+ end
108
+
109
+ end
110
+
111
+ describe "#to_lat_lng" do
112
+
113
+ it "should return nil if latitude is nil" do
114
+ subject.latitude = nil
115
+ expect(subject.to_lat_lng).to be_nil
116
+ end
117
+
118
+ it "should return nil if longitude is nil" do
119
+ subject.longitude = nil
120
+ expect(subject.to_lat_lng).to be_nil
121
+ end
122
+
123
+ end
124
+
125
+ describe "#geometry" do
126
+
127
+ it "should be nil when to_lat_lng is nil" do
128
+ allow(subject).to receive_messages :to_lat_lng => nil
129
+ expect(subject.geometry).to be_nil
130
+ end
131
+
132
+ end
133
+
134
+ describe "#generic_access_link_matrix" do
135
+ it "should have 2 generic_access_links in matrix" do
136
+ stop_place = create :stop_area, :area_type => "StopPlace"
137
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
138
+ subject = create :access_point, :stop_area => stop_place
139
+ expect(subject.generic_access_link_matrix.size).to eq(2)
140
+ end
141
+
142
+ it "should have new generic_access_links in matrix" do
143
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
144
+ subject = create :access_point, :stop_area => commercial_stop_point
145
+ subject.generic_access_link_matrix.each do |link|
146
+ expect(link.id).to be_nil
147
+ end
148
+ end
149
+ it "should have only last generic_access_links as new in matrix" do
150
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
151
+ subject = create :access_point, :stop_area => commercial_stop_point
152
+ link = create :access_link, :access_point => subject, :stop_area => commercial_stop_point
153
+ subject.generic_access_link_matrix.each do |link|
154
+ if link.link_key.start_with?"A_"
155
+ expect(link.id).not_to be_nil
156
+ else
157
+ expect(link.id).to be_nil
158
+ end
159
+ end
160
+ end
161
+ end
162
+
163
+ describe "#detail_access_link_matrix" do
164
+ it "should have 4 detail_access_links in matrix" do
165
+ stop_place = create :stop_area, :area_type => "StopPlace"
166
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint" ,:parent => stop_place
167
+ quay1 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
168
+ quay2 = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
169
+ subject = create :access_point, :stop_area => stop_place
170
+ expect(subject.detail_access_link_matrix.size).to eq(4)
171
+ end
172
+
173
+ it "should have new detail_access_links in matrix" do
174
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
175
+ quay = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
176
+ subject = create :access_point, :stop_area => commercial_stop_point
177
+ subject.detail_access_link_matrix.each do |link|
178
+ expect(link.id).to be_nil
179
+ end
180
+ end
181
+ it "should have only last detail_access_links as new in matrix" do
182
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
183
+ quay = create :stop_area, :parent => commercial_stop_point, :area_type => "Quay"
184
+ subject = create :access_point, :stop_area => commercial_stop_point
185
+ link = create :access_link, :access_point => subject, :stop_area => quay
186
+ subject.detail_access_link_matrix.each do |link|
187
+ if link.link_key.start_with?"A_"
188
+ expect(link.id).not_to be_nil
189
+ else
190
+ expect(link.id).to be_nil
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ describe "#coordinates" do
197
+ it "should convert coordinates into latitude/longitude" do
198
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
199
+ subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "45.123,120.456"
200
+ expect(subject.longitude).to be_within(0.001).of(120.456)
201
+ expect(subject.latitude).to be_within(0.001).of(45.123)
202
+ end
203
+ it "should set empty coordinates into nil latitude/longitude" do
204
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
205
+ subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "45.123,120.456"
206
+ expect(subject.longitude).to be_within(0.001).of(120.456)
207
+ expect(subject.latitude).to be_within(0.001).of(45.123)
208
+ subject.coordinates = ""
209
+ subject.save
210
+ expect(subject.longitude).to be_nil
211
+ expect(subject.latitude).to be_nil
212
+ end
213
+ it "should convert latitude/longitude into coordinates" do
214
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
215
+ subject = create :access_point, :stop_area => commercial_stop_point, :longitude => 120.456, :latitude => 45.123
216
+ expect(subject.coordinates).to eq("45.123,120.456")
217
+ end
218
+ it "should convert nil latitude/longitude into empty coordinates" do
219
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
220
+ subject = create :access_point, :stop_area => commercial_stop_point, :longitude => nil, :latitude => nil
221
+ expect(subject.coordinates).to eq("")
222
+ end
223
+ it "should accept valid coordinates" do
224
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
225
+ subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "45.123,120.456"
226
+ expect(subject.valid?).to be_truthy
227
+ subject.coordinates = "45.123, 120.456"
228
+ expect(subject.valid?).to be_truthy
229
+ expect(subject.longitude).to be_within(0.001).of(120.456)
230
+ expect(subject.latitude).to be_within(0.001).of(45.123)
231
+ subject.coordinates = "45.123, -120.456"
232
+ expect(subject.valid?).to be_truthy
233
+ subject.coordinates = "45.123 ,120.456"
234
+ expect(subject.valid?).to be_truthy
235
+ subject.coordinates = "45.123 , 120.456"
236
+ expect(subject.valid?).to be_truthy
237
+ subject.coordinates = " 45.123,120.456"
238
+ expect(subject.valid?).to be_truthy
239
+ subject.coordinates = "45.123,120.456 "
240
+ expect(subject.valid?).to be_truthy
241
+ end
242
+ it "should accept valid coordinates on limits" do
243
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
244
+ subject = create :access_point, :stop_area => commercial_stop_point, :coordinates => "90,180"
245
+ expect(subject.valid?).to be_truthy
246
+ subject.coordinates = "-90,-180"
247
+ expect(subject.valid?).to be_truthy
248
+ subject.coordinates = "-90.,180."
249
+ expect(subject.valid?).to be_truthy
250
+ subject.coordinates = "-90.0,180.00"
251
+ expect(subject.valid?).to be_truthy
252
+ end
253
+ it "should reject invalid coordinates" do
254
+ commercial_stop_point = create :stop_area, :area_type => "CommercialStopPoint"
255
+ subject = create :access_point, :stop_area => commercial_stop_point
256
+ subject.coordinates = ",12"
257
+ expect(subject.valid?).to be_falsey
258
+ subject.coordinates = "-90"
259
+ expect(subject.valid?).to be_falsey
260
+ subject.coordinates = "-90.1,180."
261
+ expect(subject.valid?).to be_falsey
262
+ subject.coordinates = "-90.0,180.1"
263
+ expect(subject.valid?).to be_falsey
264
+ subject.coordinates = "-91.0,18.1"
265
+ expect(subject.valid?).to be_falsey
266
+ end
267
+ end
268
+
269
+ end
@@ -0,0 +1,121 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chouette::ActiveRecord, :type => :model do
4
+
5
+ it { expect(Chouette::ActiveRecord.ancestors).to include(ActiveRecord::Base) }
6
+
7
+ describe "table_name" do
8
+
9
+ it "should return line for Chouette::Line" do
10
+ expect(Chouette::Line.table_name).to eq("lines")
11
+ end
12
+
13
+ it "should return ptnetwork for Chouette::Network" do
14
+ expect(Chouette::Network.table_name).to eq("networks")
15
+ end
16
+
17
+ it "should return timetable_date for Chouette::TimeTableDate" do
18
+ expect(Chouette::TimeTableDate.table_name).to eq("time_table_dates")
19
+ end
20
+
21
+ it "should return timetable_period for Chouette::TimeTablePeriod" do
22
+ expect(Chouette::TimeTablePeriod.table_name).to eq("time_table_periods")
23
+ end
24
+
25
+ end
26
+
27
+ describe "method_missing" do
28
+
29
+ it "should support method with additionnal underscores" do
30
+ stop_area = Chouette::StopArea.new
31
+ expect(stop_area.area_type).to eq(stop_area.area_type)
32
+ end
33
+
34
+ end
35
+
36
+
37
+ describe "respond_to?" do
38
+
39
+ it "should respond to method with additionnal underscores" do
40
+ stop_area = Chouette::StopArea.new
41
+ expect(stop_area.respond_to?(:area_type)).to be_truthy
42
+ end
43
+
44
+ end
45
+
46
+ # describe "create_reflection" do
47
+
48
+ # let(:macro) { :has_many }
49
+ # let(:name) { :lines }
50
+ # let(:options) { {} }
51
+ # let(:active_record) { Chouette::Network }
52
+
53
+ # let(:modified_options) { {:modified => true} }
54
+
55
+ # it "should invoke create_reflection_without_chouette_naming with modified options" do
56
+ # allow(Chouette::ActiveRecord::Reflection).to receive_messages :new => double(:options_with_default => modified_options)
57
+ # expect(Chouette::ActiveRecord).to receive(:create_reflection_without_chouette_naming).with macro, name, modified_options, active_record
58
+
59
+ # Chouette::ActiveRecord.create_reflection macro, name, options, active_record
60
+ # end
61
+
62
+ # end
63
+
64
+ end
65
+
66
+ # describe Chouette::ActiveRecord::Reflection, :type => :model do
67
+
68
+ # let(:macro) { :has_many }
69
+ # let(:name) { :lines }
70
+ # let(:options) { {} }
71
+ # let(:active_record) { Chouette::Network }
72
+
73
+ # subject { Chouette::ActiveRecord::Reflection.new macro, name, options, active_record }
74
+
75
+ # describe "collection?" do
76
+
77
+ # it "should be true when macro is has_many" do
78
+ # allow(subject).to receive_messages :macro => :has_many
79
+ # expect(subject).to be_collection
80
+ # end
81
+
82
+ # it "should be false when macro is belongs_to" do
83
+ # allow(subject).to receive_messages :macro => :belong_to
84
+ # expect(subject).not_to be_collection
85
+ # end
86
+
87
+ # end
88
+
89
+ # describe "class_name" do
90
+
91
+ # it "should be Chouette::Line when name is line" do
92
+ # allow(subject).to receive_messages :name => "line"
93
+ # expect(subject.class_name).to eq("Chouette::Line")
94
+ # end
95
+
96
+ # it "should be Chouette::Routes when name is routes and reflection is a collection" do
97
+ # allow(subject).to receive_messages :name => "routes", :collection? => true
98
+ # expect(subject.class_name).to eq("Chouette::Route")
99
+ # end
100
+
101
+ # end
102
+
103
+
104
+ # describe "options" do
105
+
106
+ # it "should define class_name if not" do
107
+ # allow(subject).to receive_messages :options => {}, :class_name => "class_name"
108
+ # expect(subject.options_with_default[:class_name]).to eq("class_name")
109
+ # end
110
+
111
+ # it "should not define class_name if presents" do
112
+ # allow(subject).to receive_messages :options => {:class_name => "dummy"}
113
+ # expect(subject.options_with_default[:class_name]).to eq("dummy")
114
+ # end
115
+
116
+ # end
117
+
118
+
119
+ # end
120
+
121
+