/
input_spec.rb
44 lines (38 loc) · 1.2 KB
/
input_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'spec_helper'
module Dino
module Components
module Setup
describe Input do
include BoardMock
let(:options) { { pin: 'A0', board: board, pullup: true} }
class InputComponent
include SinglePin
include Input
end
subject { InputComponent.new(options) }
describe '#pullup=' do
it 'should tell the board to set the pullup mode correctly' do
subject
expect(board).to receive(:set_pullup).with(subject.pin, false)
subject.pullup = false
expect(subject.pullup).to be(false)
end
end
describe '#initialize_pins' do
it 'should set the pin mode to in' do
expect(board).to receive(:set_pin_mode).with(board.convert_pin(options[:pin]), :in)
subject
end
it 'should set the pulllup if included in options' do
expect(board).to receive(:set_pullup).with(subject.pin, true)
InputComponent.new(options)
end
it 'should tell the board to start reading' do
expect(board).to receive(:start_read)
subject
end
end
end
end
end
end