Add a test case for "end condition happens before start condition".

- In the cycle analytics specs.
This commit is contained in:
Timothy Andrew 2016-09-07 14:22:03 +05:30
parent 9cff3f8f52
commit 32147ddf54
1 changed files with 21 additions and 0 deletions

View File

@ -80,6 +80,27 @@ module CycleAnalyticsHelpers
expect(subject.send(phase)).to be_nil
end
end
context "when the end condition happens before the start condition" do
it 'returns nil' do
data = data_fn[self]
start_time = Time.now
end_time = start_time + rand(1..5).days
# Run `before_end_fn` at the midpoint between `start_time` and `end_time`
Timecop.freeze(start_time + (end_time - start_time)/2) { before_end_fn[self, data] } if before_end_fn
end_time_conditions.each do |condition_name, condition_fn|
Timecop.freeze(start_time) { condition_fn[self, data] }
end
start_time_conditions.each do |condition_name, condition_fn|
Timecop.freeze(end_time) { condition_fn[self, data] }
end
expect(subject.send(phase)).to be_nil
end
end
end
end