diff options
| author | Xinhui | 2017-05-12 15:05:12 +0200 |
|---|---|---|
| committer | Xinhui | 2017-05-12 15:05:12 +0200 |
| commit | ce44691bb446cc5e48accc58ad0613a511f10431 (patch) | |
| tree | c58b6e48a08b66fedf40bad70c6d05e2f14dd864 | |
| parent | 2ab2023f3a4922857b2343cbd67049b3ec8f8c9c (diff) | |
| download | chouette-core-ce44691bb446cc5e48accc58ad0613a511f10431.tar.bz2 | |
Refactoring spec time_tables intersect
| -rw-r--r-- | spec/models/time_table_combination_spec.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/spec/models/time_table_combination_spec.rb b/spec/models/time_table_combination_spec.rb index 4c99a14fa..059fe9e81 100644 --- a/spec/models/time_table_combination_spec.rb +++ b/spec/models/time_table_combination_spec.rb @@ -54,6 +54,7 @@ describe TimeTableCombination, :type => :model do subject.combine source.reload end + it "should add combined to source" do expect(source.periods.size).to eq(1) expect(source.periods[0].period_start).to eq(Date.new(2014,8,1)) @@ -78,14 +79,17 @@ describe TimeTableCombination, :type => :model do subject.combine source.reload end + it "should intersect combined to source" do expect(source.int_day_types).to eq(0) - expect(source.periods.size).to eq(0) - expect(source.dates.size).to eq(17) - expect(source.dates[0].date).to eq(Date.new(2014,8,15)) - expect(source.dates[16].date).to eq(Date.new(2014,8,31)) + expect(source.periods.size).to eq(1) + expect(source.dates.size).to eq(0) + + expect(source.periods.first.period_start.to_s).to eq('2014-08-15') + expect(source.periods.first.period_end.to_s).to eq('2014-08-31') end end + context "when operation is disjoin" do before(:each) do source.periods.clear @@ -104,12 +108,14 @@ describe TimeTableCombination, :type => :model do subject.combine source.reload end + it "should disjoin combined to source" do expect(source.int_day_types).to eq(0) - expect(source.periods.size).to eq(0) - expect(source.dates.size).to eq(14) - expect(source.dates[0].date).to eq(Date.new(2014,8,1)) - expect(source.dates[13].date).to eq(Date.new(2014,8,14)) + expect(source.periods.size).to eq(1) + expect(source.dates.size).to eq(0) + + expect(source.periods.first.period_start.to_s).to eq('2014-08-01') + expect(source.periods.first.period_end.to_s).to eq('2014-08-14') end end end |
