Sha256: a0781212e47a4198a69a52b54ce5985e92de1b29f0807b088a0a373321b55f4c

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

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

include Nerpin

describe Controller do
  before do
    @destination = double("CoreMIDI::Destination")
  end

  subject do
    Controller.new(@destination, Nrpn::Micron)
  end

  it 'controls the pitch of oscillator 1 with 999' do
    subject.should_receive(:puts).with(15, :v0x06 => 7, :v0x26 => 103)

    subject.oscillator_1_pitch(999)
  end

  describe '#puts' do
    it 'sends message with specified value to the destination' do
      @destination.should_receive(:puts).with(0b10110000, 99, anything())
      @destination.should_receive(:puts).with(0b10110000, 98, anything())
      @destination.should_receive(:puts).with(0b10110000, 6,  5)
      @destination.should_receive(:puts).with(0b10110000, 38, 123)

      subject.puts(15, :v0x06 => 5, :v0x26 => 123)
    end

    context 'nrpn is lower than 128' do
      it 'sends message to the destination' do
        @destination.should_receive(:puts).with(0b10110000, 99, 0)
        @destination.should_receive(:puts).with(0b10110000, 98, 15)
        @destination.should_receive(:puts).with(0b10110000, 6,  anything())
        @destination.should_receive(:puts).with(0b10110000, 38, anything())

        subject.puts(15, :v0x06 => 0, :v0x26 => 0)
      end
    end

    context 'nrpn is higher than 127' do
      it 'sends message to the destination' do
        @destination.should_receive(:puts).with(0b10110000, 99, 1)
        @destination.should_receive(:puts).with(0b10110000, 98, 54)
        @destination.should_receive(:puts).with(0b10110000, 6,  anything())
        @destination.should_receive(:puts).with(0b10110000, 38, anything())

        subject.puts(182, :v0x06 => 0, :v0x26 => 0)
      end
    end
  end

  describe '#nrpns' do
    it 'return NRPNs' do
      subject.nrpns.size.should eql(234)
      subject.nrpns.values.first.should be_a_kind_of(Nrpn::Base)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nerpin-0.0.2 spec/nerpin/controller_spec.rb
nerpin-0.0.1 spec/nerpin/controller_spec.rb