ninoxe 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/db/migrate/20130710122648_set_accessibiliity_to_existing_stop_area.rb +4 -9
- data/lib/ninoxe/version.rb +1 -1
- metadata +87 -201
- data/app/models/chouette/mobility_need.rb +0 -4
- data/app/models/chouette/suitability.rb +0 -5
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -56
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -9
- data/spec/dummy/config/environment.rb +0 -7
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/active_record.rb +0 -2
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/models/chouette/access_link_spec.rb +0 -78
- data/spec/models/chouette/access_point_spec.rb +0 -193
- data/spec/models/chouette/active_record_spec.rb +0 -121
- data/spec/models/chouette/area_type_spec.rb +0 -53
- data/spec/models/chouette/company_spec.rb +0 -51
- data/spec/models/chouette/connection_link_spec.rb +0 -56
- data/spec/models/chouette/direction_spec.rb +0 -60
- data/spec/models/chouette/exporter_spec.rb +0 -28
- data/spec/models/chouette/file_validator_spec.rb +0 -28
- data/spec/models/chouette/group_of_line_spec.rb +0 -31
- data/spec/models/chouette/journey_pattern_spec.rb +0 -62
- data/spec/models/chouette/line_spec.rb +0 -106
- data/spec/models/chouette/loader_spec.rb +0 -69
- data/spec/models/chouette/network_spec.rb +0 -22
- data/spec/models/chouette/object_id_spec.rb +0 -146
- data/spec/models/chouette/route_spec.rb +0 -159
- data/spec/models/chouette/stop_area_spec.rb +0 -354
- data/spec/models/chouette/stop_point_spec.rb +0 -39
- data/spec/models/chouette/time_table_spec.rb +0 -372
- data/spec/models/chouette/transport_mode_spec.rb +0 -64
- data/spec/models/chouette/vehicle_journey_at_stop_spec.rb +0 -46
- data/spec/models/chouette/vehicle_journey_spec.rb +0 -204
- data/spec/presenters/chouette/geometry/general_presenter.rb +0 -1
- data/spec/presenters/chouette/geometry/line_presenter_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -45
| @@ -1,372 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Chouette::TimeTable do
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              subject { Factory(:time_table) }
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              it { should validate_presence_of :comment }
         | 
| 8 | 
            -
              it { should validate_uniqueness_of :objectid }
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              describe "#periods_max_date" do
         | 
| 11 | 
            -
                context "when all period extends from 04/10/2013 to 04/15/2013," do
         | 
| 12 | 
            -
                  before(:each) do
         | 
| 13 | 
            -
                    p1 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/10/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/12/2013", '%m/%d/%Y'))
         | 
| 14 | 
            -
                    p2 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/13/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/15/2013", '%m/%d/%Y'))
         | 
| 15 | 
            -
                    subject.periods = [ p1, p2]
         | 
| 16 | 
            -
                    subject.save
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  it "should retreive 04/15/2013" do
         | 
| 20 | 
            -
                    subject.periods_max_date.should == Date.strptime("04/15/2013", '%m/%d/%Y')
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                  context "when day_types select only sunday and saturday," do
         | 
| 23 | 
            -
                    before(:each) do
         | 
| 24 | 
            -
                      # jeudi, vendredi
         | 
| 25 | 
            -
                      subject.update_attributes( :int_day_types => (2**(1+6) + 2**(1+7)))
         | 
| 26 | 
            -
                    end
         | 
| 27 | 
            -
                    it "should retreive 04/14/2013" do
         | 
| 28 | 
            -
                      subject.periods_max_date.should == Date.strptime("04/14/2013", '%m/%d/%Y')
         | 
| 29 | 
            -
                    end
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
                  context "when day_types select only friday," do
         | 
| 32 | 
            -
                    before(:each) do
         | 
| 33 | 
            -
                      # jeudi, vendredi
         | 
| 34 | 
            -
                      subject.update_attributes( :int_day_types => (2**(1+6)))
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                    it "should retreive 04/12/2013" do
         | 
| 37 | 
            -
                      subject.periods_max_date.should == Date.strptime("04/13/2013", '%m/%d/%Y')
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
                  end
         | 
| 40 | 
            -
                  context "when day_types select only thursday," do
         | 
| 41 | 
            -
                    before(:each) do
         | 
| 42 | 
            -
                      # mardi
         | 
| 43 | 
            -
                      subject.update_attributes( :int_day_types => (2**(1+2)))
         | 
| 44 | 
            -
                    end
         | 
| 45 | 
            -
                    it "should retreive 04/12/2013" do
         | 
| 46 | 
            -
                      # 04/15/2013 is monday !
         | 
| 47 | 
            -
                      subject.periods_max_date.should be_nil
         | 
| 48 | 
            -
                    end
         | 
| 49 | 
            -
                  end
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
              end
         | 
| 52 | 
            -
              describe "#periods_min_date" do
         | 
| 53 | 
            -
                context "when all period extends from 04/10/2013 to 04/15/2013," do
         | 
| 54 | 
            -
                  before(:each) do
         | 
| 55 | 
            -
                    p1 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/10/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/12/2013", '%m/%d/%Y'))
         | 
| 56 | 
            -
                    p2 = Chouette::TimeTablePeriod.new( :period_start => Date.strptime("04/13/2013", '%m/%d/%Y'), :period_end => Date.strptime("04/15/2013", '%m/%d/%Y'))
         | 
| 57 | 
            -
                    subject.periods = [ p1, p2]
         | 
| 58 | 
            -
                    subject.save
         | 
| 59 | 
            -
                  end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  it "should retreive 04/10/2013" do
         | 
| 62 | 
            -
                    subject.periods_min_date.should == Date.strptime("04/10/2013", '%m/%d/%Y')
         | 
| 63 | 
            -
                  end
         | 
| 64 | 
            -
                  context "when day_types select only tuesday and friday," do
         | 
| 65 | 
            -
                    before(:each) do
         | 
| 66 | 
            -
                      # jeudi, vendredi
         | 
| 67 | 
            -
                      subject.update_attributes( :int_day_types => (2**(1+4) + 2**(1+5)))
         | 
| 68 | 
            -
                    end
         | 
| 69 | 
            -
                    it "should retreive 04/11/2013" do
         | 
| 70 | 
            -
                      subject.periods_min_date.should == Date.strptime("04/11/2013", '%m/%d/%Y')
         | 
| 71 | 
            -
                    end
         | 
| 72 | 
            -
                  end
         | 
| 73 | 
            -
                  context "when day_types select only friday," do
         | 
| 74 | 
            -
                    before(:each) do
         | 
| 75 | 
            -
                      # jeudi, vendredi
         | 
| 76 | 
            -
                      subject.update_attributes( :int_day_types => (2**(1+5)))
         | 
| 77 | 
            -
                    end
         | 
| 78 | 
            -
                    it "should retreive 04/12/2013" do
         | 
| 79 | 
            -
                      subject.periods_min_date.should == Date.strptime("04/12/2013", '%m/%d/%Y')
         | 
| 80 | 
            -
                    end
         | 
| 81 | 
            -
                  end
         | 
| 82 | 
            -
                  context "when day_types select only thursday," do
         | 
| 83 | 
            -
                    before(:each) do
         | 
| 84 | 
            -
                      # mardi
         | 
| 85 | 
            -
                      subject.update_attributes( :int_day_types => (2**(1+2)))
         | 
| 86 | 
            -
                    end
         | 
| 87 | 
            -
                    it "should retreive 04/12/2013" do
         | 
| 88 | 
            -
                      # 04/15/2013 is monday !
         | 
| 89 | 
            -
                      subject.periods_min_date.should be_nil
         | 
| 90 | 
            -
                    end
         | 
| 91 | 
            -
                  end
         | 
| 92 | 
            -
                end
         | 
| 93 | 
            -
              end
         | 
| 94 | 
            -
              describe "#periods.build" do
         | 
| 95 | 
            -
                it "should add a new instance of period, and periods_max_date should not raise error" do
         | 
| 96 | 
            -
                  period = subject.periods.build
         | 
| 97 | 
            -
                  subject.periods_max_date
         | 
| 98 | 
            -
                  period.period_start.should be_nil
         | 
| 99 | 
            -
                  period.period_end.should be_nil
         | 
| 100 | 
            -
                end
         | 
| 101 | 
            -
              end
         | 
| 102 | 
            -
              describe "#periods" do
         | 
| 103 | 
            -
                context "when a period is added," do
         | 
| 104 | 
            -
                  before(:each) do
         | 
| 105 | 
            -
                    subject.periods << Chouette::TimeTablePeriod.new( :period_start => (subject.bounding_dates.min - 1), :period_end => (subject.bounding_dates.max + 1))
         | 
| 106 | 
            -
                    subject.save
         | 
| 107 | 
            -
                  end
         | 
| 108 | 
            -
                  it "should update shortcut" do
         | 
| 109 | 
            -
                    subject.start_date.should == subject.bounding_dates.min
         | 
| 110 | 
            -
                    subject.end_date.should == subject.bounding_dates.max
         | 
| 111 | 
            -
                  end
         | 
| 112 | 
            -
                end
         | 
| 113 | 
            -
                context "when a period is removed," do
         | 
| 114 | 
            -
                  before(:each) do
         | 
| 115 | 
            -
                    subject.dates = []
         | 
| 116 | 
            -
                    subject.periods = []
         | 
| 117 | 
            -
                    subject.periods << Chouette::TimeTablePeriod.new( 
         | 
| 118 | 
            -
                                          :period_start => 4.days.since.to_date, 
         | 
| 119 | 
            -
                                          :period_end => 6.days.since.to_date)
         | 
| 120 | 
            -
                    subject.periods << Chouette::TimeTablePeriod.new( 
         | 
| 121 | 
            -
                                          :period_start => 1.days.since.to_date, 
         | 
| 122 | 
            -
                                          :period_end => 10.days.since.to_date)
         | 
| 123 | 
            -
                    subject.save
         | 
| 124 | 
            -
                    subject.periods = subject.periods - [subject.periods.last]
         | 
| 125 | 
            -
                  end
         | 
| 126 | 
            -
                  def read_tm
         | 
| 127 | 
            -
                    Chouette::TimeTable.find subject.id
         | 
| 128 | 
            -
                  end
         | 
| 129 | 
            -
                  it "should update shortcut" do
         | 
| 130 | 
            -
                    tm = read_tm
         | 
| 131 | 
            -
                    subject.start_date.should == subject.bounding_dates.min
         | 
| 132 | 
            -
                    subject.start_date.should == tm.bounding_dates.min
         | 
| 133 | 
            -
                    subject.start_date.should == 4.days.since.to_date
         | 
| 134 | 
            -
                    subject.end_date.should == subject.bounding_dates.max
         | 
| 135 | 
            -
                    subject.end_date.should == tm.bounding_dates.max
         | 
| 136 | 
            -
                    subject.end_date.should == 6.days.since.to_date
         | 
| 137 | 
            -
                  end
         | 
| 138 | 
            -
                end
         | 
| 139 | 
            -
              end
         | 
| 140 | 
            -
              describe "#dates" do
         | 
| 141 | 
            -
                context "when a date is added," do
         | 
| 142 | 
            -
                  before(:each) do
         | 
| 143 | 
            -
                    subject.dates << Chouette::TimeTableDate.new( :date => (subject.bounding_dates.max + 1))
         | 
| 144 | 
            -
                    subject.save
         | 
| 145 | 
            -
                  end
         | 
| 146 | 
            -
                  it "should update shortcut" do
         | 
| 147 | 
            -
                    subject.start_date.should == subject.bounding_dates.min
         | 
| 148 | 
            -
                    subject.end_date.should == subject.bounding_dates.max
         | 
| 149 | 
            -
                  end
         | 
| 150 | 
            -
                end
         | 
| 151 | 
            -
                context "when a date is removed," do
         | 
| 152 | 
            -
                  before(:each) do
         | 
| 153 | 
            -
                    subject.periods = []
         | 
| 154 | 
            -
                    subject.dates = subject.dates - [subject.bounding_dates.max + 1]
         | 
| 155 | 
            -
                  end
         | 
| 156 | 
            -
                  it "should update shortcut" do
         | 
| 157 | 
            -
                    subject.start_date.should == subject.bounding_dates.min
         | 
| 158 | 
            -
                    subject.end_date.should == subject.bounding_dates.max
         | 
| 159 | 
            -
                  end
         | 
| 160 | 
            -
                end
         | 
| 161 | 
            -
                context "when all the dates and periods are removed," do
         | 
| 162 | 
            -
                  before(:each) do
         | 
| 163 | 
            -
                    subject.periods = []
         | 
| 164 | 
            -
                    subject.dates = []
         | 
| 165 | 
            -
                  end
         | 
| 166 | 
            -
                  it "should update shortcut" do
         | 
| 167 | 
            -
                    subject.start_date.should be_nil
         | 
| 168 | 
            -
                    subject.end_date.should be_nil
         | 
| 169 | 
            -
                  end
         | 
| 170 | 
            -
                end
         | 
| 171 | 
            -
              end
         | 
| 172 | 
            -
             | 
| 173 | 
            -
              describe "#valid_days" do
         | 
| 174 | 
            -
                it "should begin with position 0" do
         | 
| 175 | 
            -
                  subject.int_day_types = 128
         | 
| 176 | 
            -
                  subject.valid_days.should == [6]
         | 
| 177 | 
            -
                end
         | 
| 178 | 
            -
              end
         | 
| 179 | 
            -
             | 
| 180 | 
            -
              describe "#intersects" do
         | 
| 181 | 
            -
                it "should return day if a date equal day" do
         | 
| 182 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
         | 
| 183 | 
            -
                  time_table_date = Factory(:time_table_date, :date => Date.today, :time_table_id => time_table.id)
         | 
| 184 | 
            -
                  time_table.intersects([Date.today]).should == [Date.today]
         | 
| 185 | 
            -
                end
         | 
| 186 | 
            -
             | 
| 187 | 
            -
                it "should return [] if a period not include days" do
         | 
| 188 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12)
         | 
| 189 | 
            -
                  time_table_period = Factory(:time_table_period, :period_start => Date.new(2013, 05, 27),:period_end =>  Date.new(2013, 05, 30), :time_table_id => time_table.id)
         | 
| 190 | 
            -
                  time_table.intersects([ Date.new(2013, 05, 29),  Date.new(2013, 05, 30)]).should == []
         | 
| 191 | 
            -
                end
         | 
| 192 | 
            -
             | 
| 193 | 
            -
                it "should return days if a period include day" do
         | 
| 194 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12) # Day type monday and tuesday
         | 
| 195 | 
            -
                  time_table_period = Factory(:time_table_period, :period_start => Date.new(2013, 05, 27),:period_end =>  Date.new(2013, 05, 30), :time_table_id => time_table.id)
         | 
| 196 | 
            -
                  time_table.intersects([ Date.new(2013, 05, 27),  Date.new(2013, 05, 28)]).should == [ Date.new(2013, 05, 27),  Date.new(2013, 05, 28)]
         | 
| 197 | 
            -
                end
         | 
| 198 | 
            -
             | 
| 199 | 
            -
                
         | 
| 200 | 
            -
              end
         | 
| 201 | 
            -
             | 
| 202 | 
            -
              describe "#include_day?" do
         | 
| 203 | 
            -
                it "should return true if a date equal day" do
         | 
| 204 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
         | 
| 205 | 
            -
                  time_table_date = Factory(:time_table_date, :date => Date.today, :time_table_id => time_table.id)
         | 
| 206 | 
            -
                  time_table.include_day?(Date.today).should == true
         | 
| 207 | 
            -
                end
         | 
| 208 | 
            -
             | 
| 209 | 
            -
                it "should return true if a period include day" do
         | 
| 210 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 12) # Day type monday and tuesday
         | 
| 211 | 
            -
                  time_table_period = Factory(:time_table_period, :period_start => Date.new(2013, 05, 27),:period_end =>  Date.new(2013, 05, 29), :time_table_id => time_table.id)
         | 
| 212 | 
            -
                  time_table.include_day?( Date.new(2013, 05, 27)).should == true
         | 
| 213 | 
            -
                end
         | 
| 214 | 
            -
              end
         | 
| 215 | 
            -
             | 
| 216 | 
            -
              describe "#include_in_dates?" do
         | 
| 217 | 
            -
                it "should return true if a date equal day" do
         | 
| 218 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1")
         | 
| 219 | 
            -
                  time_table_date = Factory(:time_table_date, :date => Date.today, :time_table_id => time_table.id)
         | 
| 220 | 
            -
                  time_table.include_in_dates?(Date.today).should == true
         | 
| 221 | 
            -
                end
         | 
| 222 | 
            -
              end
         | 
| 223 | 
            -
              
         | 
| 224 | 
            -
              describe "#include_in_periods?" do
         | 
| 225 | 
            -
                it "should return true if a period include day" do
         | 
| 226 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 4)
         | 
| 227 | 
            -
                  time_table_period = Factory(:time_table_period, :period_start => Date.new(2012, 1, 1),:period_end => Date.new(2012, 01, 30), :time_table_id => time_table.id)
         | 
| 228 | 
            -
                  time_table.include_in_periods?(Date.new(2012, 1, 2)).should == true
         | 
| 229 | 
            -
                end
         | 
| 230 | 
            -
              end
         | 
| 231 | 
            -
             | 
| 232 | 
            -
              describe "#include_in_overlap_dates?" do
         | 
| 233 | 
            -
                it "should return true if a day is included in overlap dates" do
         | 
| 234 | 
            -
                  time_table = Chouette::TimeTable.create!(:comment => "Test", :objectid => "test:Timetable:1", :int_day_types => 4)
         | 
| 235 | 
            -
                  time_table_period = Factory(:time_table_period, :period_start => Date.new(2012, 1, 1),:period_end => Date.new(2012, 01, 30), :time_table_id => time_table.id)
         | 
| 236 | 
            -
                  time_table_date = Factory(:time_table_date, :date => Date.new(2012, 1, 2), :time_table_id => time_table.id)
         | 
| 237 | 
            -
                  time_table.include_in_overlap_dates?(Date.new(2012, 1, 2)).should == true      
         | 
| 238 | 
            -
                end
         | 
| 239 | 
            -
              end
         | 
| 240 | 
            -
             | 
| 241 | 
            -
              describe "#dates" do
         | 
| 242 | 
            -
                it "should have with position 0" do
         | 
| 243 | 
            -
                  subject.dates.first.position.should == 0
         | 
| 244 | 
            -
                end
         | 
| 245 | 
            -
                context "when first date has been removed" do
         | 
| 246 | 
            -
                  before do
         | 
| 247 | 
            -
                    subject.dates.first.destroy
         | 
| 248 | 
            -
                  end
         | 
| 249 | 
            -
                  it "should begin with position 0" do
         | 
| 250 | 
            -
                    subject.dates.first.position.should == 0
         | 
| 251 | 
            -
                  end
         | 
| 252 | 
            -
                end
         | 
| 253 | 
            -
              end
         | 
| 254 | 
            -
              describe "#validity_out_between?" do
         | 
| 255 | 
            -
                let(:empty_tm) {Factory.build(:time_table)}
         | 
| 256 | 
            -
                it "should be false if empty calendar" do
         | 
| 257 | 
            -
                  empty_tm.validity_out_between?( Date.today, Date.today + 7.day).should be_false
         | 
| 258 | 
            -
                end
         | 
| 259 | 
            -
                it "should be true if caldendar is out during start_date and end_date period" do
         | 
| 260 | 
            -
                  start_date = subject.bounding_dates.max - 2.day
         | 
| 261 | 
            -
                  end_date = subject.bounding_dates.max + 2.day
         | 
| 262 | 
            -
                  subject.validity_out_between?( start_date, end_date).should be_true
         | 
| 263 | 
            -
                end
         | 
| 264 | 
            -
                it "should be false if calendar is out on start date" do
         | 
| 265 | 
            -
                  start_date = subject.bounding_dates.max 
         | 
| 266 | 
            -
                  end_date = subject.bounding_dates.max + 2.day
         | 
| 267 | 
            -
                  subject.validity_out_between?( start_date, end_date).should be_false
         | 
| 268 | 
            -
                end
         | 
| 269 | 
            -
                it "should be false if calendar is out on end date" do
         | 
| 270 | 
            -
                  start_date = subject.bounding_dates.max - 2.day
         | 
| 271 | 
            -
                  end_date = subject.bounding_dates.max 
         | 
| 272 | 
            -
                  subject.validity_out_between?( start_date, end_date).should be_true
         | 
| 273 | 
            -
                end
         | 
| 274 | 
            -
                it "should be false if calendar is out after start_date" do
         | 
| 275 | 
            -
                  start_date = subject.bounding_dates.max + 2.day
         | 
| 276 | 
            -
                  end_date = subject.bounding_dates.max + 4.day
         | 
| 277 | 
            -
                  subject.validity_out_between?( start_date, end_date).should be_false
         | 
| 278 | 
            -
                end
         | 
| 279 | 
            -
              end
         | 
| 280 | 
            -
              describe "#validity_out_from_on?" do
         | 
| 281 | 
            -
                let(:empty_tm) {Factory.build(:time_table)}
         | 
| 282 | 
            -
                it "should be false if empty calendar" do
         | 
| 283 | 
            -
                  empty_tm.validity_out_from_on?( Date.today).should be_false
         | 
| 284 | 
            -
                end
         | 
| 285 | 
            -
                it "should be true if caldendar ends on expected date" do
         | 
| 286 | 
            -
                  expected_date = subject.bounding_dates.max
         | 
| 287 | 
            -
                  subject.validity_out_from_on?( expected_date).should be_true
         | 
| 288 | 
            -
                end
         | 
| 289 | 
            -
                it "should be true if calendar ends before expected date" do
         | 
| 290 | 
            -
                  expected_date = subject.bounding_dates.max + 30.day
         | 
| 291 | 
            -
                  subject.validity_out_from_on?( expected_date).should be_true
         | 
| 292 | 
            -
                end
         | 
| 293 | 
            -
                it "should be false if calendars ends after expected date" do
         | 
| 294 | 
            -
                  expected_date = subject.bounding_dates.max - 30.day
         | 
| 295 | 
            -
                  subject.validity_out_from_on?( expected_date).should be_false
         | 
| 296 | 
            -
                end
         | 
| 297 | 
            -
              end
         | 
| 298 | 
            -
              describe "#bounding_dates" do
         | 
| 299 | 
            -
                context "when timetable contains only periods" do
         | 
| 300 | 
            -
                  before do
         | 
| 301 | 
            -
                    subject.dates = []
         | 
| 302 | 
            -
                    subject.save
         | 
| 303 | 
            -
                  end
         | 
| 304 | 
            -
                  it "should retreive periods.period_start.min and periods.period_end.max" do
         | 
| 305 | 
            -
                    subject.bounding_dates.min.should == subject.periods.map(&:period_start).min
         | 
| 306 | 
            -
                    subject.bounding_dates.max.should == subject.periods.map(&:period_end).max
         | 
| 307 | 
            -
                  end
         | 
| 308 | 
            -
                end
         | 
| 309 | 
            -
                context "when timetable contains only dates" do
         | 
| 310 | 
            -
                  before do
         | 
| 311 | 
            -
                    subject.periods = []
         | 
| 312 | 
            -
                    subject.save
         | 
| 313 | 
            -
                  end
         | 
| 314 | 
            -
                  it "should retreive dates.min and dates.max" do
         | 
| 315 | 
            -
                    subject.bounding_dates.min.should == subject.dates.map(&:date).min
         | 
| 316 | 
            -
                    subject.bounding_dates.max.should == subject.dates.map(&:date).max
         | 
| 317 | 
            -
                  end
         | 
| 318 | 
            -
                end
         | 
| 319 | 
            -
                it "should contains min date" do
         | 
| 320 | 
            -
                  min_date = subject.bounding_dates.min
         | 
| 321 | 
            -
                  subject.dates.each do |tm_date|
         | 
| 322 | 
            -
                    (min_date <= tm_date.date).should be_true
         | 
| 323 | 
            -
                  end
         | 
| 324 | 
            -
                  subject.periods.each do |tm_period|
         | 
| 325 | 
            -
                    (min_date <= tm_period.period_start).should be_true
         | 
| 326 | 
            -
                  end
         | 
| 327 | 
            -
             | 
| 328 | 
            -
                end
         | 
| 329 | 
            -
                it "should contains max date" do
         | 
| 330 | 
            -
                  max_date = subject.bounding_dates.max
         | 
| 331 | 
            -
                  subject.dates.each do |tm_date|
         | 
| 332 | 
            -
                    (tm_date.date <= max_date).should be_true
         | 
| 333 | 
            -
                  end
         | 
| 334 | 
            -
                  subject.periods.each do |tm_period|
         | 
| 335 | 
            -
                    (tm_period.period_end <= max_date).should be_true
         | 
| 336 | 
            -
                  end
         | 
| 337 | 
            -
             | 
| 338 | 
            -
                end
         | 
| 339 | 
            -
              end
         | 
| 340 | 
            -
              describe "#periods" do
         | 
| 341 | 
            -
                it "should begin with position 0" do
         | 
| 342 | 
            -
                  subject.periods.first.position.should == 0
         | 
| 343 | 
            -
                end
         | 
| 344 | 
            -
                context "when first period has been removed" do
         | 
| 345 | 
            -
                  before do
         | 
| 346 | 
            -
                    subject.periods.first.destroy
         | 
| 347 | 
            -
                  end
         | 
| 348 | 
            -
                  it "should begin with position 0" do
         | 
| 349 | 
            -
                    subject.periods.first.position.should == 0
         | 
| 350 | 
            -
                  end
         | 
| 351 | 
            -
                end
         | 
| 352 | 
            -
                it "should have period_start before period_end" do
         | 
| 353 | 
            -
                  period = Chouette::TimeTablePeriod.new
         | 
| 354 | 
            -
                  period.period_start = Date.today
         | 
| 355 | 
            -
                  period.period_end = Date.today + 10
         | 
| 356 | 
            -
                  period.valid?.should be_true
         | 
| 357 | 
            -
                end  
         | 
| 358 | 
            -
                it "should not have period_start after period_end" do
         | 
| 359 | 
            -
                  period = Chouette::TimeTablePeriod.new
         | 
| 360 | 
            -
                  period.period_start = Date.today
         | 
| 361 | 
            -
                  period.period_end = Date.today - 10
         | 
| 362 | 
            -
                  period.valid?.should be_false
         | 
| 363 | 
            -
                end  
         | 
| 364 | 
            -
                it "should not have period_start equal to period_end" do
         | 
| 365 | 
            -
                  period = Chouette::TimeTablePeriod.new
         | 
| 366 | 
            -
                  period.period_start = Date.today
         | 
| 367 | 
            -
                  period.period_end = Date.today
         | 
| 368 | 
            -
                  period.valid?.should be_false
         | 
| 369 | 
            -
                end  
         | 
| 370 | 
            -
              end
         | 
| 371 | 
            -
             | 
| 372 | 
            -
            end
         | 
| @@ -1,64 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Chouette::TransportMode do
         | 
| 4 | 
            -
              
         | 
| 5 | 
            -
              def mode(text_code = "test", numerical_code = nil)
         | 
| 6 | 
            -
                numerical_code ||= 1 if text_code == "test"
         | 
| 7 | 
            -
                Chouette::TransportMode.new(text_code, numerical_code)
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              describe "#to_i" do
         | 
| 11 | 
            -
                
         | 
| 12 | 
            -
                it "should return numerical code" do
         | 
| 13 | 
            -
                  mode("test", 1).to_i.should == 1
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              it "should return true to #test? when text code is 'test'" do
         | 
| 19 | 
            -
                mode("test").should be_test
         | 
| 20 | 
            -
              end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              it "should be equal when text codes are identical" do
         | 
| 23 | 
            -
                mode("test",1).should == mode("test", 2)
         | 
| 24 | 
            -
              end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
              describe ".new" do
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                it "should find numerical code from text code" do
         | 
| 29 | 
            -
                  mode("unknown").to_i.should == 0
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                it "should find text code from numerical code" do
         | 
| 33 | 
            -
                  mode(0).should be_unknown
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                it "should accept another mode" do
         | 
| 37 | 
            -
                  Chouette::TransportMode.new(mode("test")).should == mode("test")
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
                
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              describe "#public_transport?" do
         | 
| 43 | 
            -
                
         | 
| 44 | 
            -
                it "should return false for interchange" do
         | 
| 45 | 
            -
                  mode("interchange").should_not be_public_transport
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                it "should return true for other modes" do
         | 
| 49 | 
            -
                  mode("unknown").should be_public_transport
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
              end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
              describe ".all" do
         | 
| 55 | 
            -
                
         | 
| 56 | 
            -
                Chouette::TransportMode.definitions.each do |text_code, numerical_code|
         | 
| 57 | 
            -
                  it "should include a TransportMode #{text_code}" do
         | 
| 58 | 
            -
                    Chouette::TransportMode.all.should include(Chouette::TransportMode.new(text_code))
         | 
| 59 | 
            -
                  end
         | 
| 60 | 
            -
                end
         | 
| 61 | 
            -
             | 
| 62 | 
            -
              end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
            end
         | 
| @@ -1,46 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Chouette::VehicleJourneyAtStop do
         | 
| 4 | 
            -
              let!(:vehicle_journey){ Factory(:vehicle_journey_odd)}
         | 
| 5 | 
            -
              subject { vehicle_journey.vehicle_journey_at_stops.first }
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              describe "#exceeds_gap?" do
         | 
| 8 | 
            -
                it "should return false if gap < 1.hour" do
         | 
| 9 | 
            -
                  t1 = 1.minutes.ago
         | 
| 10 | 
            -
                  t2 = 1.minutes.ago + 3.hour
         | 
| 11 | 
            -
                  subject.exceeds_gap?(t1, t2).should be_true
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
                it "should return false if gap > 2.hour" do
         | 
| 14 | 
            -
                  t1 = 1.minutes.ago
         | 
| 15 | 
            -
                  t2 = 1.minutes.ago + 3.minutes
         | 
| 16 | 
            -
                  subject.exceeds_gap?(t1, t2).should be_false
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              describe "#increasing_times_validate" do
         | 
| 21 | 
            -
                let(:vjas1){ vehicle_journey.vehicle_journey_at_stops[0]}
         | 
| 22 | 
            -
                let(:vjas2){ vehicle_journey.vehicle_journey_at_stops[1]}
         | 
| 23 | 
            -
                context "when vjas#arrival_time exceeds gap" do
         | 
| 24 | 
            -
                  it "should add errors on arrival_time" do
         | 
| 25 | 
            -
                    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
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
                context "when vjas#departure_time exceeds gap" do
         | 
| 32 | 
            -
                  it "should add errors on departure_time" do
         | 
| 33 | 
            -
                    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
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
                context "when vjas does'nt exceed gap" do
         | 
| 40 | 
            -
                  it "should not add errors" do
         | 
| 41 | 
            -
                    vjas2.increasing_times_validate(vjas1).should be_true
         | 
| 42 | 
            -
                    vjas2.errors.should be_empty
         | 
| 43 | 
            -
                  end
         | 
| 44 | 
            -
                end
         | 
| 45 | 
            -
              end
         | 
| 46 | 
            -
            end 
         | 
| @@ -1,204 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Chouette::VehicleJourney do
         | 
| 4 | 
            -
              subject { Factory(:vehicle_journey_odd) }
         | 
| 5 | 
            -
             | 
| 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)}
         | 
| 11 | 
            -
             | 
| 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)}
         | 
| 14 | 
            -
                  describe "#extra_stops_in_relation_to_a_journey_pattern" do
         | 
| 15 | 
            -
                    it "should be empty" do
         | 
| 16 | 
            -
                      subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern).should be_empty
         | 
| 17 | 
            -
                    end
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                  describe "#extra_vjas_in_relation_to_a_journey_pattern" do
         | 
| 20 | 
            -
                    it "should be empty" do
         | 
| 21 | 
            -
                      subject.extra_vjas_in_relation_to_a_journey_pattern( journey_pattern).should be_empty
         | 
| 22 | 
            -
                    end
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                  describe "#missing_stops_in_relation_to_a_journey_pattern" do
         | 
| 25 | 
            -
                    it "should return even stops" do
         | 
| 26 | 
            -
                      result = subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern)
         | 
| 27 | 
            -
                      result.should == journey_pattern_even.stop_points
         | 
| 28 | 
            -
                    end
         | 
| 29 | 
            -
                  end
         | 
| 30 | 
            -
                  describe "#update_journey_pattern" do
         | 
| 31 | 
            -
                    it "should new_record for added vjas" do
         | 
| 32 | 
            -
                      subject.update_journey_pattern( journey_pattern)
         | 
| 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)
         | 
| 35 | 
            -
                      end
         | 
| 36 | 
            -
                    end
         | 
| 37 | 
            -
                    it "should add vjas on each even stops" do
         | 
| 38 | 
            -
                      subject.update_journey_pattern( journey_pattern)
         | 
| 39 | 
            -
                      vehicle_stops = subject.vehicle_journey_at_stops.map(&:stop_point)
         | 
| 40 | 
            -
                      journey_pattern_even.stop_points.each do |sp|
         | 
| 41 | 
            -
                        vehicle_stops.should include(sp)
         | 
| 42 | 
            -
                      end
         | 
| 43 | 
            -
                    end
         | 
| 44 | 
            -
                    it "should not mark any vjas as _destroy" do
         | 
| 45 | 
            -
                      subject.update_journey_pattern( journey_pattern)
         | 
| 46 | 
            -
                      subject.vehicle_journey_at_stops.any?{ |vjas| vjas._destroy }.should be_false
         | 
| 47 | 
            -
                    end
         | 
| 48 | 
            -
                  end
         | 
| 49 | 
            -
                end
         | 
| 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)}
         | 
| 52 | 
            -
                  describe "#missing_stops_in_relation_to_a_journey_pattern" do
         | 
| 53 | 
            -
                    it "should be empty" do
         | 
| 54 | 
            -
                      subject.missing_stops_in_relation_to_a_journey_pattern( journey_pattern_odd).should be_empty
         | 
| 55 | 
            -
                    end
         | 
| 56 | 
            -
                  end
         | 
| 57 | 
            -
                  describe "#extra_stops_in_relation_to_a_journey_pattern" do
         | 
| 58 | 
            -
                    it "should return even stops" do
         | 
| 59 | 
            -
                      result = subject.extra_stops_in_relation_to_a_journey_pattern( journey_pattern_odd)
         | 
| 60 | 
            -
                      result.should == journey_pattern_even.stop_points
         | 
| 61 | 
            -
                    end
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
                  describe "#extra_vjas_in_relation_to_a_journey_pattern" do
         | 
| 64 | 
            -
                    it "should return vjas on even stops" do
         | 
| 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
         | 
| 67 | 
            -
                    end
         | 
| 68 | 
            -
                  end
         | 
| 69 | 
            -
                  describe "#update_journey_pattern" do
         | 
| 70 | 
            -
                    it "should add no new vjas" do
         | 
| 71 | 
            -
                      subject.update_journey_pattern( journey_pattern_odd)
         | 
| 72 | 
            -
                      subject.vehicle_journey_at_stops.any?{ |vjas| vjas.new_record? }.should be_false
         | 
| 73 | 
            -
                    end
         | 
| 74 | 
            -
                    it "should mark vehicle_journey_at_stops as _destroy on even stops" do
         | 
| 75 | 
            -
                      subject.update_journey_pattern( journey_pattern_odd)
         | 
| 76 | 
            -
                      subject.vehicle_journey_at_stops.each { |vjas| 
         | 
| 77 | 
            -
                        vjas._destroy.should == journey_pattern_even.stop_points.include?(vjas.stop_point) 
         | 
| 78 | 
            -
                      }
         | 
| 79 | 
            -
                    end
         | 
| 80 | 
            -
                  end
         | 
| 81 | 
            -
                end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
              end
         | 
| 84 | 
            -
              context "when following departure times exceeds gap" do
         | 
| 85 | 
            -
                describe "#increasing_times" do
         | 
| 86 | 
            -
                  before(:each) do
         | 
| 87 | 
            -
                    subject.vehicle_journey_at_stops[0].departure_time = subject.vehicle_journey_at_stops[1].departure_time - 2.hour
         | 
| 88 | 
            -
                    subject.vehicle_journey_at_stops[0].arrival_time = subject.vehicle_journey_at_stops[0].departure_time
         | 
| 89 | 
            -
                    subject.vehicle_journey_at_stops[1].arrival_time = subject.vehicle_journey_at_stops[1].departure_time
         | 
| 90 | 
            -
                  end
         | 
| 91 | 
            -
                  it "should make instance invalid" do
         | 
| 92 | 
            -
                    subject.increasing_times
         | 
| 93 | 
            -
                    subject.vehicle_journey_at_stops[1].errors[:departure_time].should_not be_blank
         | 
| 94 | 
            -
                    subject.should_not be_valid
         | 
| 95 | 
            -
                  end
         | 
| 96 | 
            -
                end
         | 
| 97 | 
            -
                describe "#update_attributes" do
         | 
| 98 | 
            -
                  let!(:params){ {"vehicle_journey_at_stops_attributes" => {
         | 
| 99 | 
            -
                        "0"=>{"id" => subject.vehicle_journey_at_stops[0].id ,"arrival_time" => 1.minutes.ago,"departure_time" => 1.minutes.ago},
         | 
| 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 | 
            -
                     }}}
         | 
| 102 | 
            -
                  it "should return false" do
         | 
| 103 | 
            -
                    subject.update_attributes(params).should be_false
         | 
| 104 | 
            -
                  end
         | 
| 105 | 
            -
                  it "should make instance invalid" do
         | 
| 106 | 
            -
                    subject.update_attributes(params)
         | 
| 107 | 
            -
                    subject.should_not be_valid
         | 
| 108 | 
            -
                  end
         | 
| 109 | 
            -
                  it "should let first vjas without any errors" do
         | 
| 110 | 
            -
                    subject.update_attributes(params)
         | 
| 111 | 
            -
                    subject.vehicle_journey_at_stops[0].errors.should be_empty
         | 
| 112 | 
            -
                  end
         | 
| 113 | 
            -
                  it "should add an error on second vjas" do
         | 
| 114 | 
            -
                    subject.update_attributes(params)
         | 
| 115 | 
            -
                    subject.vehicle_journey_at_stops[1].errors[:departure_time].should_not be_blank
         | 
| 116 | 
            -
                  end
         | 
| 117 | 
            -
                end
         | 
| 118 | 
            -
              end
         | 
| 119 | 
            -
             | 
| 120 | 
            -
              context "#time_table_tokens=" do
         | 
| 121 | 
            -
                let!(:tm1){Factory(:time_table, :comment => "TM1")}
         | 
| 122 | 
            -
                let!(:tm2){Factory(:time_table, :comment => "TM2")}
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                it "should return associated time table ids" do
         | 
| 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)
         | 
| 128 | 
            -
                end
         | 
| 129 | 
            -
              end
         | 
| 130 | 
            -
              describe "#bounding_dates" do
         | 
| 131 | 
            -
                before(:each) do
         | 
| 132 | 
            -
                  tm1 = Factory.build(:time_table, :dates => 
         | 
| 133 | 
            -
                    [ Factory.build(:time_table_date, :date => 1.days.ago.to_date),
         | 
| 134 | 
            -
                      Factory.build(:time_table_date, :date => 2.days.ago.to_date)])
         | 
| 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)
         | 
| 138 | 
            -
                  subject.time_tables = [ tm1, tm2, tm3]
         | 
| 139 | 
            -
                end
         | 
| 140 | 
            -
                it "should return min date from associated calendars" do
         | 
| 141 | 
            -
                  subject.bounding_dates.min.should == 4.days.ago.to_date
         | 
| 142 | 
            -
                end
         | 
| 143 | 
            -
                it "should return max date from associated calendars" do
         | 
| 144 | 
            -
                  subject.bounding_dates.max.should == 1.days.ago.to_date
         | 
| 145 | 
            -
                end
         | 
| 146 | 
            -
              end
         | 
| 147 | 
            -
              context "#vehicle_journey_at_stops" do
         | 
| 148 | 
            -
                it "should be ordered like stop_points on route" do
         | 
| 149 | 
            -
                  route = subject.route
         | 
| 150 | 
            -
                  vj_stop_ids = subject.vehicle_journey_at_stops.map(&:stop_point_id)
         | 
| 151 | 
            -
                  expected_order = route.stop_points.map(&:id).select {|s_id| vj_stop_ids.include?(s_id)}
         | 
| 152 | 
            -
             | 
| 153 | 
            -
                  vj_stop_ids.should == expected_order
         | 
| 154 | 
            -
                end
         | 
| 155 | 
            -
             | 
| 156 | 
            -
              end
         | 
| 157 | 
            -
              
         | 
| 158 | 
            -
                describe "#transport_mode_name" do
         | 
| 159 | 
            -
             | 
| 160 | 
            -
                def self.legacy_transport_modes
         | 
| 161 | 
            -
                  %w{Air Train LongDistanceTrain LocalTrain RapidTransit Metro Tramway Coach Bus Ferry Waterborne PrivateVehicle Walk Trolleybus Bicycle Shuttle Taxi VAL Other}
         | 
| 162 | 
            -
                end
         | 
| 163 | 
            -
                
         | 
| 164 | 
            -
                legacy_transport_modes.each do |transport_mode|
         | 
| 165 | 
            -
                  context "when transport_mode is #{transport_mode}" do
         | 
| 166 | 
            -
                    transport_mode_name = Chouette::TransportMode.new(transport_mode.underscore)
         | 
| 167 | 
            -
                    it "should be #{transport_mode_name}" do
         | 
| 168 | 
            -
                      subject.transport_mode = transport_mode
         | 
| 169 | 
            -
                      subject.transport_mode_name.should == transport_mode_name
         | 
| 170 | 
            -
                    end
         | 
| 171 | 
            -
                  end
         | 
| 172 | 
            -
                end
         | 
| 173 | 
            -
                context "when transport_mode is nil" do
         | 
| 174 | 
            -
                  it "should be nil" do
         | 
| 175 | 
            -
                    subject.transport_mode = nil
         | 
| 176 | 
            -
                    subject.transport_mode_name.should be_nil
         | 
| 177 | 
            -
                  end
         | 
| 178 | 
            -
                end
         | 
| 179 | 
            -
             | 
| 180 | 
            -
              end
         | 
| 181 | 
            -
             | 
| 182 | 
            -
              describe "#transport_mode_name=" do
         | 
| 183 | 
            -
                
         | 
| 184 | 
            -
                it "should change transport_mode with TransportMode#name" do
         | 
| 185 | 
            -
                  subject.transport_mode_name = "Test"
         | 
| 186 | 
            -
                  subject.transport_mode.should == "Test"
         | 
| 187 | 
            -
                end
         | 
| 188 | 
            -
             | 
| 189 | 
            -
              end
         | 
| 190 | 
            -
             | 
| 191 | 
            -
              describe ".transport_mode_names" do
         | 
| 192 | 
            -
                
         | 
| 193 | 
            -
                it "should not include unknown transport_mode_name" do
         | 
| 194 | 
            -
                  Chouette::VehicleJourney.transport_mode_names.should_not include(Chouette::TransportMode.new("unknown"))
         | 
| 195 | 
            -
                end
         | 
| 196 | 
            -
             | 
| 197 | 
            -
                it "should not include interchange transport_mode" do
         | 
| 198 | 
            -
                  Chouette::VehicleJourney.transport_mode_names.should_not include(Chouette::TransportMode.new("interchange"))
         | 
| 199 | 
            -
                end
         | 
| 200 | 
            -
             | 
| 201 | 
            -
              end
         | 
| 202 | 
            -
             | 
| 203 | 
            -
            end
         | 
| 204 | 
            -
             | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
             |