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,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::TimeTable do
3
+ describe Chouette::TimeTable, :type => :model do
4
4
 
5
- subject { Factory(:time_table) }
5
+ subject { create(:time_table) }
6
6
 
7
- it { should validate_presence_of :comment }
8
- it { should validate_uniqueness_of :objectid }
7
+ it { is_expected.to validate_presence_of :comment }
8
+ it { is_expected.to validate_uniqueness_of :objectid }
9
9
 
10
10
  describe "#periods_max_date" do
11
11
  context "when all period extends from 04/10/2013 to 04/15/2013," do
@@ -17,7 +17,7 @@ describe Chouette::TimeTable do
17
17
  end
18
18
 
19
19
  it "should retreive 04/15/2013" do
20
- subject.periods_max_date.should == Date.strptime("04/15/2013", '%m/%d/%Y')
20
+ expect(subject.periods_max_date).to eq(Date.strptime("04/15/2013", '%m/%d/%Y'))
21
21
  end
22
22
  context "when 04/15/2013 is excluded, periods_max_dates selects the day before" do
23
23
  before(:each) do
@@ -26,7 +26,7 @@ describe Chouette::TimeTable do
26
26
  subject.save
27
27
  end
28
28
  it "should retreive 04/14/2013" do
29
- subject.periods_max_date.should == Date.strptime("04/14/2013", '%m/%d/%Y')
29
+ expect(subject.periods_max_date).to eq(Date.strptime("04/14/2013", '%m/%d/%Y'))
30
30
  end
31
31
  end
32
32
  context "when day_types select only sunday and saturday," do
@@ -35,7 +35,7 @@ describe Chouette::TimeTable do
35
35
  subject.update_attributes( :int_day_types => (2**(1+6) + 2**(1+7)))
36
36
  end
37
37
  it "should retreive 04/14/2013" do
38
- subject.periods_max_date.should == Date.strptime("04/14/2013", '%m/%d/%Y')
38
+ expect(subject.periods_max_date).to eq(Date.strptime("04/14/2013", '%m/%d/%Y'))
39
39
  end
40
40
  end
41
41
  context "when day_types select only friday," do
@@ -44,7 +44,7 @@ describe Chouette::TimeTable do
44
44
  subject.update_attributes( :int_day_types => (2**(1+6)))
45
45
  end
46
46
  it "should retreive 04/12/2013" do
47
- subject.periods_max_date.should == Date.strptime("04/13/2013", '%m/%d/%Y')
47
+ expect(subject.periods_max_date).to eq(Date.strptime("04/13/2013", '%m/%d/%Y'))
48
48
  end
49
49
  end
50
50
  context "when day_types select only thursday," do
@@ -54,7 +54,7 @@ describe Chouette::TimeTable do
54
54
  end
55
55
  it "should retreive 04/12/2013" do
56
56
  # 04/15/2013 is monday !
57
- subject.periods_max_date.should be_nil
57
+ expect(subject.periods_max_date).to be_nil
58
58
  end
59
59
  end
60
60
  end
@@ -70,8 +70,8 @@ describe "update_attributes on periods and dates" do
70
70
  subject.update_attributes( days_hash)
71
71
 
72
72
  read = Chouette::TimeTable.find( subject.id )
73
- read.start_date.should == read.dates.select{|d| d.in_out}.map(&:date).compact.min
74
- read.end_date.should == read.dates.select{|d| d.in_out}.map(&:date).compact.max
73
+ expect(read.start_date).to eq(read.dates.select{|d| d.in_out}.map(&:date).compact.min)
74
+ expect(read.end_date).to eq(read.dates.select{|d| d.in_out}.map(&:date).compact.max)
75
75
 
76
76
  end
77
77
  end
@@ -87,8 +87,8 @@ describe "update_attributes on periods and dates" do
87
87
  subject.update_attributes( :periods_attributes => new_period_attributes)
88
88
 
89
89
  read = Chouette::TimeTable.find( subject.id )
90
- read.start_date.should == new_start_date
91
- read.end_date.should == new_end_date
90
+ expect(read.start_date).to eq(new_start_date)
91
+ expect(read.end_date).to eq(new_end_date)
92
92
  end
93
93
  end
94
94
  context "update period end" do
@@ -102,7 +102,7 @@ describe "update_attributes on periods and dates" do
102
102
  subject.update_attributes :periods_attributes => new_period_attributes
103
103
 
104
104
  read = Chouette::TimeTable.find( subject.id )
105
- read.end_date.should == new_end_date
105
+ expect(read.end_date).to eq(new_end_date)
106
106
  end
107
107
  end
108
108
  context "update period start" do
@@ -116,7 +116,7 @@ describe "update_attributes on periods and dates" do
116
116
  subject.update_attributes :periods_attributes => new_period_attributes
117
117
 
118
118
  read = Chouette::TimeTable.find( subject.id )
119
- read.start_date.should == new_start_date
119
+ expect(read.start_date).to eq(new_start_date)
120
120
  end
121
121
  end
122
122
  context "remove periods and dates and add a new period" do
@@ -137,8 +137,8 @@ describe "update_attributes on periods and dates" do
137
137
  subject.update_attributes :periods_attributes => new_period_attributes, :dates_attributes => new_dates_attributes
138
138
 
139
139
  read = Chouette::TimeTable.find( subject.id )
140
- read.start_date.should == new_start_date
141
- read.end_date.should == new_end_date
140
+ expect(read.start_date).to eq(new_start_date)
141
+ expect(read.end_date).to eq(new_end_date)
142
142
  end
143
143
  end
144
144
  def dates_attributes
@@ -167,7 +167,7 @@ end
167
167
  end
168
168
 
169
169
  it "should retreive 04/10/2013" do
170
- subject.periods_min_date.should == Date.strptime("04/10/2013", '%m/%d/%Y')
170
+ expect(subject.periods_min_date).to eq(Date.strptime("04/10/2013", '%m/%d/%Y'))
171
171
  end
172
172
  context "when 04/10/2013 is excluded, periods_min_dates select the day after" do
173
173
  before(:each) do
@@ -176,7 +176,7 @@ end
176
176
  subject.save
177
177
  end
178
178
  it "should retreive 04/11/2013" do
179
- subject.periods_min_date.should == Date.strptime("04/11/2013", '%m/%d/%Y')
179
+ expect(subject.periods_min_date).to eq(Date.strptime("04/11/2013", '%m/%d/%Y'))
180
180
  end
181
181
  end
182
182
  context "when day_types select only tuesday and friday," do
@@ -185,7 +185,7 @@ end
185
185
  subject.update_attributes( :int_day_types => (2**(1+4) + 2**(1+5)))
186
186
  end
187
187
  it "should retreive 04/11/2013" do
188
- subject.periods_min_date.should == Date.strptime("04/11/2013", '%m/%d/%Y')
188
+ expect(subject.periods_min_date).to eq(Date.strptime("04/11/2013", '%m/%d/%Y'))
189
189
  end
190
190
  end
191
191
  context "when day_types select only friday," do
@@ -194,7 +194,7 @@ end
194
194
  subject.update_attributes( :int_day_types => (2**(1+5)))
195
195
  end
196
196
  it "should retreive 04/12/2013" do
197
- subject.periods_min_date.should == Date.strptime("04/12/2013", '%m/%d/%Y')
197
+ expect(subject.periods_min_date).to eq(Date.strptime("04/12/2013", '%m/%d/%Y'))
198
198
  end
199
199
  end
200
200
  context "when day_types select only thursday," do
@@ -204,7 +204,7 @@ end
204
204
  end
205
205
  it "should retreive 04/12/2013" do
206
206
  # 04/15/2013 is monday !
207
- subject.periods_min_date.should be_nil
207
+ expect(subject.periods_min_date).to be_nil
208
208
  end
209
209
  end
210
210
  end
@@ -213,8 +213,8 @@ end
213
213
  it "should add a new instance of period, and periods_max_date should not raise error" do
214
214
  period = subject.periods.build
215
215
  subject.periods_max_date
216
- period.period_start.should be_nil
217
- period.period_end.should be_nil
216
+ expect(period.period_start).to be_nil
217
+ expect(period.period_end).to be_nil
218
218
  end
219
219
  end
220
220
  describe "#periods" do
@@ -224,8 +224,8 @@ end
224
224
  subject.save
225
225
  end
226
226
  it "should update shortcut" do
227
- subject.start_date.should == subject.bounding_dates.min
228
- subject.end_date.should == subject.bounding_dates.max
227
+ expect(subject.start_date).to eq(subject.bounding_dates.min)
228
+ expect(subject.end_date).to eq(subject.bounding_dates.max)
229
229
  end
230
230
  end
231
231
  context "when a period is removed," do
@@ -247,12 +247,12 @@ end
247
247
  end
248
248
  it "should update shortcut" do
249
249
  tm = read_tm
250
- subject.start_date.should == subject.bounding_dates.min
251
- subject.start_date.should == tm.bounding_dates.min
252
- subject.start_date.should == 4.days.since.to_date
253
- subject.end_date.should == subject.bounding_dates.max
254
- subject.end_date.should == tm.bounding_dates.max
255
- subject.end_date.should == 6.days.since.to_date
250
+ expect(subject.start_date).to eq(subject.bounding_dates.min)
251
+ expect(subject.start_date).to eq(tm.bounding_dates.min)
252
+ expect(subject.start_date).to eq(4.days.since.to_date)
253
+ expect(subject.end_date).to eq(subject.bounding_dates.max)
254
+ expect(subject.end_date).to eq(tm.bounding_dates.max)
255
+ expect(subject.end_date).to eq(6.days.since.to_date)
256
256
  end
257
257
  end
258
258
  context "when a period is updated," do
@@ -274,12 +274,12 @@ end
274
274
  end
275
275
  it "should update shortcut" do
276
276
  tm = read_tm
277
- subject.start_date.should == subject.bounding_dates.min
278
- subject.start_date.should == tm.bounding_dates.min
279
- subject.start_date.should == 1.days.since.to_date
280
- subject.end_date.should == subject.bounding_dates.max
281
- subject.end_date.should == tm.bounding_dates.max
282
- subject.end_date.should == 15.days.since.to_date
277
+ expect(subject.start_date).to eq(subject.bounding_dates.min)
278
+ expect(subject.start_date).to eq(tm.bounding_dates.min)
279
+ expect(subject.start_date).to eq(1.days.since.to_date)
280
+ expect(subject.end_date).to eq(subject.bounding_dates.max)
281
+ expect(subject.end_date).to eq(tm.bounding_dates.max)
282
+ expect(subject.end_date).to eq(15.days.since.to_date)
283
283
  end
284
284
  end
285
285
 
@@ -301,7 +301,7 @@ end
301
301
  "period_end"=>"",
302
302
  "_destroy"=>""}}})
303
303
  subject.save
304
- subject.id.should be_nil
304
+ expect(subject.id).to be_nil
305
305
  end
306
306
  end
307
307
  context "when a valid period is set," do
@@ -321,9 +321,9 @@ end
321
321
  "_destroy"=>""}}})
322
322
  subject.save
323
323
  tm = Chouette::TimeTable.find subject.id
324
- tm.periods.empty?.should be_false
325
- tm.start_date.should == Date.new(2014, 01, 01)
326
- tm.end_date.should == Date.new(2015, 01, 01)
324
+ expect(tm.periods.empty?).to be_falsey
325
+ expect(tm.start_date).to eq(Date.new(2014, 01, 01))
326
+ expect(tm.end_date).to eq(Date.new(2015, 01, 01))
327
327
 
328
328
  end
329
329
  end
@@ -336,8 +336,8 @@ end
336
336
  subject.save
337
337
  end
338
338
  it "should update shortcut" do
339
- subject.start_date.should == subject.bounding_dates.min
340
- subject.end_date.should == subject.bounding_dates.max
339
+ expect(subject.start_date).to eq(subject.bounding_dates.min)
340
+ expect(subject.end_date).to eq(subject.bounding_dates.max)
341
341
  end
342
342
  end
343
343
  context "when a date is removed," do
@@ -347,8 +347,8 @@ end
347
347
  subject.save_shortcuts
348
348
  end
349
349
  it "should update shortcut" do
350
- subject.start_date.should == subject.bounding_dates.min
351
- subject.end_date.should == subject.bounding_dates.max
350
+ expect(subject.start_date).to eq(subject.bounding_dates.min)
351
+ expect(subject.end_date).to eq(subject.bounding_dates.max)
352
352
  end
353
353
  end
354
354
  context "when all the dates and periods are removed," do
@@ -358,8 +358,8 @@ end
358
358
  subject.save_shortcuts
359
359
  end
360
360
  it "should update shortcut" do
361
- subject.start_date.should be_nil
362
- subject.end_date.should be_nil
361
+ expect(subject.start_date).to be_nil
362
+ expect(subject.end_date).to be_nil
363
363
  end
364
364
  end
365
365
  context "when a date is updated," do
@@ -383,12 +383,12 @@ end
383
383
  end
384
384
  it "should update shortcut" do
385
385
  tm = read_tm
386
- subject.start_date.should == subject.bounding_dates.min
387
- subject.start_date.should == tm.bounding_dates.min
388
- subject.start_date.should == 1.days.since.to_date
389
- subject.end_date.should == subject.bounding_dates.max
390
- subject.end_date.should == tm.bounding_dates.max
391
- subject.end_date.should == 15.days.since.to_date
386
+ expect(subject.start_date).to eq(subject.bounding_dates.min)
387
+ expect(subject.start_date).to eq(tm.bounding_dates.min)
388
+ expect(subject.start_date).to eq(1.days.since.to_date)
389
+ expect(subject.end_date).to eq(subject.bounding_dates.max)
390
+ expect(subject.end_date).to eq(tm.bounding_dates.max)
391
+ expect(subject.end_date).to eq(15.days.since.to_date)
392
392
  end
393
393
  end
394
394
  end
@@ -407,7 +407,7 @@ end
407
407
  "dates_attributes"=>{"1397136189216"=>{"date"=>"",
408
408
  "_destroy"=>"", "in_out" => true}}})
409
409
  subject.save
410
- subject.id.should be_nil
410
+ expect(subject.id).to be_nil
411
411
  end
412
412
  it "it should save tm if date valid" do
413
413
  subject = Chouette::TimeTable.new({"comment"=>"test",
@@ -424,16 +424,16 @@ end
424
424
  "_destroy"=>"", "in_out" => true}}})
425
425
  subject.save
426
426
  tm = Chouette::TimeTable.find subject.id
427
- tm.dates.empty?.should be_false
428
- tm.start_date.should == Date.new(2015, 01, 01)
429
- tm.end_date.should == Date.new(2015, 01, 01)
427
+ expect(tm.dates.empty?).to be_falsey
428
+ expect(tm.start_date).to eq(Date.new(2015, 01, 01))
429
+ expect(tm.end_date).to eq(Date.new(2015, 01, 01))
430
430
  end
431
431
  end
432
432
 
433
433
  describe "#valid_days" do
434
434
  it "should begin with position 0" do
435
435
  subject.int_day_types = 128
436
- subject.valid_days.should == [6]
436
+ expect(subject.valid_days).to eq([6])
437
437
  end
438
438
  end
439
439
 
@@ -441,7 +441,7 @@ end
441
441
  it "should return day if a date equal day" do
442
442
  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
443
443
  time_table.dates << Chouette::TimeTableDate.new( :date => Date.today, :in_out => true)
444
- time_table.intersects([Date.today]).should == [Date.today]
444
+ expect(time_table.intersects([Date.today])).to eq([Date.today])
445
445
  end
446
446
 
447
447
  it "should return [] if a period not include days" do
@@ -449,7 +449,7 @@ end
449
449
  time_table.periods << Chouette::TimeTablePeriod.new(
450
450
  :period_start => Date.new(2013, 05, 27),
451
451
  :period_end => Date.new(2013, 05, 30))
452
- time_table.intersects([ Date.new(2013, 05, 29), Date.new(2013, 05, 30)]).should == []
452
+ expect(time_table.intersects([ Date.new(2013, 05, 29), Date.new(2013, 05, 30)])).to eq([])
453
453
  end
454
454
 
455
455
  it "should return days if a period include day" do
@@ -457,7 +457,7 @@ end
457
457
  time_table.periods << Chouette::TimeTablePeriod.new(
458
458
  :period_start => Date.new(2013, 05, 27),
459
459
  :period_end => Date.new(2013, 05, 30))
460
- time_table.intersects([ Date.new(2013, 05, 27), Date.new(2013, 05, 28)]).should == [ Date.new(2013, 05, 27), Date.new(2013, 05, 28)]
460
+ expect(time_table.intersects([ Date.new(2013, 05, 27), Date.new(2013, 05, 28)])).to eq([ Date.new(2013, 05, 27), Date.new(2013, 05, 28)])
461
461
  end
462
462
 
463
463
 
@@ -467,7 +467,7 @@ end
467
467
  it "should return true if a date equal day" do
468
468
  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
469
469
  time_table.dates << Chouette::TimeTableDate.new( :date => Date.today, :in_out => true)
470
- time_table.include_day?(Date.today).should == true
470
+ expect(time_table.include_day?(Date.today)).to eq(true)
471
471
  end
472
472
 
473
473
  it "should return true if a period include day" do
@@ -475,7 +475,7 @@ end
475
475
  time_table.periods << Chouette::TimeTablePeriod.new(
476
476
  :period_start => Date.new(2013, 05, 27),
477
477
  :period_end => Date.new(2013, 05, 29))
478
- time_table.include_day?( Date.new(2013, 05, 27)).should == true
478
+ expect(time_table.include_day?( Date.new(2013, 05, 27))).to eq(true)
479
479
  end
480
480
  end
481
481
 
@@ -483,14 +483,14 @@ end
483
483
  it "should return true if a date equal day" do
484
484
  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
485
485
  time_table.dates << Chouette::TimeTableDate.new( :date => Date.today, :in_out => true)
486
- time_table.include_in_dates?(Date.today).should == true
486
+ expect(time_table.include_in_dates?(Date.today)).to eq(true)
487
487
  end
488
488
 
489
489
  it "should return false if a period include day but that is exclued" do
490
490
  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12) # Day type monday and tuesday
491
491
  excluded_date = Date.new(2013, 05, 27)
492
492
  time_table.dates << Chouette::TimeTableDate.new( :date => excluded_date, :in_out => false)
493
- time_table.include_in_dates?( excluded_date).should be_false
493
+ expect(time_table.include_in_dates?( excluded_date)).to be_falsey
494
494
  end
495
495
  end
496
496
 
@@ -500,7 +500,7 @@ end
500
500
  time_table.periods << Chouette::TimeTablePeriod.new(
501
501
  :period_start => Date.new(2012, 1, 1),
502
502
  :period_end => Date.new(2012, 01, 30))
503
- time_table.include_in_periods?(Date.new(2012, 1, 2)).should == true
503
+ expect(time_table.include_in_periods?(Date.new(2012, 1, 2))).to eq(true)
504
504
  end
505
505
 
506
506
  it "should return false if a period include day but that is exclued" do
@@ -510,7 +510,7 @@ end
510
510
  time_table.periods << Chouette::TimeTablePeriod.new(
511
511
  :period_start => Date.new(2013, 05, 27),
512
512
  :period_end => Date.new(2013, 05, 29))
513
- time_table.include_in_periods?( excluded_date).should be_false
513
+ expect(time_table.include_in_periods?( excluded_date)).to be_falsey
514
514
  end
515
515
  end
516
516
 
@@ -521,7 +521,7 @@ end
521
521
  :period_start => Date.new(2012, 1, 1),
522
522
  :period_end => Date.new(2012, 01, 30))
523
523
  time_table.dates << Chouette::TimeTableDate.new( :date => Date.new(2012, 1, 2), :in_out => true)
524
- time_table.include_in_overlap_dates?(Date.new(2012, 1, 2)).should == true
524
+ expect(time_table.include_in_overlap_dates?(Date.new(2012, 1, 2))).to eq(true)
525
525
  end
526
526
  it "should return false if the day is excluded" do
527
527
  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 4)
@@ -529,65 +529,65 @@ end
529
529
  :period_start => Date.new(2012, 1, 1),
530
530
  :period_end => Date.new(2012, 01, 30))
531
531
  time_table.dates << Chouette::TimeTableDate.new( :date => Date.new(2012, 1, 2), :in_out => false)
532
- time_table.include_in_overlap_dates?(Date.new(2012, 1, 2)).should be_false
532
+ expect(time_table.include_in_overlap_dates?(Date.new(2012, 1, 2))).to be_falsey
533
533
  end
534
534
  end
535
535
 
536
536
  describe "#dates" do
537
537
  it "should have with position 0" do
538
- subject.dates.first.position.should == 0
538
+ expect(subject.dates.first.position).to eq(0)
539
539
  end
540
540
  context "when first date has been removed" do
541
541
  before do
542
542
  subject.dates.first.destroy
543
543
  end
544
544
  it "should begin with position 0" do
545
- subject.dates.first.position.should == 0
545
+ expect(subject.dates.first.position).to eq(0)
546
546
  end
547
547
  end
548
548
  end
549
549
  describe "#validity_out_between?" do
550
- let(:empty_tm) {Factory.build(:time_table)}
550
+ let(:empty_tm) {build(:time_table)}
551
551
  it "should be false if empty calendar" do
552
- empty_tm.validity_out_between?( Date.today, Date.today + 7.day).should be_false
552
+ expect(empty_tm.validity_out_between?( Date.today, Date.today + 7.day)).to be_falsey
553
553
  end
554
554
  it "should be true if caldendar is out during start_date and end_date period" do
555
555
  start_date = subject.bounding_dates.max - 2.day
556
556
  end_date = subject.bounding_dates.max + 2.day
557
- subject.validity_out_between?( start_date, end_date).should be_true
557
+ expect(subject.validity_out_between?( start_date, end_date)).to be_truthy
558
558
  end
559
559
  it "should be false if calendar is out on start date" do
560
560
  start_date = subject.bounding_dates.max
561
561
  end_date = subject.bounding_dates.max + 2.day
562
- subject.validity_out_between?( start_date, end_date).should be_false
562
+ expect(subject.validity_out_between?( start_date, end_date)).to be_falsey
563
563
  end
564
564
  it "should be false if calendar is out on end date" do
565
565
  start_date = subject.bounding_dates.max - 2.day
566
566
  end_date = subject.bounding_dates.max
567
- subject.validity_out_between?( start_date, end_date).should be_true
567
+ expect(subject.validity_out_between?( start_date, end_date)).to be_truthy
568
568
  end
569
569
  it "should be false if calendar is out after start_date" do
570
570
  start_date = subject.bounding_dates.max + 2.day
571
571
  end_date = subject.bounding_dates.max + 4.day
572
- subject.validity_out_between?( start_date, end_date).should be_false
572
+ expect(subject.validity_out_between?( start_date, end_date)).to be_falsey
573
573
  end
574
574
  end
575
575
  describe "#validity_out_from_on?" do
576
- let(:empty_tm) {Factory.build(:time_table)}
576
+ let(:empty_tm) {build(:time_table)}
577
577
  it "should be false if empty calendar" do
578
- empty_tm.validity_out_from_on?( Date.today).should be_false
578
+ expect(empty_tm.validity_out_from_on?( Date.today)).to be_falsey
579
579
  end
580
580
  it "should be true if caldendar ends on expected date" do
581
581
  expected_date = subject.bounding_dates.max
582
- subject.validity_out_from_on?( expected_date).should be_true
582
+ expect(subject.validity_out_from_on?( expected_date)).to be_truthy
583
583
  end
584
584
  it "should be true if calendar ends before expected date" do
585
585
  expected_date = subject.bounding_dates.max + 30.day
586
- subject.validity_out_from_on?( expected_date).should be_true
586
+ expect(subject.validity_out_from_on?( expected_date)).to be_truthy
587
587
  end
588
588
  it "should be false if calendars ends after expected date" do
589
589
  expected_date = subject.bounding_dates.max - 30.day
590
- subject.validity_out_from_on?( expected_date).should be_false
590
+ expect(subject.validity_out_from_on?( expected_date)).to be_falsey
591
591
  end
592
592
  end
593
593
  describe "#bounding_dates" do
@@ -597,8 +597,8 @@ end
597
597
  subject.save
598
598
  end
599
599
  it "should retreive periods.period_start.min and periods.period_end.max" do
600
- subject.bounding_dates.min.should == subject.periods.map(&:period_start).min
601
- subject.bounding_dates.max.should == subject.periods.map(&:period_end).max
600
+ expect(subject.bounding_dates.min).to eq(subject.periods.map(&:period_start).min)
601
+ expect(subject.bounding_dates.max).to eq(subject.periods.map(&:period_end).max)
602
602
  end
603
603
  end
604
604
  context "when timetable contains only dates" do
@@ -607,60 +607,60 @@ end
607
607
  subject.save
608
608
  end
609
609
  it "should retreive dates.min and dates.max" do
610
- subject.bounding_dates.min.should == subject.dates.map(&:date).min
611
- subject.bounding_dates.max.should == subject.dates.map(&:date).max
610
+ expect(subject.bounding_dates.min).to eq(subject.dates.map(&:date).min)
611
+ expect(subject.bounding_dates.max).to eq(subject.dates.map(&:date).max)
612
612
  end
613
613
  end
614
614
  it "should contains min date" do
615
615
  min_date = subject.bounding_dates.min
616
616
  subject.dates.each do |tm_date|
617
- (min_date <= tm_date.date).should be_true
617
+ expect(min_date <= tm_date.date).to be_truthy
618
618
  end
619
619
  subject.periods.each do |tm_period|
620
- (min_date <= tm_period.period_start).should be_true
620
+ expect(min_date <= tm_period.period_start).to be_truthy
621
621
  end
622
622
 
623
623
  end
624
624
  it "should contains max date" do
625
625
  max_date = subject.bounding_dates.max
626
626
  subject.dates.each do |tm_date|
627
- (tm_date.date <= max_date).should be_true
627
+ expect(tm_date.date <= max_date).to be_truthy
628
628
  end
629
629
  subject.periods.each do |tm_period|
630
- (tm_period.period_end <= max_date).should be_true
630
+ expect(tm_period.period_end <= max_date).to be_truthy
631
631
  end
632
632
 
633
633
  end
634
634
  end
635
635
  describe "#periods" do
636
636
  it "should begin with position 0" do
637
- subject.periods.first.position.should == 0
637
+ expect(subject.periods.first.position).to eq(0)
638
638
  end
639
639
  context "when first period has been removed" do
640
640
  before do
641
641
  subject.periods.first.destroy
642
642
  end
643
643
  it "should begin with position 0" do
644
- subject.periods.first.position.should == 0
644
+ expect(subject.periods.first.position).to eq(0)
645
645
  end
646
646
  end
647
647
  it "should have period_start before period_end" do
648
648
  period = Chouette::TimeTablePeriod.new
649
649
  period.period_start = Date.today
650
650
  period.period_end = Date.today + 10
651
- period.valid?.should be_true
651
+ expect(period.valid?).to be_truthy
652
652
  end
653
653
  it "should not have period_start after period_end" do
654
654
  period = Chouette::TimeTablePeriod.new
655
655
  period.period_start = Date.today
656
656
  period.period_end = Date.today - 10
657
- period.valid?.should be_false
657
+ expect(period.valid?).to be_falsey
658
658
  end
659
659
  it "should not have period_start equal to period_end" do
660
660
  period = Chouette::TimeTablePeriod.new
661
661
  period.period_start = Date.today
662
662
  period.period_end = Date.today
663
- period.valid?.should be_false
663
+ expect(period.valid?).to be_falsey
664
664
  end
665
665
  end
666
666
 
@@ -673,14 +673,14 @@ end
673
673
  subject.int_day_types = 4|8|16
674
674
  end
675
675
  it "should return monday to wednesday" do
676
- subject.effective_days_of_periods.size.should == 3
677
- subject.effective_days_of_periods[0].should == Date.new(2014, 6, 30)
678
- subject.effective_days_of_periods[1].should == Date.new(2014, 7, 1)
679
- subject.effective_days_of_periods[2].should == Date.new(2014, 7, 2)
676
+ expect(subject.effective_days_of_periods.size).to eq(3)
677
+ expect(subject.effective_days_of_periods[0]).to eq(Date.new(2014, 6, 30))
678
+ expect(subject.effective_days_of_periods[1]).to eq(Date.new(2014, 7, 1))
679
+ expect(subject.effective_days_of_periods[2]).to eq(Date.new(2014, 7, 2))
680
680
  end
681
681
  it "should return thursday" do
682
- subject.effective_days_of_periods(Chouette::TimeTable.valid_days(32)).size.should == 1
683
- subject.effective_days_of_periods(Chouette::TimeTable.valid_days(32))[0].should == Date.new(2014, 7, 3)
682
+ expect(subject.effective_days_of_periods(Chouette::TimeTable.valid_days(32)).size).to eq(1)
683
+ expect(subject.effective_days_of_periods(Chouette::TimeTable.valid_days(32))[0]).to eq(Date.new(2014, 7, 3))
684
684
  end
685
685
 
686
686
  end
@@ -696,10 +696,10 @@ end
696
696
  end
697
697
  it "should return 3 dates" do
698
698
  days = subject.included_days
699
- days.size.should == 3
700
- days[0].should == Date.new(2014, 7, 16)
701
- days[1].should == Date.new(2014,7, 18)
702
- days[2].should == Date.new(2014, 7,20)
699
+ expect(days.size).to eq(3)
700
+ expect(days[0]).to eq(Date.new(2014, 7, 16))
701
+ expect(days[1]).to eq(Date.new(2014,7, 18))
702
+ expect(days[2]).to eq(Date.new(2014, 7,20))
703
703
  end
704
704
  end
705
705
 
@@ -716,9 +716,9 @@ end
716
716
  end
717
717
  it "should return 3 dates" do
718
718
  days = subject.excluded_days
719
- days.size.should == 2
720
- days[0].should == Date.new(2014, 7, 17)
721
- days[1].should == Date.new(2014,7, 19)
719
+ expect(days.size).to eq(2)
720
+ expect(days[0]).to eq(Date.new(2014, 7, 17))
721
+ expect(days[1]).to eq(Date.new(2014,7, 19))
722
722
  end
723
723
  end
724
724
 
@@ -739,12 +739,12 @@ end
739
739
  end
740
740
  it "should return 5 dates" do
741
741
  days = subject.effective_days
742
- days.size.should == 5
743
- days[0].should == Date.new(2014, 6, 30)
744
- days[1].should == Date.new(2014, 7, 2)
745
- days[2].should == Date.new(2014, 7, 16)
746
- days[3].should == Date.new(2014, 7, 18)
747
- days[4].should == Date.new(2014, 7, 20)
742
+ expect(days.size).to eq(5)
743
+ expect(days[0]).to eq(Date.new(2014, 6, 30))
744
+ expect(days[1]).to eq(Date.new(2014, 7, 2))
745
+ expect(days[2]).to eq(Date.new(2014, 7, 16))
746
+ expect(days[3]).to eq(Date.new(2014, 7, 18))
747
+ expect(days[4]).to eq(Date.new(2014, 7, 20))
748
748
  end
749
749
  end
750
750
 
@@ -769,11 +769,11 @@ end
769
769
  end
770
770
  it "should return 2 ordered periods" do
771
771
  periods = subject.optimize_periods
772
- periods.size.should == 2
773
- periods[0].period_start.should == Date.new(2014, 6, 1)
774
- periods[0].period_end.should == Date.new(2014, 6, 14)
775
- periods[1].period_start.should == Date.new(2014, 6, 30)
776
- periods[1].period_end.should == Date.new(2014, 7, 14)
772
+ expect(periods.size).to eq(2)
773
+ expect(periods[0].period_start).to eq(Date.new(2014, 6, 1))
774
+ expect(periods[0].period_end).to eq(Date.new(2014, 6, 14))
775
+ expect(periods[1].period_start).to eq(Date.new(2014, 6, 30))
776
+ expect(periods[1].period_end).to eq(Date.new(2014, 7, 14))
777
777
  end
778
778
  end
779
779
 
@@ -787,26 +787,26 @@ end
787
787
  it "should do nothing" do
788
788
  subject.add_included_day(Date.new(2014,7,16))
789
789
  days = subject.included_days
790
- days.size.should == 2
791
- days.include?(Date.new(2014,7,16)).should be_true
792
- days.include?(Date.new(2014,7,18)).should be_false
793
- days.include?(Date.new(2014,7,20)).should be_true
790
+ expect(days.size).to eq(2)
791
+ expect(days.include?(Date.new(2014,7,16))).to be_truthy
792
+ expect(days.include?(Date.new(2014,7,18))).to be_falsey
793
+ expect(days.include?(Date.new(2014,7,20))).to be_truthy
794
794
  end
795
795
  it "should switch in_out flag" do
796
796
  subject.add_included_day(Date.new(2014,7,18))
797
797
  days = subject.included_days
798
- days.size.should == 3
799
- days.include?(Date.new(2014,7,16)).should be_true
800
- days.include?(Date.new(2014,7,18)).should be_true
801
- days.include?(Date.new(2014,7,20)).should be_true
798
+ expect(days.size).to eq(3)
799
+ expect(days.include?(Date.new(2014,7,16))).to be_truthy
800
+ expect(days.include?(Date.new(2014,7,18))).to be_truthy
801
+ expect(days.include?(Date.new(2014,7,20))).to be_truthy
802
802
  end
803
803
  it "should add date" do
804
804
  subject.add_included_day(Date.new(2014,7,21))
805
805
  days = subject.included_days
806
- days.size.should == 3
807
- days.include?(Date.new(2014,7,16)).should be_true
808
- days.include?(Date.new(2014,7,20)).should be_true
809
- days.include?(Date.new(2014,7,21)).should be_true
806
+ expect(days.size).to eq(3)
807
+ expect(days.include?(Date.new(2014,7,16))).to be_truthy
808
+ expect(days.include?(Date.new(2014,7,20))).to be_truthy
809
+ expect(days.include?(Date.new(2014,7,21))).to be_truthy
810
810
  end
811
811
  end
812
812
 
@@ -820,7 +820,7 @@ end
820
820
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,6,30), :period_end => Date.new(2014,7,6))
821
821
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,16), :in_out => true)
822
822
  subject.int_day_types = 4|16|32|128
823
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
823
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
824
824
  another_tt.periods.clear
825
825
  another_tt.dates.clear
826
826
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,5), :period_end => Date.new(2014,8,12))
@@ -829,23 +829,23 @@ end
829
829
  subject.reload
830
830
  end
831
831
  it "should have merged periods" do
832
- subject.periods.size.should == 3
833
- subject.periods[0].period_start.should == Date.new(2014, 6, 30)
834
- subject.periods[0].period_end.should == Date.new(2014, 7, 6)
835
- subject.periods[1].period_start.should == Date.new(2014, 7, 15)
836
- subject.periods[1].period_end.should == Date.new(2014, 7, 25)
837
- subject.periods[2].period_start.should == Date.new(2014, 8, 1)
838
- subject.periods[2].period_end.should == Date.new(2014, 8, 12)
832
+ expect(subject.periods.size).to eq(3)
833
+ expect(subject.periods[0].period_start).to eq(Date.new(2014, 6, 30))
834
+ expect(subject.periods[0].period_end).to eq(Date.new(2014, 7, 6))
835
+ expect(subject.periods[1].period_start).to eq(Date.new(2014, 7, 15))
836
+ expect(subject.periods[1].period_end).to eq(Date.new(2014, 7, 25))
837
+ expect(subject.periods[2].period_start).to eq(Date.new(2014, 8, 1))
838
+ expect(subject.periods[2].period_end).to eq(Date.new(2014, 8, 12))
839
839
  end
840
840
  it "should have common day_types" do
841
- subject.int_day_types.should == 4|16|128
841
+ expect(subject.int_day_types).to eq(4|16|128)
842
842
  end
843
843
  it "should have dates for thursdays and fridays" do
844
- subject.dates.size.should == 4
845
- subject.dates[0].date.should == Date.new(2014,7,3)
846
- subject.dates[1].date.should == Date.new(2014,7,18)
847
- subject.dates[2].date.should == Date.new(2014,7,25)
848
- subject.dates[3].date.should == Date.new(2014,8,8)
844
+ expect(subject.dates.size).to eq(4)
845
+ expect(subject.dates[0].date).to eq(Date.new(2014,7,3))
846
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,18))
847
+ expect(subject.dates[2].date).to eq(Date.new(2014,7,25))
848
+ expect(subject.dates[3].date).to eq(Date.new(2014,8,8))
849
849
  end
850
850
  end
851
851
 
@@ -860,7 +860,7 @@ end
860
860
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,6,30), :period_end => Date.new(2014,7,20))
861
861
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,16), :in_out => true)
862
862
  subject.int_day_types = 4|16|32|128
863
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
863
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
864
864
  another_tt.periods.clear
865
865
  another_tt.dates.clear
866
866
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,6), :period_end => Date.new(2014,8,12))
@@ -868,17 +868,17 @@ end
868
868
  subject.intersect! another_tt
869
869
  subject.reload
870
870
  end
871
- it "should have 1 common period" do
872
- subject.periods.size.should == 1
873
- subject.periods[0].period_start.should == Date.new(2014, 7, 15)
874
- subject.periods[0].period_end.should == Date.new(2014, 7, 20)
875
- end
876
- it "should have common day_types" do
877
- subject.int_day_types.should == 4|16|128
871
+ it "should have no period" do
872
+ expect(subject.periods.size).to eq(0)
873
+ end
874
+ it "should have no day_types" do
875
+ expect(subject.int_day_types).to eq(0)
878
876
  end
879
- it "should have date for period reduced to one day" do
880
- subject.dates.size.should == 1
881
- subject.dates[0].date.should == Date.new(2014,8,6)
877
+ it "should have date all common days" do
878
+ expect(subject.dates.size).to eq(3)
879
+ expect(subject.dates[0].date).to eq(Date.new(2014,7,16))
880
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,19))
881
+ expect(subject.dates[2].date).to eq(Date.new(2014,8,6))
882
882
  end
883
883
  end
884
884
  context "timetables have periods or dates " do
@@ -891,7 +891,7 @@ end
891
891
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,19), :in_out => true)
892
892
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,20), :in_out => true)
893
893
  subject.int_day_types = 0
894
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
894
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
895
895
  another_tt.periods.clear
896
896
  another_tt.dates.clear
897
897
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,6), :period_end => Date.new(2014,8,12))
@@ -900,15 +900,15 @@ end
900
900
  subject.reload
901
901
  end
902
902
  it "should have 0 period" do
903
- subject.periods.size.should == 0
903
+ expect(subject.periods.size).to eq(0)
904
904
  end
905
- it "should have merges special flags" do
906
- subject.int_day_types.should == 0
905
+ it "should have no day_types" do
906
+ expect(subject.int_day_types).to eq(0)
907
907
  end
908
908
  it "should have date reduced for period" do
909
- subject.dates.size.should == 2
910
- subject.dates[0].date.should == Date.new(2014,7,18)
911
- subject.dates[1].date.should == Date.new(2014,7,19)
909
+ expect(subject.dates.size).to eq(2)
910
+ expect(subject.dates[0].date).to eq(Date.new(2014,7,18))
911
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,19))
912
912
  end
913
913
  end
914
914
  context "with only periods : intersect timetable have no one day period" do
@@ -917,7 +917,7 @@ end
917
917
  subject.dates.clear
918
918
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,1), :period_end => Date.new(2014,8,6))
919
919
  subject.int_day_types = 4|8|16
920
- another_tt = Factory(:time_table , :int_day_types => (4|8|16) )
920
+ another_tt = create(:time_table , :int_day_types => (4|8|16) )
921
921
  another_tt.periods.clear
922
922
  another_tt.dates.clear
923
923
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,6), :period_end => Date.new(2014,8,12))
@@ -925,14 +925,14 @@ end
925
925
  subject.reload
926
926
  end
927
927
  it "should have 0 result periods" do
928
- subject.periods.size.should == 0
928
+ expect(subject.periods.size).to eq(0)
929
929
  end
930
930
  it "should have no day_types" do
931
- subject.int_day_types.should == 0
931
+ expect(subject.int_day_types).to eq(0)
932
932
  end
933
933
  it "should have 1 date " do
934
- subject.dates.size.should == 1
935
- subject.dates[0].date.should == Date.new(2014,8,6)
934
+ expect(subject.dates.size).to eq(1)
935
+ expect(subject.dates[0].date).to eq(Date.new(2014,8,6))
936
936
  end
937
937
  end
938
938
 
@@ -946,7 +946,7 @@ end
946
946
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,1), :period_end => Date.new(2014,8,6))
947
947
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,6,30), :period_end => Date.new(2014,7,20))
948
948
  subject.int_day_types = 4|16|32|128
949
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
949
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
950
950
  another_tt.periods.clear
951
951
  another_tt.dates.clear
952
952
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,6), :period_end => Date.new(2014,8,12))
@@ -954,19 +954,25 @@ end
954
954
  subject.disjoin! another_tt
955
955
  subject.reload
956
956
  end
957
- it "should have 2 result periods" do
958
- subject.periods.size.should == 2
959
- subject.periods[0].period_start.should == Date.new(2014, 6, 30)
960
- subject.periods[0].period_end.should == Date.new(2014, 7, 14)
961
- subject.periods[1].period_start.should == Date.new(2014, 8, 3)
962
- subject.periods[1].period_end.should == Date.new(2014, 8, 5)
963
- end
964
- it "should have remained day_types" do
965
- subject.int_day_types.should == 4|16|32|128
966
- end
967
- it "should have dates for period reduced" do
968
- subject.dates.size.should == 1
969
- subject.dates[0].date.should == Date.new(2014,7,17)
957
+ it "should have 0 periods" do
958
+ expect(subject.periods.size).to eq(0)
959
+ end
960
+ it "should have 0 day_types" do
961
+ expect(subject.int_day_types).to eq(0)
962
+ end
963
+ it "should have only dates " do
964
+ expect(subject.dates.size).to eq(11)
965
+ expect(subject.dates[0].date).to eq(Date.new(2014,6,30))
966
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,2))
967
+ expect(subject.dates[2].date).to eq(Date.new(2014,7,3))
968
+ expect(subject.dates[3].date).to eq(Date.new(2014,7,5))
969
+ expect(subject.dates[4].date).to eq(Date.new(2014,7,7))
970
+ expect(subject.dates[5].date).to eq(Date.new(2014,7,9))
971
+ expect(subject.dates[6].date).to eq(Date.new(2014,7,10))
972
+ expect(subject.dates[7].date).to eq(Date.new(2014,7,12))
973
+ expect(subject.dates[8].date).to eq(Date.new(2014,7,14))
974
+ expect(subject.dates[9].date).to eq(Date.new(2014,7,17))
975
+ expect(subject.dates[10].date).to eq(Date.new(2014,8,4))
970
976
  end
971
977
  end
972
978
  context "timetables have periods or dates " do
@@ -981,7 +987,7 @@ end
981
987
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,8,6), :in_out => true)
982
988
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,8,7), :in_out => true)
983
989
  subject.int_day_types = 0
984
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
990
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
985
991
  another_tt.periods.clear
986
992
  another_tt.dates.clear
987
993
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,6), :period_end => Date.new(2014,8,12))
@@ -990,17 +996,17 @@ end
990
996
  subject.reload
991
997
  end
992
998
  it "should have 0 period" do
993
- subject.periods.size.should == 0
999
+ expect(subject.periods.size).to eq(0)
994
1000
  end
995
1001
  it "should have no remained day_types" do
996
- subject.int_day_types.should == 0
1002
+ expect(subject.int_day_types).to eq(0)
997
1003
  end
998
1004
  it "should have date reduced for period" do
999
- subject.dates.size.should == 4
1000
- subject.dates[0].date.should == Date.new(2014,7,16)
1001
- subject.dates[1].date.should == Date.new(2014,7,17)
1002
- subject.dates[2].date.should == Date.new(2014,7,20)
1003
- subject.dates[3].date.should == Date.new(2014,8,7)
1005
+ expect(subject.dates.size).to eq(4)
1006
+ expect(subject.dates[0].date).to eq(Date.new(2014,7,16))
1007
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,17))
1008
+ expect(subject.dates[2].date).to eq(Date.new(2014,7,20))
1009
+ expect(subject.dates[3].date).to eq(Date.new(2014,8,7))
1004
1010
  end
1005
1011
  end
1006
1012
  context "disjoined timetable have all periods in removed ones " do
@@ -1010,7 +1016,7 @@ end
1010
1016
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,1), :period_end => Date.new(2014,8,8))
1011
1017
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,6,30), :period_end => Date.new(2014,7,20))
1012
1018
  subject.int_day_types = 4|16|32|128
1013
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
1019
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
1014
1020
  another_tt.periods.clear
1015
1021
  another_tt.dates.clear
1016
1022
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,7,31), :period_end => Date.new(2014,8,12))
@@ -1019,17 +1025,17 @@ end
1019
1025
  subject.reload
1020
1026
  end
1021
1027
  it "should have 0 result periods" do
1022
- subject.periods.size.should == 0
1028
+ expect(subject.periods.size).to eq(0)
1023
1029
  end
1024
1030
  it "should have no remained day_types" do
1025
- subject.int_day_types.should == 0
1031
+ expect(subject.int_day_types).to eq(0)
1026
1032
  end
1027
1033
  it "should have dates for period reduced" do
1028
- subject.dates.size.should == 4
1029
- subject.dates[0].date.should == Date.new(2014,7,3)
1030
- subject.dates[1].date.should == Date.new(2014,7,10)
1031
- subject.dates[2].date.should == Date.new(2014,7,17)
1032
- subject.dates[3].date.should == Date.new(2014,8,7)
1034
+ expect(subject.dates.size).to eq(4)
1035
+ expect(subject.dates[0].date).to eq(Date.new(2014,7,3))
1036
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,10))
1037
+ expect(subject.dates[2].date).to eq(Date.new(2014,7,17))
1038
+ expect(subject.dates[3].date).to eq(Date.new(2014,8,7))
1033
1039
  end
1034
1040
  end
1035
1041
 
@@ -1043,7 +1049,7 @@ end
1043
1049
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,19), :in_out => true)
1044
1050
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,20), :in_out => true)
1045
1051
  subject.int_day_types = 0
1046
- another_tt = Factory(:time_table , :int_day_types => (4|16|64|128) )
1052
+ another_tt = create(:time_table , :int_day_types => (4|16|64|128) )
1047
1053
  another_tt.periods.clear
1048
1054
  another_tt.dates.clear
1049
1055
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,7,31), :period_end => Date.new(2014,8,12))
@@ -1053,16 +1059,16 @@ end
1053
1059
  subject.reload
1054
1060
  end
1055
1061
  it "should have 0 result periods" do
1056
- subject.periods.size.should == 0
1062
+ expect(subject.periods.size).to eq(0)
1057
1063
  end
1058
1064
  it "should have no remained day_types" do
1059
1065
  subject.int_day_types == 0
1060
1066
  end
1061
1067
  it "should have 3 dates left" do
1062
- subject.dates.size.should == 3
1063
- subject.dates[0].date.should == Date.new(2014,7,16)
1064
- subject.dates[1].date.should == Date.new(2014,7,19)
1065
- subject.dates[2].date.should == Date.new(2014,7,20)
1068
+ expect(subject.dates.size).to eq(3)
1069
+ expect(subject.dates[0].date).to eq(Date.new(2014,7,16))
1070
+ expect(subject.dates[1].date).to eq(Date.new(2014,7,19))
1071
+ expect(subject.dates[2].date).to eq(Date.new(2014,7,20))
1066
1072
  end
1067
1073
  end
1068
1074
  context "timetable with dates against timetable with dates and periods all covered" do
@@ -1074,7 +1080,7 @@ end
1074
1080
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,5), :in_out => true)
1075
1081
  subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,7,6), :in_out => true)
1076
1082
  subject.int_day_types = 512
1077
- another_tt = Factory(:time_table , :int_day_types => (32|64|512) )
1083
+ another_tt = create(:time_table , :int_day_types => (32|64|512) )
1078
1084
  another_tt.periods.clear
1079
1085
  another_tt.dates.clear
1080
1086
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,6,30), :period_end => Date.new(2014,7,11))
@@ -1086,13 +1092,13 @@ end
1086
1092
  subject.reload
1087
1093
  end
1088
1094
  it "should have 0 result periods" do
1089
- subject.periods.size.should == 0
1095
+ expect(subject.periods.size).to eq(0)
1090
1096
  end
1091
1097
  it "should have no remained day_types" do
1092
1098
  subject.int_day_types == 0
1093
1099
  end
1094
1100
  it "should have 0 dates left" do
1095
- subject.dates.size.should == 0
1101
+ expect(subject.dates.size).to eq(0)
1096
1102
  end
1097
1103
  end
1098
1104
 
@@ -1103,23 +1109,27 @@ end
1103
1109
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,1), :period_end => Date.new(2014,8,8))
1104
1110
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,10), :period_end => Date.new(2014,8,31))
1105
1111
  subject.int_day_types = 4|8
1106
- another_tt = Factory(:time_table , :int_day_types => (4|8) )
1112
+ another_tt = create(:time_table , :int_day_types => (4|8) )
1107
1113
  another_tt.periods.clear
1108
1114
  another_tt.dates.clear
1109
1115
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,4), :period_end => Date.new(2014,8,7))
1110
1116
  subject.disjoin! another_tt
1111
1117
  subject.reload
1112
1118
  end
1113
- it "should have 1 result periods" do
1114
- subject.periods.size.should == 1
1115
- subject.periods[0].period_start.should == Date.new(2014,8,10)
1116
- subject.periods[0].period_end.should == Date.new(2014,8,31)
1119
+ it "should have 0 result periods" do
1120
+ expect(subject.periods.size).to eq(0)
1117
1121
  end
1118
- it "should have same day_types" do
1119
- subject.int_day_types.should == 4|8
1122
+ it "should have 0 day_types" do
1123
+ expect(subject.int_day_types).to eq(0)
1120
1124
  end
1121
- it "should have no dates " do
1122
- subject.dates.size.should == 0
1125
+ it "should have 6 dates " do
1126
+ expect(subject.dates.size).to eq(6)
1127
+ expect(subject.dates[0].date).to eq(Date.new(2014,8,11))
1128
+ expect(subject.dates[1].date).to eq(Date.new(2014,8,12))
1129
+ expect(subject.dates[2].date).to eq(Date.new(2014,8,18))
1130
+ expect(subject.dates[3].date).to eq(Date.new(2014,8,19))
1131
+ expect(subject.dates[4].date).to eq(Date.new(2014,8,25))
1132
+ expect(subject.dates[5].date).to eq(Date.new(2014,8,26))
1123
1133
  end
1124
1134
  end
1125
1135
 
@@ -1130,24 +1140,31 @@ end
1130
1140
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,1), :period_end => Date.new(2014,8,6))
1131
1141
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,10), :period_end => Date.new(2014,8,31))
1132
1142
  subject.int_day_types = 4|8|16
1133
- another_tt = Factory(:time_table , :int_day_types => (4|8) )
1143
+ another_tt = create(:time_table , :int_day_types => (4|8) )
1134
1144
  another_tt.periods.clear
1135
1145
  another_tt.dates.clear
1136
1146
  another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,4), :period_end => Date.new(2014,8,5))
1137
1147
  subject.disjoin! another_tt
1138
1148
  subject.reload
1139
1149
  end
1140
- it "should have 1 result periods" do
1141
- subject.periods.size.should == 1
1142
- subject.periods[0].period_start.should == Date.new(2014,8,10)
1143
- subject.periods[0].period_end.should == Date.new(2014,8,31)
1144
- end
1145
- it "should have same day_types" do
1146
- subject.int_day_types.should == 4|8|16
1147
- end
1148
- it "should have 1 date " do
1149
- subject.dates.size.should == 1
1150
- subject.dates[0].date.should == Date.new(2014,8,6)
1150
+ it "should have 0 result periods" do
1151
+ expect(subject.periods.size).to eq(0)
1152
+ end
1153
+ it "should have 0 day_types" do
1154
+ expect(subject.int_day_types).to eq(0)
1155
+ end
1156
+ it "should have 10 dates " do
1157
+ expect(subject.dates.size).to eq(10)
1158
+ expect(subject.dates[0].date).to eq(Date.new(2014,8,6))
1159
+ expect(subject.dates[1].date).to eq(Date.new(2014,8,11))
1160
+ expect(subject.dates[2].date).to eq(Date.new(2014,8,12))
1161
+ expect(subject.dates[3].date).to eq(Date.new(2014,8,13))
1162
+ expect(subject.dates[4].date).to eq(Date.new(2014,8,18))
1163
+ expect(subject.dates[5].date).to eq(Date.new(2014,8,19))
1164
+ expect(subject.dates[6].date).to eq(Date.new(2014,8,20))
1165
+ expect(subject.dates[7].date).to eq(Date.new(2014,8,25))
1166
+ expect(subject.dates[8].date).to eq(Date.new(2014,8,26))
1167
+ expect(subject.dates[9].date).to eq(Date.new(2014,8,27))
1151
1168
  end
1152
1169
  end
1153
1170
 
@@ -1158,7 +1175,7 @@ end
1158
1175
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,1), :period_end => Date.new(2014,8,8))
1159
1176
  subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2014,8,10), :period_end => Date.new(2014,8,31))
1160
1177
  subject.int_day_types = 4|8|16
1161
- another_tt = Factory(:time_table , :int_day_types => (0) )
1178
+ another_tt = create(:time_table , :int_day_types => (0) )
1162
1179
  another_tt.periods.clear
1163
1180
  another_tt.dates.clear
1164
1181
  another_tt.dates << Chouette::TimeTableDate.new( :date => Date.new(2014,8,4), :in_out => true)
@@ -1167,40 +1184,71 @@ end
1167
1184
  subject.disjoin! another_tt
1168
1185
  subject.reload
1169
1186
  end
1170
- it "should have same 2 result periods" do
1171
- subject.periods.size.should == 2
1172
- subject.periods[0].period_start.should == Date.new(2014,8,1)
1173
- subject.periods[0].period_end.should == Date.new(2014,8,8)
1174
- subject.periods[1].period_start.should == Date.new(2014,8,10)
1175
- subject.periods[1].period_end.should == Date.new(2014,8,31)
1187
+ it "should have same 0 result periods" do
1188
+ expect(subject.periods.size).to eq(0)
1189
+ end
1190
+ it "should have 0 day_types" do
1191
+ expect(subject.int_day_types).to eq(0)
1192
+ end
1193
+ it "should have only 10 dates " do
1194
+ expect(subject.dates.size).to eq(10)
1195
+ expect(subject.dates[0].date).to eq(Date.new(2014,8,6))
1196
+ expect(subject.dates[1].date).to eq(Date.new(2014,8,11))
1197
+ expect(subject.dates[2].date).to eq(Date.new(2014,8,12))
1198
+ expect(subject.dates[3].date).to eq(Date.new(2014,8,13))
1199
+ expect(subject.dates[4].date).to eq(Date.new(2014,8,18))
1200
+ expect(subject.dates[5].date).to eq(Date.new(2014,8,19))
1201
+ expect(subject.dates[6].date).to eq(Date.new(2014,8,20))
1202
+ expect(subject.dates[7].date).to eq(Date.new(2014,8,25))
1203
+ expect(subject.dates[8].date).to eq(Date.new(2014,8,26))
1204
+ expect(subject.dates[9].date).to eq(Date.new(2014,8,27))
1205
+ end
1206
+ end
1207
+
1208
+
1209
+ context "with same definition : dsjointed timetable should be empty" do
1210
+ before do
1211
+ subject.periods.clear
1212
+ subject.dates.clear
1213
+ subject.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2015,6,1), :period_end => Date.new(2015,6,30))
1214
+ subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2015,6,16), :in_out => true)
1215
+ subject.dates << Chouette::TimeTableDate.new( :date => Date.new(2015,6,22), :in_out => false)
1216
+ subject.int_day_types = 4|8|16|32|64|128|256
1217
+ another_tt = create(:time_table , :int_day_types => ( 4|8|16|32|64|128|256) )
1218
+ another_tt.periods.clear
1219
+ another_tt.dates.clear
1220
+ another_tt.periods << Chouette::TimeTablePeriod.new(:period_start => Date.new(2015,6,1), :period_end => Date.new(2015,6,30))
1221
+ another_tt.dates << Chouette::TimeTableDate.new( :date => Date.new(2015,6,16), :in_out => true)
1222
+ another_tt.dates << Chouette::TimeTableDate.new( :date => Date.new(2015,6,22), :in_out => false)
1223
+ subject.disjoin! another_tt
1224
+ subject.reload
1225
+ end
1226
+ it "should have same 0 result periods" do
1227
+ expect(subject.periods.size).to eq(0)
1176
1228
  end
1177
- it "should have same day_types" do
1178
- subject.int_day_types.should == 4|8|16
1229
+ it "should have 0 day_types" do
1230
+ expect(subject.int_day_types).to eq(0)
1179
1231
  end
1180
- it "should have only 2 excluded dates " do
1181
- subject.included_days.size.should == 0
1182
- subject.excluded_days.size.should == 2
1183
- subject.excluded_days[0].should == Date.new(2014,8,4)
1184
- subject.excluded_days[1].should == Date.new(2014,8,5)
1232
+ it "should have 0 dates " do
1233
+ expect(subject.dates.size).to eq(0)
1185
1234
  end
1186
1235
  end
1187
-
1188
-
1189
1236
  end
1237
+
1190
1238
  describe "#duplicate" do
1191
1239
  it "should be a copy of" do
1192
1240
  target=subject.duplicate
1193
- target.id.should be_nil
1194
- target.comment.should == "Copy of "+subject.comment
1195
- target.objectid.should == subject.objectid+"_1"
1196
- target.int_day_types.should == subject.int_day_types
1197
- target.dates.size.should == subject.dates.size
1241
+ expect(target.id).to be_nil
1242
+ expect(target.comment).to eq("Copy of "+subject.comment)
1243
+ expect(target.objectid).to eq(subject.objectid+"_1")
1244
+ expect(target.int_day_types).to eq(subject.int_day_types)
1245
+ expect(target.dates.size).to eq(subject.dates.size)
1198
1246
  target.dates.each do |d|
1199
- d.time_table_id.should be_nil
1247
+ expect(d.time_table_id).to be_nil
1200
1248
  end
1201
- target.periods.size.should == subject.periods.size
1249
+ expect(target.periods.size).to eq(subject.periods.size)
1202
1250
  target.periods.each do |p|
1203
- p.time_table_id.should be_nil
1251
+ expect(p.time_table_id).to be_nil
1204
1252
  end
1205
1253
  end
1206
1254
  end
@@ -1210,8 +1258,8 @@ end
1210
1258
  subject.tag_list = "toto, titi"
1211
1259
  subject.save
1212
1260
  subject.reload
1213
- Chouette::TimeTable.tag_counts.size.should == 2
1214
- subject.tag_list.size.should == 2
1261
+ expect(Chouette::TimeTable.tag_counts.size).to eq(2)
1262
+ expect(subject.tag_list.size).to eq(2)
1215
1263
  end
1216
1264
  end
1217
1265