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,17 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::ConnectionLink do
4
- let!(:quay) { Factory :stop_area, :area_type => "Quay" }
5
- let!(:boarding_position) { Factory :stop_area, :area_type => "BoardingPosition" }
6
- let!(:commercial_stop_point) { Factory :stop_area, :area_type => "CommercialStopPoint" }
7
- let!(:stop_place) { Factory :stop_area, :area_type => "StopPlace" }
8
- let!(:itl) { Factory :stop_area, :area_type => "ITL" }
9
- subject { Factory(:connection_link) }
10
-
11
- it { should validate_uniqueness_of :objectid }
12
- its(:objectid) { should be_kind_of(Chouette::ObjectId) }
3
+ describe Chouette::ConnectionLink, :type => :model do
4
+ let!(:quay) { create :stop_area, :area_type => "Quay" }
5
+ let!(:boarding_position) { create :stop_area, :area_type => "BoardingPosition" }
6
+ let!(:commercial_stop_point) { create :stop_area, :area_type => "CommercialStopPoint" }
7
+ let!(:stop_place) { create :stop_area, :area_type => "StopPlace" }
8
+ let!(:itl) { create :stop_area, :area_type => "ITL" }
9
+ subject { create(:connection_link) }
10
+
11
+ it { is_expected.to validate_uniqueness_of :objectid }
12
+
13
+ describe '#objectid' do
14
+ subject { super().objectid }
15
+ it { is_expected.to be_kind_of(Chouette::ObjectId) }
16
+ end
13
17
 
14
- it { should validate_presence_of :name }
18
+ it { is_expected.to validate_presence_of :name }
15
19
 
16
20
  describe "#connection_link_type" do
17
21
 
@@ -24,14 +28,14 @@ describe Chouette::ConnectionLink do
24
28
  connection_link_type = Chouette::ConnectionLinkType.new(link_type.underscore)
25
29
  it "should be #{connection_link_type}" do
26
30
  subject.link_type = link_type
27
- subject.connection_link_type.should == connection_link_type
31
+ expect(subject.connection_link_type).to eq(connection_link_type)
28
32
  end
29
33
  end
30
34
  end
31
35
  context "when link_type is nil" do
32
36
  it "should be nil" do
33
37
  subject.link_type = nil
34
- subject.connection_link_type.should be_nil
38
+ expect(subject.connection_link_type).to be_nil
35
39
  end
36
40
  end
37
41
 
@@ -41,7 +45,7 @@ describe Chouette::ConnectionLink do
41
45
 
42
46
  it "should change link_type with ConnectionLinkType#name" do
43
47
  subject.connection_link_type = "Test"
44
- subject.link_type.should == "Test"
48
+ expect(subject.link_type).to eq("Test")
45
49
  end
46
50
 
47
51
  end
@@ -49,7 +53,7 @@ describe Chouette::ConnectionLink do
49
53
  describe ".possible_areas" do
50
54
 
51
55
  it "should not find areas type ITL" do
52
- subject.possible_areas.should_not == [itl]
56
+ expect(subject.possible_areas).not_to eq([itl])
53
57
  end
54
58
  end
55
59
 
@@ -1,24 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::Direction do
3
+ describe Chouette::Direction, :type => :model do
4
4
 
5
5
  describe ".new" do
6
6
  context "when single argument provided is a direction" do
7
7
  let(:text) { "dummy"}
8
8
  let(:direction){ Chouette::Direction.new( text, 1)}
9
9
  it "should be equals to the provided direction" do
10
- direction.should == Chouette::Direction.new( direction)
10
+ expect(direction).to eq(Chouette::Direction.new( direction))
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
15
  shared_examples_for "west direction" do
16
16
  it "should return true to #west? " do
17
- direction.should be_west
17
+ expect(direction).to be_west
18
18
  end
19
19
  context "#to_i" do
20
20
  it "should return 6" do
21
- direction.to_i.should == 6
21
+ expect(direction.to_i).to eq(6)
22
22
  end
23
23
  end
24
24
  end
@@ -38,22 +38,22 @@ describe Chouette::Direction do
38
38
  let(:direction){ Chouette::Direction.new( text, number)}
39
39
 
40
40
  it "should return true to #dummy? " do
41
- direction.send( "#{text}?".to_sym).should be_true
41
+ expect(direction.send( "#{text}?".to_sym)).to be_truthy
42
42
  end
43
43
 
44
44
  it "should return false to #other-dummy? " do
45
- direction.send( "other-#{text}?".to_sym).should be_false
45
+ expect(direction.send( "other-#{text}?".to_sym)).to be_falsey
46
46
  end
47
47
 
48
48
  context "#to_i" do
49
49
  it "should return provided number" do
50
- direction.to_i.should == number
50
+ expect(direction.to_i).to eq(number)
51
51
  end
52
52
  end
53
53
 
54
54
  context "#name" do
55
55
  it "should return provided text" do
56
- direction.name.should == text
56
+ expect(direction.name).to eq(text)
57
57
  end
58
58
  end
59
59
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::Exporter do
3
+ describe Chouette::Exporter, :type => :model do
4
4
 
5
5
  subject { Chouette::Exporter.new("test") }
6
6
 
@@ -9,16 +9,16 @@ describe Chouette::Exporter do
9
9
  let(:chouette_command) { double :run! => true }
10
10
 
11
11
  before(:each) do
12
- subject.stub :chouette_command => chouette_command
12
+ allow(subject).to receive_messages :chouette_command => chouette_command
13
13
  end
14
14
 
15
15
  it "should use specified file in -outputFile option" do
16
- chouette_command.should_receive(:run!).with(hash_including(:output_file => File.expand_path('file')))
16
+ expect(chouette_command).to receive(:run!).with(hash_including(:output_file => File.expand_path('file')))
17
17
  subject.export "file"
18
18
  end
19
19
 
20
20
  it "should use specified format in -format option" do
21
- chouette_command.should_receive(:run!).with(hash_including(:format => 'DUMMY'))
21
+ expect(chouette_command).to receive(:run!).with(hash_including(:format => 'DUMMY'))
22
22
  subject.export "file", :format => "dummy"
23
23
  end
24
24
 
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::FileValidator do
3
+ describe Chouette::FileValidator, :type => :model do
4
4
 
5
5
  subject { Chouette::FileValidator.new("public") }
6
6
 
7
7
  before(:each) do
8
- subject.stub :execute! => true
8
+ allow(subject).to receive_messages :execute! => true
9
9
  end
10
10
 
11
11
 
@@ -14,11 +14,11 @@ describe Chouette::FileValidator do
14
14
  let(:chouette_command) { double :run! => true }
15
15
 
16
16
  before(:each) do
17
- subject.stub :chouette_command => chouette_command
17
+ allow(subject).to receive_messages :chouette_command => chouette_command
18
18
  end
19
19
 
20
20
  it "should use specified file in -inputFile option" do
21
- chouette_command.should_receive(:run!).with(hash_including(:input_file => File.expand_path('file')))
21
+ expect(chouette_command).to receive(:run!).with(hash_including(:input_file => File.expand_path('file')))
22
22
  subject.validate "file"
23
23
  end
24
24
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Chouette::Footnote do
4
4
 
5
- subject { Factory.build(:footnote) }
5
+ subject { build(:footnote) }
6
6
 
7
7
  it { should validate_presence_of :line }
8
8
 
@@ -1,30 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::GroupOfLine do
3
+ describe Chouette::GroupOfLine, :type => :model do
4
4
 
5
- subject { Factory(:group_of_line) }
5
+ subject { create(:group_of_line) }
6
6
 
7
- it { should validate_presence_of :name }
7
+ it { is_expected.to validate_presence_of :name }
8
8
 
9
9
  # it { should validate_presence_of :objectid }
10
- it { should validate_uniqueness_of :objectid }
10
+ it { is_expected.to validate_uniqueness_of :objectid }
11
11
 
12
12
  describe "#stop_areas" do
13
- let!(:line){Factory(:line, :group_of_lines => [subject])}
14
- let!(:route){Factory(:route, :line => line)}
13
+ let!(:line){create(:line, :group_of_lines => [subject])}
14
+ let!(:route){create(:route, :line => line)}
15
15
  it "should retreive group of line's stop_areas" do
16
- subject.stop_areas.count.should == route.stop_points.count
16
+ expect(subject.stop_areas.count).to eq(route.stop_points.count)
17
17
  end
18
18
  end
19
19
 
20
20
  context "#line_tokens=" do
21
- let!(:line1){Factory(:line)}
22
- let!(:line2){Factory(:line)}
21
+ let!(:line1){create(:line)}
22
+ let!(:line2){create(:line)}
23
23
 
24
24
  it "should return associated line ids" do
25
25
  subject.update_attributes :line_tokens => [line1.id, line2.id].join(',')
26
- subject.lines.should include( line1)
27
- subject.lines.should include( line2)
26
+ expect(subject.lines).to include( line1)
27
+ expect(subject.lines).to include( line2)
28
28
  end
29
29
  end
30
30
 
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::JourneyPattern do
3
+ describe Chouette::JourneyPattern, :type => :model do
4
4
  describe "#stop_point_ids" do
5
5
  context "for a journey_pattern using only route's stop on odd position" do
6
- let!(:journey_pattern){ Factory( :journey_pattern_odd)}
7
- let!(:vehicle_journey){ Factory( :vehicle_journey_odd, :journey_pattern => journey_pattern)}
6
+ let!(:journey_pattern){ create( :journey_pattern_odd)}
7
+ let!(:vehicle_journey){ create( :vehicle_journey_odd, :journey_pattern => journey_pattern)}
8
8
 
9
9
  # workaroud
10
10
  #subject { journey_pattern}
@@ -16,13 +16,14 @@ describe Chouette::JourneyPattern do
16
16
  end
17
17
  it "should remove all vehicle_journey_at_stop" do
18
18
  vjas_stop_ids = Chouette::VehicleJourney.find(vehicle_journey.id).vehicle_journey_at_stops
19
- vjas_stop_ids.count.should == 0
19
+ expect(vjas_stop_ids.count).to eq(0)
20
20
  end
21
21
  it "should keep departure and arrival shortcut up to date to nil" do
22
- subject.arrival_stop_point_id.should be_nil
23
- subject.departure_stop_point_id.should be_nil
22
+ expect(subject.arrival_stop_point_id).to be_nil
23
+ expect(subject.departure_stop_point_id).to be_nil
24
24
  end
25
25
  end
26
+
26
27
  context "when a route's stop has been removed from journey_pattern" do
27
28
  let!(:last_stop_id){ subject.stop_point_ids.last}
28
29
  before(:each) do
@@ -30,16 +31,17 @@ describe Chouette::JourneyPattern do
30
31
  end
31
32
  it "should remove vehicle_journey_at_stop for last stop" do
32
33
  vjas_stop_ids = Chouette::VehicleJourney.find(vehicle_journey.id).vehicle_journey_at_stops.map(&:stop_point_id)
33
- vjas_stop_ids.count.should == subject.stop_point_ids.size
34
- vjas_stop_ids.should_not include( last_stop_id)
34
+ expect(vjas_stop_ids.count).to eq(subject.stop_point_ids.size)
35
+ expect(vjas_stop_ids).not_to include( last_stop_id)
35
36
  end
36
37
  it "should keep departure and arrival shortcut up to date" do
37
38
  ordered = subject.stop_points.sort { |a,b| a.position <=> b.position}
38
39
 
39
- subject.arrival_stop_point_id.should == ordered.last.id
40
- subject.departure_stop_point_id.should == ordered.first.id
40
+ expect(subject.arrival_stop_point_id).to eq(ordered.last.id)
41
+ expect(subject.departure_stop_point_id).to eq(ordered.first.id)
41
42
  end
42
43
  end
44
+
43
45
  context "when a route's stop has been added in journey_pattern" do
44
46
  let!(:new_stop){ subject.route.stop_points[1]}
45
47
  before(:each) do
@@ -47,14 +49,14 @@ describe Chouette::JourneyPattern do
47
49
  end
48
50
  it "should add a new vehicle_journey_at_stop for that stop" do
49
51
  vjas_stop_ids = Chouette::VehicleJourney.find(vehicle_journey.id).vehicle_journey_at_stops.map(&:stop_point_id)
50
- vjas_stop_ids.count.should == subject.stop_point_ids.size
51
- vjas_stop_ids.should include( new_stop.id)
52
+ expect(vjas_stop_ids.count).to eq(subject.stop_point_ids.size)
53
+ expect(vjas_stop_ids).to include( new_stop.id)
52
54
  end
53
55
  it "should keep departure and arrival shortcut up to date" do
54
56
  ordered = subject.stop_points.sort { |a,b| a.position <=> b.position}
55
57
 
56
- subject.arrival_stop_point_id.should == ordered.last.id
57
- subject.departure_stop_point_id.should == ordered.first.id
58
+ expect(subject.arrival_stop_point_id).to eq(ordered.last.id)
59
+ expect(subject.departure_stop_point_id).to eq(ordered.first.id)
58
60
  end
59
61
  end
60
62
  end
@@ -1,48 +1,52 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::Line do
3
+ describe Chouette::Line, :type => :model do
4
4
 
5
- subject { Factory(:line) }
5
+ subject { create(:line) }
6
6
 
7
- it { should validate_presence_of :network }
8
- it { should validate_presence_of :company }
7
+ it { is_expected.to validate_presence_of :network }
8
+ it { is_expected.to validate_presence_of :company }
9
9
 
10
- it { should validate_presence_of :registration_number }
11
- it { should validate_uniqueness_of :registration_number }
12
-
13
- it { should validate_presence_of :name }
10
+ it { is_expected.to validate_presence_of :registration_number }
11
+ it { is_expected.to validate_uniqueness_of :registration_number }
14
12
 
13
+ it { is_expected.to validate_presence_of :name }
14
+
15
15
  # it { should validate_presence_of :objectid }
16
- it { should validate_uniqueness_of :objectid }
17
- its(:objectid) { should be_kind_of(Chouette::ObjectId) }
16
+ it { is_expected.to validate_uniqueness_of :objectid }
17
+
18
+ describe '#objectid' do
19
+ subject { super().objectid }
20
+ it { is_expected.to be_kind_of(Chouette::ObjectId) }
21
+ end
18
22
 
19
23
  # it { should validate_numericality_of :objectversion }
20
24
 
21
25
  describe ".last_stop_areas_parents" do
22
26
 
23
27
  it "should return stop areas if no parents" do
24
- line = Factory(:line_with_stop_areas)
25
- line.stop_areas_last_parents.should == line.stop_areas
28
+ line = create(:line_with_stop_areas)
29
+ expect(line.stop_areas_last_parents).to eq(line.stop_areas)
26
30
  end
27
31
 
28
32
  it "should return stop areas parents if parents" do
29
- line = Factory(:line_with_stop_areas)
30
- route = Factory(:route, :line => line)
31
- parent = Factory(:stop_area)
32
- stop_areas = [ Factory(:stop_area), Factory(:stop_area), Factory(:stop_area, :parent_id => parent.id) ]
33
+ line = create(:line_with_stop_areas)
34
+ route = create(:route, :line => line)
35
+ parent = create(:stop_area)
36
+ stop_areas = [ create(:stop_area), create(:stop_area), create(:stop_area, :parent_id => parent.id) ]
33
37
  stop_areas.each do |stop_area|
34
- Factory(:stop_point, :stop_area => stop_area, :route => route)
35
- end
38
+ create(:stop_point, :stop_area => stop_area, :route => route)
39
+ end
36
40
 
37
- line.stop_areas_last_parents.should =~ line.stop_areas[0..(line.stop_areas.size - 2)].push(parent)
41
+ expect(line.stop_areas_last_parents).to match(line.stop_areas[0..(line.stop_areas.size - 2)].push(parent))
38
42
  end
39
43
 
40
44
  end
41
45
 
42
46
  describe "#stop_areas" do
43
- let!(:route){Factory(:route, :line => subject)}
47
+ let!(:route){create(:route, :line => subject)}
44
48
  it "should retreive route's stop_areas" do
45
- subject.stop_areas.count.should == route.stop_points.count
49
+ expect(subject.stop_areas.count).to eq(route.stop_points.count)
46
50
  end
47
51
  end
48
52
 
@@ -57,14 +61,14 @@ describe Chouette::Line do
57
61
  transport_mode = Chouette::TransportMode.new(transport_mode_name.underscore)
58
62
  it "should be #{transport_mode}" do
59
63
  subject.transport_mode_name = transport_mode_name
60
- subject.transport_mode.should == transport_mode
64
+ expect(subject.transport_mode).to eq(transport_mode)
61
65
  end
62
66
  end
63
67
  end
64
68
  context "when transport_mode_name is nil" do
65
69
  it "should be nil" do
66
70
  subject.transport_mode_name = nil
67
- subject.transport_mode.should be_nil
71
+ expect(subject.transport_mode).to be_nil
68
72
  end
69
73
  end
70
74
 
@@ -74,7 +78,7 @@ describe Chouette::Line do
74
78
 
75
79
  it "should change transport_mode_name with TransportMode#name" do
76
80
  subject.transport_mode = "Test"
77
- subject.transport_mode_name.should == "Test"
81
+ expect(subject.transport_mode_name).to eq("Test")
78
82
  end
79
83
 
80
84
  end
@@ -82,30 +86,30 @@ describe Chouette::Line do
82
86
  describe ".transport_modes" do
83
87
 
84
88
  it "should not include unknown transport_mode" do
85
- Chouette::Line.transport_modes.should_not include(Chouette::TransportMode.new("unknown"))
89
+ expect(Chouette::Line.transport_modes).not_to include(Chouette::TransportMode.new("unknown"))
86
90
  end
87
91
 
88
92
  it "should not include interchange transport_mode" do
89
- Chouette::Line.transport_modes.should_not include(Chouette::TransportMode.new("interchange"))
93
+ expect(Chouette::Line.transport_modes).not_to include(Chouette::TransportMode.new("interchange"))
90
94
  end
91
95
 
92
96
  end
93
97
 
94
98
  context "#group_of_line_tokens=" do
95
- let!(:group_of_line1){Factory(:group_of_line)}
96
- let!(:group_of_line2){Factory(:group_of_line)}
99
+ let!(:group_of_line1){create(:group_of_line)}
100
+ let!(:group_of_line2){create(:group_of_line)}
97
101
 
98
102
  it "should return associated group_of_line ids" do
99
103
  subject.update_attributes :group_of_line_tokens => [group_of_line1.id, group_of_line2.id].join(',')
100
- subject.group_of_lines.should include( group_of_line1)
101
- subject.group_of_lines.should include( group_of_line2)
104
+ expect(subject.group_of_lines).to include( group_of_line1)
105
+ expect(subject.group_of_lines).to include( group_of_line2)
102
106
  end
103
107
  end
104
108
 
105
109
  describe "#update_attributes footnotes_attributes" do
106
110
  context "instanciate 2 footnotes without line" do
107
- let!( :footnote_first) {Factory.build( :footnote, :line_id => nil)}
108
- let!( :footnote_second) {Factory.build( :footnote, :line_id => nil)}
111
+ let!( :footnote_first) {build( :footnote, :line_id => nil)}
112
+ let!( :footnote_second) {build( :footnote, :line_id => nil)}
109
113
  it "should add 2 footnotes to the line" do
110
114
  subject.update_attributes :footnotes_attributes =>
111
115
  { Time.now.to_i => footnote_first.attributes,
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::Loader do
3
+ describe Chouette::Loader, :type => :model do
4
4
 
5
5
  subject { Chouette::Loader.new("test") }
6
6
 
7
7
  before(:each) do
8
- subject.stub :execute! => true
8
+ allow(subject).to receive_messages :execute! => true
9
9
  end
10
10
 
11
11
  describe "#load_dump" do
@@ -17,16 +17,16 @@ describe Chouette::Loader do
17
17
  let(:chouette_command) { double :run! => true }
18
18
 
19
19
  before(:each) do
20
- subject.stub :chouette_command => chouette_command
20
+ allow(subject).to receive_messages :chouette_command => chouette_command
21
21
  end
22
22
 
23
23
  it "should use specified file in -inputFile option" do
24
- chouette_command.should_receive(:run!).with(hash_including(:input_file => File.expand_path('file')))
24
+ expect(chouette_command).to receive(:run!).with(hash_including(:input_file => File.expand_path('file')))
25
25
  subject.import "file"
26
26
  end
27
27
 
28
28
  it "should use specified format in -format option" do
29
- chouette_command.should_receive(:run!).with(hash_including(:format => 'DUMMY'))
29
+ expect(chouette_command).to receive(:run!).with(hash_including(:format => 'DUMMY'))
30
30
  subject.import "file", :format => "dummy"
31
31
  end
32
32
 
@@ -35,7 +35,7 @@ describe Chouette::Loader do
35
35
  describe "#create" do
36
36
 
37
37
  it "should quote schema name" do
38
- subject.should_receive(:execute!).with(/"test"/)
38
+ expect(subject).to receive(:execute!).with(/"test"/)
39
39
  subject.create
40
40
  end
41
41
 
@@ -44,7 +44,7 @@ describe Chouette::Loader do
44
44
  describe "#drop" do
45
45
 
46
46
  it "should quote schema name" do
47
- subject.should_receive(:execute!).with(/"test"/)
47
+ expect(subject).to receive(:execute!).with(/"test"/)
48
48
  subject.drop
49
49
  end
50
50
 
@@ -55,12 +55,12 @@ describe Chouette::Loader do
55
55
  let(:file) { "/dev/null" }
56
56
 
57
57
  it "should call pg_dump" do
58
- subject.should_receive(:execute!).with(/^pg_dump/)
58
+ expect(subject).to receive(:execute!).with(/^pg_dump/)
59
59
  subject.backup file
60
60
  end
61
61
 
62
62
  it "should dump in specified file" do
63
- subject.should_receive(:execute!).with(/-f #{file}/)
63
+ expect(subject).to receive(:execute!).with(/-f #{file}/)
64
64
  subject.backup file
65
65
  end
66
66
  end
@@ -1,22 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chouette::Network do
3
+ describe Chouette::Network, :type => :model do
4
4
 
5
- subject { Factory(:network) }
5
+ subject { create(:network) }
6
6
 
7
- it { should validate_presence_of :registration_number }
8
- it { should validate_uniqueness_of :registration_number }
7
+ it { is_expected.to validate_presence_of :registration_number }
8
+ it { is_expected.to validate_uniqueness_of :registration_number }
9
9
 
10
- it { should validate_presence_of :name }
10
+ it { is_expected.to validate_presence_of :name }
11
11
 
12
12
  # it { should validate_presence_of :objectid }
13
- it { should validate_uniqueness_of :objectid }
13
+ it { is_expected.to validate_uniqueness_of :objectid }
14
14
 
15
15
  describe "#stop_areas" do
16
- let!(:line){Factory(:line, :network => subject)}
17
- let!(:route){Factory(:route, :line => line)}
16
+ let!(:line){create(:line, :network => subject)}
17
+ let!(:route){create(:route, :line => line)}
18
18
  it "should retreive route's stop_areas" do
19
- subject.stop_areas.count.should == route.stop_points.count
19
+ expect(subject.stop_areas.count).to eq(route.stop_points.count)
20
20
  end
21
21
  end
22
22
  end