Sha256: 677689df81e75393ddd0b8a2fa24f76a7e85d27577578e737eb817eac90370c7

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Program do
  
  it "should assign the segments given during initialization" do
    segments = [ 0.0...5.0, 0.0...4.0, 5.0...10.0 ]
    program = Program.new segments
    program.segments.should eq(segments.clone)
  end
  
  describe "#include?" do
    it "should return true for any offset which would be encountered" do
      segments = [ 0.0...5.0, 0.0...4.0, 5.0...10.0 ]
      program = Program.new segments
      
      [0.0, 4.0, 5.0, 9.999].each do |offset|
        program.include?(offset).should be true
      end
    end

    it "should return false for any offset which would not be encountered" do
      segments = [ 0.0...5.0, 0.0...4.0, 5.0...10.0 ]
      program = Program.new segments
      
      [-0.000001, 10.000001].each do |offset|
        program.include?(offset).should be false
      end
    end
  end
  
  describe '#valid?' do
    context 'increasing, positive segments' do
      it 'should return true' do
        Program.new([0..2,1..2,0..4]).should be_valid
      end
    end
    
    context 'decreasing, positive segments' do
      it 'should return false' do
        Program.new([2..0,2..1,04..0]).should be_invalid
      end
    end

    context 'increasing, negative segments' do
      it 'should return false' do
        Program.new([-1..2,-2..0,-2..2]).should be_invalid
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
music-transcription-0.21.0 spec/model/program_spec.rb
music-transcription-0.20.0 spec/model/program_spec.rb
music-transcription-0.19.0 spec/model/program_spec.rb
music-transcription-0.17.1 spec/model/program_spec.rb
music-transcription-0.17.0 spec/model/program_spec.rb
music-transcription-0.16.0 spec/model/program_spec.rb
music-transcription-0.15.0 spec/model/program_spec.rb
music-transcription-0.14.0 spec/model/program_spec.rb
music-transcription-0.13.0 spec/model/program_spec.rb
music-transcription-0.11.0 spec/model/program_spec.rb