ninoxe 1.1.5 → 1.2.0

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