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::ObjectId do
3
+ describe Chouette::ObjectId, :type => :model do
4
4
 
5
5
  def objectid(value = "abc:StopArea:abc123")
6
6
  Chouette::ObjectId.new value
@@ -12,10 +12,17 @@ describe Chouette::ObjectId do
12
12
 
13
13
  subject { objectid("abc") }
14
14
 
15
- it { should_not be_valid }
15
+ it { is_expected.not_to be_valid }
16
16
 
17
- its(:parts) { should be_nil }
18
- its(:system_id) { should be_nil }
17
+ describe '#parts' do
18
+ subject { super().parts }
19
+ it { is_expected.to be_nil }
20
+ end
21
+
22
+ describe '#system_id' do
23
+ subject { super().system_id }
24
+ it { is_expected.to be_nil }
25
+ end
19
26
 
20
27
  end
21
28
 
@@ -23,7 +30,7 @@ describe Chouette::ObjectId do
23
30
 
24
31
  subject { objectid("abc:Line:Aze toto") }
25
32
 
26
- it { should_not be_valid }
33
+ it { is_expected.not_to be_valid }
27
34
 
28
35
 
29
36
  end
@@ -32,7 +39,7 @@ describe Chouette::ObjectId do
32
39
 
33
40
  subject { objectid("ae abc:Line:Aze") }
34
41
 
35
- it { should_not be_valid }
42
+ it { is_expected.not_to be_valid }
36
43
 
37
44
 
38
45
  end
@@ -41,7 +48,7 @@ describe Chouette::ObjectId do
41
48
 
42
49
  subject { objectid("aeabc:Li ne:Aze") }
43
50
 
44
- it { should_not be_valid }
51
+ it { is_expected.not_to be_valid }
45
52
 
46
53
 
47
54
  end
@@ -50,33 +57,33 @@ describe Chouette::ObjectId do
50
57
 
51
58
  subject { objectid("Abc_+19:Line:Abc") }
52
59
 
53
- it { should_not be_valid }
60
+ it { is_expected.not_to be_valid }
54
61
  end
55
62
 
56
63
  context "when invalid in middle part" do
57
64
 
58
65
  subject { objectid("Abc_19:Li56ne:Abc") }
59
66
 
60
- it { should_not be_valid }
67
+ it { is_expected.not_to be_valid }
61
68
  end
62
69
 
63
70
  context "when invalid in last part" do
64
71
 
65
72
  subject { objectid("Abc_19:Line:Ab+c") }
66
73
 
67
- it { should_not be_valid }
74
+ it { is_expected.not_to be_valid }
68
75
  end
69
76
  context "when valid" do
70
77
 
71
78
  subject { objectid("Abc_19:Line:Abc_12-") }
72
79
 
73
- it { should be_valid }
80
+ it { is_expected.to be_valid }
74
81
  end
75
82
 
76
83
  describe "#parts" do
77
84
 
78
85
  it "should be the 3 parts of the ObjectId" do
79
- objectid("abc:StopArea:abc123").parts.should == %w{abc StopArea abc123}
86
+ expect(objectid("abc:StopArea:abc123").parts).to eq(%w{abc StopArea abc123})
80
87
  end
81
88
 
82
89
  end
@@ -84,7 +91,7 @@ describe Chouette::ObjectId do
84
91
  describe "#system_id" do
85
92
 
86
93
  it "should be the first ObjectId parts" do
87
- objectid("first:second:third").system_id.should == "first"
94
+ expect(objectid("first:second:third").system_id).to eq("first")
88
95
  end
89
96
 
90
97
  end
@@ -92,7 +99,7 @@ describe Chouette::ObjectId do
92
99
  describe "#object_type" do
93
100
 
94
101
  it "should be the second ObjectId parts" do
95
- objectid("first:second:third").object_type.should == "second"
102
+ expect(objectid("first:second:third").object_type).to eq("second")
96
103
  end
97
104
 
98
105
  end
@@ -100,14 +107,14 @@ describe Chouette::ObjectId do
100
107
  describe "#local_id" do
101
108
 
102
109
  it "should be the third ObjectId parts" do
103
- objectid("first:second:third").local_id.should == "third"
110
+ expect(objectid("first:second:third").local_id).to eq("third")
104
111
  end
105
112
 
106
113
  end
107
114
 
108
115
  it "should be valid when parts are found" do
109
- subject.stub :parts => "dummy"
110
- subject.should be_valid
116
+ allow(subject).to receive_messages :parts => "dummy"
117
+ expect(subject).to be_valid
111
118
  end
112
119
 
113
120
  describe ".create" do
@@ -117,27 +124,23 @@ describe Chouette::ObjectId do
117
124
  let(:given_local_id) { "localId" }
118
125
 
119
126
  subject { Chouette::ObjectId.create(given_system_id, given_object_type, given_local_id) }
120
-
121
- RSpec::Matchers.define :return_an_objectid_with_given do |attribute|
122
- match do |actual|
123
- actual.send(attribute).should == send("given_#{attribute}")
124
- end
125
- end
126
127
 
127
- it { should return_an_objectid_with_given(:system_id) }
128
- it { should return_an_objectid_with_given(:object_type) }
129
- it { should return_an_objectid_with_given(:local_id) }
128
+ it "should return ObjectId attributes" do
129
+ expect(subject.send(:system_id)).to eq(given_system_id)
130
+ expect(subject.send(:object_type)).to eq(given_object_type)
131
+ expect(subject.send(:local_id)).to eq(given_local_id)
132
+ end
130
133
 
131
134
  end
132
135
 
133
136
  describe ".new" do
134
137
 
135
138
  it "should return an existing ObjectId" do
136
- Chouette::ObjectId.new(objectid).should == objectid
139
+ expect(Chouette::ObjectId.new(objectid)).to eq(objectid)
137
140
  end
138
141
 
139
142
  it "should create an empty ObjectId with nil" do
140
- Chouette::ObjectId.new(nil).should be_empty
143
+ expect(Chouette::ObjectId.new(nil)).to be_empty
141
144
  end
142
145
 
143
146
  end
@@ -1,15 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::Route do
4
- subject { Factory(:route) }
3
+ describe Chouette::Route, :type => :model do
4
+ subject { create(:route) }
5
5
 
6
- it { should validate_uniqueness_of :objectid }
7
- its(:objectid) { should be_kind_of(Chouette::ObjectId) }
6
+ it { is_expected.to validate_uniqueness_of :objectid }
8
7
 
9
- it { should validate_presence_of :name }
10
- it { should validate_presence_of :line }
11
- it { should validate_presence_of :wayback_code }
12
- it { should validate_presence_of :direction_code }
8
+ describe '#objectid' do
9
+ subject { super().objectid }
10
+ it { is_expected.to be_kind_of(Chouette::ObjectId) }
11
+ end
12
+
13
+ #it { is_expected.to validate_presence_of :name }
14
+ it { is_expected.to validate_presence_of :line }
15
+ #it { is_expected.to validate_presence_of :wayback_code }
16
+ #it { is_expected.to validate_presence_of :direction_code }
13
17
 
14
18
  context "reordering methods" do
15
19
  let( :bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}}
@@ -19,7 +23,7 @@ describe Chouette::Route do
19
23
  describe "#reorder!" do
20
24
  context "invalid stop_point_ids" do
21
25
  let( :new_stop_point_ids) { bad_stop_point_ids}
22
- it { subject.reorder!( new_stop_point_ids).should be_false}
26
+ it { expect(subject.reorder!( new_stop_point_ids)).to be_falsey}
23
27
  end
24
28
 
25
29
  context "swaped last and first stop_point_ids" do
@@ -28,13 +32,13 @@ describe Chouette::Route do
28
32
  let!( :old_stop_area_ids) { subject.stop_areas.map(&:id) }
29
33
 
30
34
  it "should keep stop_point_ids order unchanged" do
31
- subject.reorder!( new_stop_point_ids).should be_true
32
- subject.stop_points.map(&:id).should eq( old_stop_point_ids)
35
+ expect(subject.reorder!( new_stop_point_ids)).to be_truthy
36
+ expect(subject.stop_points.map(&:id)).to eq( old_stop_point_ids)
33
37
  end
34
38
  it "should have changed stop_area_ids order" do
35
- subject.reorder!( new_stop_point_ids).should be_true
39
+ expect(subject.reorder!( new_stop_point_ids)).to be_truthy
36
40
  subject.reload
37
- subject.stop_areas.map(&:id).should eq( [old_stop_area_ids.last] + old_stop_area_ids[1..-2] + [old_stop_area_ids.first])
41
+ expect(subject.stop_areas.map(&:id)).to eq( [old_stop_area_ids.last] + old_stop_area_ids[1..-2] + [old_stop_area_ids.first])
38
42
  end
39
43
  end
40
44
  end
@@ -42,29 +46,29 @@ describe Chouette::Route do
42
46
  describe "#stop_point_permutation?" do
43
47
  context "invalid stop_point_ids" do
44
48
  let( :new_stop_point_ids) { bad_stop_point_ids}
45
- it { should_not be_stop_point_permutation( new_stop_point_ids)}
49
+ it { is_expected.not_to be_stop_point_permutation( new_stop_point_ids)}
46
50
  end
47
51
  context "unchanged stop_point_ids" do
48
52
  let( :new_stop_point_ids) { ident}
49
- it { should be_stop_point_permutation( new_stop_point_ids)}
53
+ it { is_expected.to be_stop_point_permutation( new_stop_point_ids)}
50
54
  end
51
55
  context "swaped last and first stop_point_ids" do
52
56
  let( :new_stop_point_ids) { first_last_swap}
53
- it { should be_stop_point_permutation( new_stop_point_ids)}
57
+ it { is_expected.to be_stop_point_permutation( new_stop_point_ids)}
54
58
  end
55
59
  end
56
60
  end
57
61
 
58
62
  describe "#stop_points_attributes=" do
59
- let( :journey_pattern) { Factory( :journey_pattern, :route => subject )}
60
- let( :vehicle_journey) { Factory( :vehicle_journey, :journey_pattern => journey_pattern)}
63
+ let( :journey_pattern) { create( :journey_pattern, :route => subject )}
64
+ let( :vehicle_journey) { create( :vehicle_journey, :journey_pattern => journey_pattern)}
61
65
  def subject_stop_points_attributes
62
66
  {}.tap do |hash|
63
67
  subject.stop_points.each_with_index { |sp,index| hash[ index.to_s ] = sp.attributes }
64
68
  end
65
69
  end
66
70
  context "route having swapped a new stop" do
67
- let( :new_stop_point ){Factory.build( :stop_point, :route => subject)}
71
+ let( :new_stop_point ){build( :stop_point, :route => subject)}
68
72
  def added_stop_hash
69
73
  subject_stop_points_attributes.tap do |h|
70
74
  h["4"] = new_stop_point.attributes.merge( "position" => "4", "_destroy" => "" )
@@ -74,15 +78,15 @@ describe Chouette::Route do
74
78
 
75
79
  it "should have added stop_point in route" do
76
80
  subject.update_attributes( :stop_points_attributes => added_stop_hash)
77
- Chouette::Route.find( subject.id ).stop_points.size.should == new_route_size
81
+ expect(Chouette::Route.find( subject.id ).stop_points.size).to eq(new_route_size)
78
82
  end
79
83
  it "should have added stop_point in route's journey pattern" do
80
84
  subject.update_attributes( :stop_points_attributes => added_stop_hash)
81
- Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.size.should == new_route_size
85
+ expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.size).to eq(new_route_size)
82
86
  end
83
87
  it "should have added stop_point in route's vehicle journey at stop" do
84
88
  subject.update_attributes( :stop_points_attributes => added_stop_hash)
85
- Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.size.should == new_route_size
89
+ expect(Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.size).to eq(new_route_size)
86
90
  end
87
91
  end
88
92
  context "route having swapped stop" do
@@ -92,19 +96,19 @@ describe Chouette::Route do
92
96
  h[ "3" ][ "position" ] = "1"
93
97
  end
94
98
  end
95
- let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.insert( 1, array.delete_at(3)); array.insert( 3, array.delete_at(2) )}.join(",") }
99
+ let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.insert( 1, array.delete_at(3)); array.insert( 3, array.delete_at(2) )} }
96
100
 
97
101
  it "should have swap stop_points from route" do
98
102
  subject.update_attributes( :stop_points_attributes => swapped_stop_hash)
99
- Chouette::Route.find( subject.id ).stop_points.map(&:id).join(",").should == new_stop_id_list
103
+ expect(Chouette::Route.find( subject.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
100
104
  end
101
105
  it "should have swap stop_points from route's journey pattern" do
102
106
  subject.update_attributes( :stop_points_attributes => swapped_stop_hash)
103
- Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id).join(",").should == new_stop_id_list
107
+ expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
104
108
  end
105
109
  it "should have swap stop_points from route's vehicle journey at stop" do
106
110
  subject.update_attributes( :stop_points_attributes => swapped_stop_hash)
107
- Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id).join(",").should == new_stop_id_list
111
+ expect(Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id)).to match_array(new_stop_id_list)
108
112
  end
109
113
  end
110
114
  context "route having a deleted stop" do
@@ -113,19 +117,19 @@ describe Chouette::Route do
113
117
  h[ "1" ][ "_destroy" ] = "1"
114
118
  end
115
119
  end
116
- let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.delete_at(1) }.join(",") }
120
+ let!( :new_stop_id_list ){ subject.stop_points.map(&:id).tap {|array| array.delete_at(1) } }
117
121
 
118
122
  it "should ignore deleted stop_point from route" do
119
123
  subject.update_attributes( :stop_points_attributes => removed_stop_hash)
120
- Chouette::Route.find( subject.id ).stop_points.map(&:id).join(",").should == new_stop_id_list
124
+ expect(Chouette::Route.find( subject.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
121
125
  end
122
126
  it "should ignore deleted stop_point from route's journey pattern" do
123
127
  subject.update_attributes( :stop_points_attributes => removed_stop_hash)
124
- Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id).join(",").should == new_stop_id_list
128
+ expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)).to eq(new_stop_id_list)
125
129
  end
126
130
  it "should ignore deleted stop_point from route's vehicle journey at stop" do
127
131
  subject.update_attributes( :stop_points_attributes => removed_stop_hash)
128
- Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id).join(",").should == new_stop_id_list
132
+ expect(Chouette::VehicleJourney.find( vehicle_journey.id ).vehicle_journey_at_stops.map(&:stop_point_id)).to match_array(new_stop_id_list)
129
133
  end
130
134
  end
131
135
  end
@@ -135,29 +139,29 @@ describe Chouette::Route do
135
139
  context "when arg is first quay id" do
136
140
  let(:first_stop_point) { subject.stop_points.first}
137
141
  it "should return first quay" do
138
- subject.stop_points.find_by_stop_area( first_stop_point.stop_area_id).should eq( first_stop_point)
142
+ expect(subject.stop_points.find_by_stop_area( first_stop_point.stop_area_id)).to eq( first_stop_point)
139
143
  end
140
144
  end
141
145
  end
142
146
  end
143
147
  describe "#stop_areas" do
144
- let(:line){ Factory(:line)}
145
- let(:route_1){ Factory(:route, :line => line)}
146
- let(:route_2){ Factory(:route, :line => line)}
148
+ let(:line){ create(:line)}
149
+ let(:route_1){ create(:route, :line => line)}
150
+ let(:route_2){ create(:route, :line => line)}
147
151
  it "should retreive all stop_area on route" do
148
152
  route_1.stop_areas.each do |sa|
149
- sa.stop_points.map(&:route_id).uniq.should == [route_1.id]
153
+ expect(sa.stop_points.map(&:route_id).uniq).to eq([route_1.id])
150
154
  end
151
155
  end
152
156
 
153
157
  context "when route is looping: last and first stop area are the same" do
154
158
  it "should retreive same stop_area one last and first position" do
155
- route_loop = Factory(:route, :line => line)
159
+ route_loop = create(:route, :line => line)
156
160
  first_stop = Chouette::StopPoint.where( :route_id => route_loop.id, :position => 0).first
157
- last_stop = Factory(:stop_point, :route => route_loop, :position => 5, :stop_area => first_stop.stop_area)
161
+ last_stop = create(:stop_point, :route => route_loop, :position => 4, :stop_area => first_stop.stop_area)
158
162
 
159
- route_loop.stop_areas.size.should == 6
160
- route_loop.stop_areas.select {|s| s.id == first_stop.stop_area.id}.size.should == 2
163
+ expect(route_loop.stop_areas.size).to eq(6)
164
+ expect(route_loop.stop_areas.select {|s| s.id == first_stop.stop_area.id}.size).to eq(2)
161
165
  end
162
166
  end
163
167
  end
@@ -172,14 +176,14 @@ describe Chouette::Route do
172
176
  direction_code = Chouette::Direction.new( Chouette::Route.direction_binding[ direction])
173
177
  it "should be #{direction_code}" do
174
178
  subject.direction = direction
175
- subject.direction_code.should == direction_code
179
+ expect(subject.direction_code).to eq(direction_code)
176
180
  end
177
181
  end
178
182
  end
179
183
  context "when direction is nil" do
180
184
  it "should be nil" do
181
185
  subject.direction = nil
182
- subject.direction_code.should be_nil
186
+ expect(subject.direction_code).to be_nil
183
187
  end
184
188
  end
185
189
  end
@@ -187,13 +191,13 @@ describe Chouette::Route do
187
191
  context "when unknown direction is provided" do
188
192
  it "should change direction to nil" do
189
193
  subject.direction_code = "dummy"
190
- subject.direction.should be_nil
194
+ expect(subject.direction).to be_nil
191
195
  end
192
196
  end
193
197
  context "when an existing direction (west) is provided" do
194
198
  it "should change direction Direction.west" do
195
199
  subject.direction_code = "west"
196
- subject.direction.should == "West"
200
+ expect(subject.direction).to eq("West")
197
201
  end
198
202
  end
199
203
  end
@@ -206,14 +210,14 @@ describe Chouette::Route do
206
210
  wayback_code = Chouette::Wayback.new( Chouette::Route.wayback_binding[ wayback])
207
211
  it "should be #{wayback_code}" do
208
212
  subject.wayback = wayback
209
- subject.wayback_code.should == wayback_code
213
+ expect(subject.wayback_code).to eq(wayback_code)
210
214
  end
211
215
  end
212
216
  end
213
217
  context "when wayback is nil" do
214
218
  it "should be nil" do
215
219
  subject.wayback = nil
216
- subject.wayback_code.should be_nil
220
+ expect(subject.wayback_code).to be_nil
217
221
  end
218
222
  end
219
223
  end
@@ -221,13 +225,13 @@ describe Chouette::Route do
221
225
  context "when unknown wayback is provided" do
222
226
  it "should change wayback to nil" do
223
227
  subject.wayback_code = "dummy"
224
- subject.wayback.should be_nil
228
+ expect(subject.wayback).to be_nil
225
229
  end
226
230
  end
227
231
  context "when an existing wayback (straight_forward) is provided" do
228
232
  it "should change wayback Wayback.straight_forward" do
229
233
  subject.wayback_code = "straight_forward"
230
- subject.wayback.should == "A"
234
+ expect(subject.wayback).to eq("A")
231
235
  end
232
236
  end
233
237
  end