Sha256: ecdaa853620a9e4b2c5ac96d9edaa82bb12f91e16276ad56b8ba89954e895513

Contents?: true

Size: 718 Bytes

Versions: 7

Compression:

Stored size: 718 Bytes

Contents

require 'spec_helper'

RSpec.describe FFI::WiringPi::SoftTone do

  before :each do
    allow(FFI::WiringPi::SoftTone).to receive(:soft_tone_create).and_return 0
  end

  describe '::Pin' do
    it 'raises error when soft_tone_create returns non-zero' do
      allow(FFI::WiringPi::SoftTone).to receive(:soft_tone_create).and_return 1
      expect { described_class::Pin.new 0 }.to raise_error('Something went wrong: Errno:0')
    end

    describe '#write' do
      subject do
        described_class::Pin.new 0
      end

      it 'calls soft_tone_write', :aggregate_failures do
        expect(FFI::WiringPi::SoftTone).to receive(:soft_tone_write).with(0, 100)
        subject.write(100)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ffi-wiring_pi-1.0.3 spec/ffi/wiring_pi/soft_tone_spec.rb
ffi-wiring_pi-1.0.2 spec/ffi/wiring_pi/soft_tone_spec.rb
ffi-wiring_pi-1.0.1 spec/ffi/wiring_pi/soft_tone_spec.rb
ffi-wiring_pi-1.0.0 spec/ffi/wiring_pi/soft_tone_spec.rb
ffi-wiring_pi-0.6.0 spec/ffi/wiring_pi/soft_tone_spec.rb
ffi-wiring_pi-0.5.0 spec/ffi/wiring_pi/soft_tone_spec.rb
ffi-wiring_pi-0.4.0 spec/ffi/wiring_pi/soft_tone_spec.rb