spec/model/tempo_spec.rb in music-transcription-0.17.1 vs spec/model/tempo_spec.rb in music-transcription-0.19.0
- old
+ new
@@ -1,24 +1,24 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Tempo do
- describe '#==' do
- context 'same bpm and beat duration' do
- it 'should return true' do
- [
- [120,nil],
- [120,0.25.to_r],
- [300,"3/8".to_r]
- ].each do |bpm,bd|
- Tempo.new(bpm,bd).should eq(Tempo.new(bpm,bd))
- end
- end
+ describe '#initialize' do
+ it 'should assign given value' do
+ Tempo.new(3).value.should eq(3)
end
- context 'different bpm or beat duration' do
- it 'should return false' do
- Tempo.new(120,nil).should_not eq(Tempo.new(120,"1/4".to_r))
- Tempo.new(200,2).should_not eq(Tempo.new(200,2.1))
+ context 'given negative value' do
+ it 'should raise NonPositiveError' do
+ expect { Tempo.new(-3) }.to raise_error(NonPositiveError)
+ end
+ end
+ end
+
+ [ :qnpm, :bpm, :npm, :nps ].each do |sym|
+ describe "Tempo::#{sym}" do
+ it "should print tempo value + '#{sym}'" do
+ klass = Tempo.const_get(sym.upcase)
+ klass.new(20).to_s.should eq("20#{sym}")
end
end
end
end