Sha256: cad2bf7033ca09507621902e0638662303014bb52cb0437ea76adc038f22f4cb

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

describe NetworkExecutive::LineupRange do

  before do
    Timecop.freeze Time.now.change hour:12, min:0, sec:0
  end

  let(:start) { Time.now }

  let(:stop) { 1.5.hours.from_now }

  describe '#each' do
    subject do
      times = []

      described_class.new(start, stop).each { |st| times << st }

      times
    end

    it 'should yield a showtime for each segment' do
      subject.size.should == 6
    end

    it 'should yield the start time' do
      subject.first.should == start
    end

    it 'should yield a rounded stop time' do
      subject.last.should == stop - 15.minutes
    end
  end

  describe '#each_with_object' do
    subject do
      my_obj = []

      described_class.new( start, stop ).each_with_object( my_obj ) do |st, o|
        o << st
      end

      my_obj
    end

    it 'should yield the specified object for each segment' do
      subject.size.should == 6
    end
  end

  describe '#segments' do
    subject { described_class.new( start, stop, interval:interval).segments }

    context 'with a default interval' do
      let(:interval) { nil }

      it { should == 6 }
    end

    context 'with a half-hour interval' do
      let(:interval) { 30 }

      it { should == 3 }
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
network_executive-0.0.4 spec/models/lineup_range_spec.rb
network_executive-0.0.3 spec/models/lineup_range_spec.rb
network_executive-0.0.2 spec/models/lineup_range_spec.rb