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,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::TransportMode do
3
+ describe Chouette::TransportMode, :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::TransportMode 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("unknown").to_i.should == 0
29
+ expect(mode("unknown").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 be_unknown
33
+ expect(mode(0)).to be_unknown
34
34
  end
35
35
 
36
36
  it "should accept another mode" do
37
- Chouette::TransportMode.new(mode("test")).should == mode("test")
37
+ expect(Chouette::TransportMode.new(mode("test"))).to eq(mode("test"))
38
38
  end
39
39
 
40
40
  end
@@ -42,11 +42,11 @@ describe Chouette::TransportMode do
42
42
  describe "#public_transport?" do
43
43
 
44
44
  it "should return false for interchange" do
45
- mode("interchange").should_not be_public_transport
45
+ expect(mode("interchange")).not_to be_public_transport
46
46
  end
47
47
 
48
48
  it "should return true for other modes" do
49
- mode("unknown").should be_public_transport
49
+ expect(mode("unknown")).to be_public_transport
50
50
  end
51
51
 
52
52
  end
@@ -55,7 +55,7 @@ describe Chouette::TransportMode do
55
55
 
56
56
  Chouette::TransportMode.definitions.each do |text_code, numerical_code|
57
57
  it "should include a TransportMode #{text_code}" do
58
- Chouette::TransportMode.all.should include(Chouette::TransportMode.new(text_code))
58
+ expect(Chouette::TransportMode.all).to include(Chouette::TransportMode.new(text_code))
59
59
  end
60
60
  end
61
61
 
@@ -1,29 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::TridentActiveRecord do
3
+ describe Chouette::TridentActiveRecord, :type => :model do
4
4
 
5
- it { Chouette::TridentActiveRecord.ancestors.should include(Chouette::ActiveRecord) }
5
+ it { expect(Chouette::TridentActiveRecord.ancestors).to include(Chouette::ActiveRecord) }
6
6
 
7
- subject { Factory(:time_table) }
7
+ subject { create(:time_table) }
8
8
 
9
9
  describe "#uniq_objectid" do
10
10
 
11
11
  it "should rebuild objectid" do
12
- tm = Factory(:time_table)
12
+ tm = create(:time_table)
13
13
  tm.objectid = subject.objectid
14
14
  tm.uniq_objectid
15
- tm.objectid.should == subject.objectid+"_1"
15
+ expect(tm.objectid).to eq(subject.objectid+"_1")
16
16
  end
17
17
 
18
18
  it "should rebuild objectid" do
19
- tm = Factory(:time_table)
19
+ tm = create(:time_table)
20
20
  tm.objectid = subject.objectid
21
21
  tm.uniq_objectid
22
22
  tm.save
23
- tm = Factory(:time_table)
23
+ tm = create(:time_table)
24
24
  tm.objectid = subject.objectid
25
25
  tm.uniq_objectid
26
- tm.objectid.should == subject.objectid+"_2"
26
+ expect(tm.objectid).to eq(subject.objectid+"_2")
27
27
  end
28
28
 
29
29
  end
@@ -33,19 +33,19 @@ describe Chouette::TridentActiveRecord do
33
33
  it "should left objectid" do
34
34
  tm = Chouette::TimeTable.new :comment => "merge1" , :objectid => "NINOXE:Timetable:merge1"
35
35
  tm.prepare_auto_columns
36
- tm.objectid.should == "NINOXE:Timetable:merge1"
36
+ expect(tm.objectid).to eq("NINOXE:Timetable:merge1")
37
37
  end
38
38
 
39
39
  it "should add pending_id to objectid" do
40
40
  tm = Chouette::TimeTable.new :comment => "merge1"
41
41
  tm.prepare_auto_columns
42
- tm.objectid.start_with?("NINOXE:Timetable:__pending_id__").should be_true
42
+ expect(tm.objectid.start_with?("NINOXE:Timetable:__pending_id__")).to be_truthy
43
43
  end
44
44
 
45
45
  it "should set id to objectid" do
46
46
  tm = Chouette::TimeTable.new :comment => "merge1"
47
47
  tm.save
48
- tm.objectid.should == "NINOXE:Timetable:"+tm.id.to_s
48
+ expect(tm.objectid).to eq("NINOXE:Timetable:"+tm.id.to_s)
49
49
  end
50
50
 
51
51
  it "should detect objectid conflicts" do
@@ -55,7 +55,7 @@ describe Chouette::TridentActiveRecord do
55
55
  tm.save
56
56
  tm = Chouette::TimeTable.new :comment => "merge1"
57
57
  tm.save
58
- tm.objectid.should == "NINOXE:Timetable:"+tm.id.to_s+"_1"
58
+ expect(tm.objectid).to eq("NINOXE:Timetable:"+tm.id.to_s+"_1")
59
59
  end
60
60
 
61
61
  end
@@ -65,14 +65,14 @@ describe Chouette::TridentActiveRecord do
65
65
  it "should build automatic objectid when empty" do
66
66
  g1 = Chouette::GroupOfLine.new( :name => "g1")
67
67
  g1.save
68
- g1.objectid.should == "NINOXE:GroupOfLine:"+g1.id.to_s
68
+ expect(g1.objectid).to eq("NINOXE:GroupOfLine:"+g1.id.to_s)
69
69
  end
70
70
 
71
71
  it "should build automatic objectid with fixed when only suffix given" do
72
72
  g1 = Chouette::GroupOfLine.new( :name => "g1")
73
73
  g1.objectid = "toto"
74
74
  g1.save
75
- g1.objectid.should == "NINOXE:GroupOfLine:toto"
75
+ expect(g1.objectid).to eq("NINOXE:GroupOfLine:toto")
76
76
  end
77
77
 
78
78
  it "should build automatic objectid with extension when already exists" do
@@ -83,7 +83,7 @@ describe Chouette::TridentActiveRecord do
83
83
  g1.save
84
84
  g2 = Chouette::GroupOfLine.new( :name => "g2")
85
85
  g2.save
86
- g2.objectid.should == "NINOXE:GroupOfLine:"+g2.id.to_s+"_1"
86
+ expect(g2.objectid).to eq("NINOXE:GroupOfLine:"+g2.id.to_s+"_1")
87
87
  end
88
88
 
89
89
  it "should build automatic objectid with extension when already exists" do
@@ -97,7 +97,7 @@ describe Chouette::TridentActiveRecord do
97
97
  g2.save
98
98
  g3 = Chouette::GroupOfLine.new( :name => "g3")
99
99
  g3.save
100
- g3.objectid.should == "NINOXE:GroupOfLine:"+g3.id.to_s+"_2"
100
+ expect(g3.objectid).to eq("NINOXE:GroupOfLine:"+g3.id.to_s+"_2")
101
101
  end
102
102
 
103
103
  it "should build automatic objectid when id cleared" do
@@ -106,7 +106,7 @@ describe Chouette::TridentActiveRecord do
106
106
  g1.save
107
107
  g1.objectid = nil
108
108
  g1.save
109
- g1.objectid.should == "NINOXE:GroupOfLine:"+g1.id.to_s
109
+ expect(g1.objectid).to eq("NINOXE:GroupOfLine:"+g1.id.to_s)
110
110
  end
111
111
  end
112
112
 
@@ -1,19 +1,20 @@
1
1
  require 'spec_helper'
2
+ require 'pp'
2
3
 
3
- describe Chouette::VehicleJourneyAtStop do
4
- let!(:vehicle_journey){ Factory(:vehicle_journey_odd)}
4
+ describe Chouette::VehicleJourneyAtStop, :type => :model do
5
+ let!(:vehicle_journey) { create(:vehicle_journey_odd)}
5
6
  subject { vehicle_journey.vehicle_journey_at_stops.first }
6
7
 
7
8
  describe "#exceeds_gap?" do
8
9
  it "should return false if gap < 1.hour" do
9
10
  t1 = 1.minutes.ago
10
11
  t2 = 1.minutes.ago + 3.hour
11
- subject.exceeds_gap?(t1, t2).should be_true
12
+ expect(subject.exceeds_gap?(t1, t2)).to be_truthy
12
13
  end
13
14
  it "should return false if gap > 2.hour" do
14
15
  t1 = 1.minutes.ago
15
16
  t2 = 1.minutes.ago + 3.minutes
16
- subject.exceeds_gap?(t1, t2).should be_false
17
+ expect(subject.exceeds_gap?(t1, t2)).to be_falsey
17
18
  end
18
19
  end
19
20
 
@@ -23,23 +24,23 @@ describe Chouette::VehicleJourneyAtStop do
23
24
  context "when vjas#arrival_time exceeds gap" do
24
25
  it "should add errors on arrival_time" do
25
26
  vjas1.arrival_time = vjas2.arrival_time - 3.hour
26
- vjas2.increasing_times_validate(vjas1).should be_false
27
- vjas2.errors.should_not be_empty
28
- vjas2.errors[:arrival_time].should_not be_blank
27
+ expect(vjas2.increasing_times_validate(vjas1)).to be_falsey
28
+ expect(vjas2.errors).not_to be_empty
29
+ expect(vjas2.errors[:arrival_time]).not_to be_blank
29
30
  end
30
31
  end
31
32
  context "when vjas#departure_time exceeds gap" do
32
33
  it "should add errors on departure_time" do
33
34
  vjas1.departure_time = vjas2.departure_time - 3.hour
34
- vjas2.increasing_times_validate(vjas1).should be_false
35
- vjas2.errors.should_not be_empty
36
- vjas2.errors[:departure_time].should_not be_blank
35
+ expect(vjas2.increasing_times_validate(vjas1)).to be_falsey
36
+ expect(vjas2.errors).not_to be_empty
37
+ expect(vjas2.errors[:departure_time]).not_to be_blank
37
38
  end
38
39
  end
39
40
  context "when vjas does'nt exceed gap" do
40
41
  it "should not add errors" do
41
- vjas2.increasing_times_validate(vjas1).should be_true
42
- vjas2.errors.should be_empty
42
+ expect(vjas2.increasing_times_validate(vjas1)).to be_truthy
43
+ expect(vjas2.errors).to be_empty
43
44
  end
44
45
  end
45
46
  end
@@ -1,80 +1,80 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::VehicleJourney do
4
- subject { Factory(:vehicle_journey_odd) }
3
+ describe Chouette::VehicleJourney, :type => :model do
4
+ subject { create(:vehicle_journey_odd) }
5
5
 
6
6
  describe "in_relation_to_a_journey_pattern methods" do
7
- let!(:route) { Factory(:route)}
8
- let!(:journey_pattern) { Factory(:journey_pattern, :route => route)}
9
- let!(:journey_pattern_odd) { Factory(:journey_pattern_odd, :route => route)}
10
- let!(:journey_pattern_even) { Factory(:journey_pattern_even, :route => route)}
7
+ let!(:route) { create(:route)}
8
+ let!(:journey_pattern) { create(:journey_pattern, :route => route)}
9
+ let!(:journey_pattern_odd) { create(:journey_pattern_odd, :route => route)}
10
+ let!(:journey_pattern_even) { create(:journey_pattern_even, :route => route)}
11
11
 
12
12
  context "when vehicle_journey is on odd stop whereas selected journey_pattern is on all stops" do
13
- subject { Factory(:vehicle_journey, :route => route, :journey_pattern => journey_pattern_odd)}
13
+ subject { create(:vehicle_journey, :route => route, :journey_pattern => journey_pattern_odd)}
14
14
  describe "#extra_stops_in_relation_to_a_journey_pattern" do
15
15
  it "should be empty" do
16
- subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern).should be_empty
16
+ expect(subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern)).to be_empty
17
17
  end
18
18
  end
19
19
  describe "#extra_vjas_in_relation_to_a_journey_pattern" do
20
20
  it "should be empty" do
21
- subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern).should be_empty
21
+ expect(subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern)).to be_empty
22
22
  end
23
23
  end
24
24
  describe "#missing_stops_in_relation_to_a_journey_pattern" do
25
25
  it "should return even stops" do
26
26
  result = subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern)
27
- result.should == journey_pattern_even.stop_points
27
+ expect(result).to eq(journey_pattern_even.stop_points)
28
28
  end
29
29
  end
30
30
  describe "#update_journey_pattern" do
31
31
  it "should new_record for added vjas" do
32
32
  subject.update_journey_pattern( journey_pattern)
33
33
  subject.vehicle_journey_at_stops.select{ |vjas| vjas.new_record? }.each do |vjas|
34
- journey_pattern_even.stop_points.should include( vjas.stop_point)
34
+ expect(journey_pattern_even.stop_points).to include( vjas.stop_point)
35
35
  end
36
36
  end
37
37
  it "should add vjas on each even stops" do
38
38
  subject.update_journey_pattern( journey_pattern)
39
39
  vehicle_stops = subject.vehicle_journey_at_stops.map(&:stop_point)
40
40
  journey_pattern_even.stop_points.each do |sp|
41
- vehicle_stops.should include(sp)
41
+ expect(vehicle_stops).to include(sp)
42
42
  end
43
43
  end
44
44
  it "should not mark any vjas as _destroy" do
45
45
  subject.update_journey_pattern( journey_pattern)
46
- subject.vehicle_journey_at_stops.any?{ |vjas| vjas._destroy }.should be_false
46
+ expect(subject.vehicle_journey_at_stops.any?{ |vjas| vjas._destroy }).to be_falsey
47
47
  end
48
48
  end
49
49
  end
50
50
  context "when vehicle_journey is on all stops whereas selected journey_pattern is on odd stops" do
51
- subject { Factory(:vehicle_journey, :route => route, :journey_pattern => journey_pattern)}
51
+ subject { create(:vehicle_journey, :route => route, :journey_pattern => journey_pattern)}
52
52
  describe "#missing_stops_in_relation_to_a_journey_pattern" do
53
53
  it "should be empty" do
54
- subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern_odd).should be_empty
54
+ expect(subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern_odd)).to be_empty
55
55
  end
56
56
  end
57
57
  describe "#extra_stops_in_relation_to_a_journey_pattern" do
58
58
  it "should return even stops" do
59
59
  result = subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern_odd)
60
- result.should == journey_pattern_even.stop_points
60
+ expect(result).to eq(journey_pattern_even.stop_points)
61
61
  end
62
62
  end
63
63
  describe "#extra_vjas_in_relation_to_a_journey_pattern" do
64
64
  it "should return vjas on even stops" do
65
65
  result = subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern_odd)
66
- result.map(&:stop_point).should == journey_pattern_even.stop_points
66
+ expect(result.map(&:stop_point)).to eq(journey_pattern_even.stop_points)
67
67
  end
68
68
  end
69
69
  describe "#update_journey_pattern" do
70
70
  it "should add no new vjas" do
71
71
  subject.update_journey_pattern( journey_pattern_odd)
72
- subject.vehicle_journey_at_stops.any?{ |vjas| vjas.new_record? }.should be_false
72
+ expect(subject.vehicle_journey_at_stops.any?{ |vjas| vjas.new_record? }).to be_falsey
73
73
  end
74
74
  it "should mark vehicle_journey_at_stops as _destroy on even stops" do
75
75
  subject.update_journey_pattern( journey_pattern_odd)
76
76
  subject.vehicle_journey_at_stops.each { |vjas|
77
- vjas._destroy.should == journey_pattern_even.stop_points.include?(vjas.stop_point)
77
+ expect(vjas._destroy).to eq(journey_pattern_even.stop_points.include?(vjas.stop_point))
78
78
  }
79
79
  end
80
80
  end
@@ -90,8 +90,8 @@ describe Chouette::VehicleJourney do
90
90
  end
91
91
  it "should make instance invalid" do
92
92
  subject.increasing_times
93
- subject.vehicle_journey_at_stops[1].errors[:departure_time].should_not be_blank
94
- subject.should_not be_valid
93
+ expect(subject.vehicle_journey_at_stops[1].errors[:departure_time]).not_to be_blank
94
+ expect(subject).not_to be_valid
95
95
  end
96
96
  end
97
97
  describe "#update_attributes" do
@@ -100,48 +100,48 @@ describe Chouette::VehicleJourney do
100
100
  "1"=>{"id" => subject.vehicle_journey_at_stops[1].id, "arrival_time" => (1.minutes.ago + 2.hour),"departure_time" => (1.minutes.ago + 2.hour)}
101
101
  }}}
102
102
  it "should return false" do
103
- subject.update_attributes(params).should be_false
103
+ expect(subject.update_attributes(params)).to be_falsey
104
104
  end
105
105
  it "should make instance invalid" do
106
106
  subject.update_attributes(params)
107
- subject.should_not be_valid
107
+ expect(subject).not_to be_valid
108
108
  end
109
109
  it "should let first vjas without any errors" do
110
110
  subject.update_attributes(params)
111
- subject.vehicle_journey_at_stops[0].errors.should be_empty
111
+ expect(subject.vehicle_journey_at_stops[0].errors).to be_empty
112
112
  end
113
113
  it "should add an error on second vjas" do
114
114
  subject.update_attributes(params)
115
- subject.vehicle_journey_at_stops[1].errors[:departure_time].should_not be_blank
115
+ expect(subject.vehicle_journey_at_stops[1].errors[:departure_time]).not_to be_blank
116
116
  end
117
117
  end
118
118
  end
119
119
 
120
120
  context "#time_table_tokens=" do
121
- let!(:tm1){Factory(:time_table, :comment => "TM1")}
122
- let!(:tm2){Factory(:time_table, :comment => "TM2")}
121
+ let!(:tm1){create(:time_table, :comment => "TM1")}
122
+ let!(:tm2){create(:time_table, :comment => "TM2")}
123
123
 
124
124
  it "should return associated time table ids" do
125
125
  subject.update_attributes :time_table_tokens => [tm1.id, tm2.id].join(',')
126
- subject.time_tables.should include( tm1)
127
- subject.time_tables.should include( tm2)
126
+ expect(subject.time_tables).to include( tm1)
127
+ expect(subject.time_tables).to include( tm2)
128
128
  end
129
129
  end
130
130
  describe "#bounding_dates" do
131
131
  before(:each) do
132
- tm1 = Factory.build(:time_table, :dates =>
133
- [ Factory.build(:time_table_date, :date => 1.days.ago.to_date, :in_out => true),
134
- Factory.build(:time_table_date, :date => 2.days.ago.to_date, :in_out => true)])
135
- tm2 = Factory.build(:time_table, :periods =>
136
- [ Factory.build(:time_table_period, :period_start => 4.days.ago.to_date, :period_end => 3.days.ago.to_date)])
137
- tm3 = Factory.build(:time_table)
132
+ tm1 = build(:time_table, :dates =>
133
+ [ build(:time_table_date, :date => 1.days.ago.to_date, :in_out => true),
134
+ build(:time_table_date, :date => 2.days.ago.to_date, :in_out => true) ])
135
+ tm2 = build(:time_table, :periods =>
136
+ [ build(:time_table_period, :period_start => 4.days.ago.to_date, :period_end => 3.days.ago.to_date)])
137
+ tm3 = build(:time_table)
138
138
  subject.time_tables = [ tm1, tm2, tm3]
139
139
  end
140
140
  it "should return min date from associated calendars" do
141
- subject.bounding_dates.min.should == 4.days.ago.to_date
141
+ expect(subject.bounding_dates.min).to eq(4.days.ago.to_date)
142
142
  end
143
143
  it "should return max date from associated calendars" do
144
- subject.bounding_dates.max.should == 1.days.ago.to_date
144
+ expect(subject.bounding_dates.max).to eq(1.days.ago.to_date)
145
145
  end
146
146
  end
147
147
  context "#vehicle_journey_at_stops" do
@@ -150,7 +150,7 @@ describe Chouette::VehicleJourney do
150
150
  vj_stop_ids = subject.vehicle_journey_at_stops.map(&:stop_point_id)
151
151
  expected_order = route.stop_points.map(&:id).select {|s_id| vj_stop_ids.include?(s_id)}
152
152
 
153
- vj_stop_ids.should == expected_order
153
+ expect(vj_stop_ids).to eq(expected_order)
154
154
  end
155
155
 
156
156
  end
@@ -166,14 +166,14 @@ describe Chouette::VehicleJourney do
166
166
  transport_mode_name = Chouette::TransportMode.new(transport_mode.underscore)
167
167
  it "should be #{transport_mode_name}" do
168
168
  subject.transport_mode = transport_mode
169
- subject.transport_mode_name.should == transport_mode_name
169
+ expect(subject.transport_mode_name).to eq(transport_mode_name)
170
170
  end
171
171
  end
172
172
  end
173
173
  context "when transport_mode is nil" do
174
174
  it "should be nil" do
175
175
  subject.transport_mode = nil
176
- subject.transport_mode_name.should be_nil
176
+ expect(subject.transport_mode_name).to be_nil
177
177
  end
178
178
  end
179
179
 
@@ -183,7 +183,7 @@ describe Chouette::VehicleJourney do
183
183
 
184
184
  it "should change transport_mode with TransportMode#name" do
185
185
  subject.transport_mode_name = "Test"
186
- subject.transport_mode.should == "Test"
186
+ expect(subject.transport_mode).to eq("Test")
187
187
  end
188
188
 
189
189
  end
@@ -191,21 +191,21 @@ describe Chouette::VehicleJourney do
191
191
  describe ".transport_mode_names" do
192
192
 
193
193
  it "should not include unknown transport_mode_name" do
194
- Chouette::VehicleJourney.transport_mode_names.should_not include(Chouette::TransportMode.new("unknown"))
194
+ expect(Chouette::VehicleJourney.transport_mode_names).not_to include(Chouette::TransportMode.new("unknown"))
195
195
  end
196
196
 
197
197
  it "should not include interchange transport_mode" do
198
- Chouette::VehicleJourney.transport_mode_names.should_not include(Chouette::TransportMode.new("interchange"))
198
+ expect(Chouette::VehicleJourney.transport_mode_names).not_to include(Chouette::TransportMode.new("interchange"))
199
199
  end
200
200
 
201
201
  end
202
202
 
203
203
  describe "#footnote_ids=" do
204
204
  context "when line have footnotes, " do
205
- let!( :route) { Factory( :route ) }
205
+ let!( :route) { create( :route ) }
206
206
  let!( :line) { route.line }
207
- let!( :footnote_first) {Factory( :footnote, :code => "1", :label => "dummy 1", :line => route.line)}
208
- let!( :footnote_second) {Factory( :footnote, :code => "2", :label => "dummy 2", :line => route.line)}
207
+ let!( :footnote_first) {create( :footnote, :code => "1", :label => "dummy 1", :line => route.line)}
208
+ let!( :footnote_second) {create( :footnote, :code => "2", :label => "dummy 2", :line => route.line)}
209
209
 
210
210
 
211
211
  it "should update vehicle's footnotes" do
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Chouette::Geometry::LinePresenter do
4
- let!(:line) { Factory(:line_with_stop_areas_having_parent) }
4
+ let!(:line) { create(:line_with_stop_areas_having_parent) }
5
5
  subject { Chouette::Geometry::LinePresenter.new(line)}
6
6
 
7
7
  describe "#routes_localized_commercials" do
8
8
  it "should return 3 stop_areas" do
9
- subject.routes_localized_commercials(line.routes.first).size.should == 5
9
+ expect(subject.routes_localized_commercials(line.routes.first).size).to eq(10)
10
10
  end
11
11
  end
12
12
  end
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,27 @@
1
1
  # Configure Rails Envinronment
2
- ENV["RAILS_ENV"] = "test"
2
+ ENV["RAILS_ENV"] ||= "test"
3
+ require 'spec_helper'
3
4
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
-
5
5
  require 'rspec/rails'
6
- require 'rspec/autorun'
7
6
 
7
+ # Add additional requires below this line. Rails is not loaded until this point!
8
8
  require 'shoulda-matchers'
9
9
  require 'factory_girl_rails'
10
-
11
10
  require 'geo_ruby'
12
11
 
12
+ # Requires supporting ruby files with custom matchers and macros, etc, in
13
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
14
+ # run as spec files by default. This means that files in spec/support that end
15
+ # in _spec.rb will both be required and run as specs, causing the specs to be
16
+ # run twice. It is recommended that you do not name files matching this glob to
17
+ # end with _spec.rb. You can configure this pattern with the --pattern
18
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
19
+ #
20
+ # The following line is provided for convenience purposes. It has the downside
21
+ # of increasing the boot-up time by auto-requiring all files in the support
22
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
23
+ # require only the support files necessary.
24
+ #
13
25
  ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
14
26
 
15
27
  # Requires supporting ruby files with custom matchers and macros, etc,
@@ -17,7 +29,13 @@ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
17
29
  Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
18
30
  Dir[File.join(ENGINE_RAILS_ROOT, "lib/factories/**/*.rb")].each {|f| require f }
19
31
 
32
+ # Checks for pending migrations before tests are run.
33
+ # If you are not using ActiveRecord, you can remove this line.
34
+ ActiveRecord::Migration.maintain_test_schema!
35
+
20
36
  RSpec.configure do |config|
37
+ config.include FactoryGirl::Syntax::Methods
38
+
21
39
  # == Mock Framework
22
40
  #
23
41
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
@@ -35,11 +53,6 @@ RSpec.configure do |config|
35
53
  # instead of true.
36
54
  config.use_transactional_fixtures = true
37
55
 
38
- # If true, the base class of anonymous controllers will be inferred
39
- # automatically. This will be the default behavior in future versions of
40
- # rspec-rails.
41
- config.infer_base_class_for_anonymous_controllers = false
42
-
43
56
  end
44
57
 
45
58