Sha256: a90fa3590d4d482954373f5282fb6f31cd962d98c120bb69aa11c8ddfa81d15a
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require_relative '../test_helper' class I2CPeripheralBase include Denko::I2C::Peripheral end class I2CPeripheralTest < MiniTest::Test def board @board ||= BoardMock.new end def bus return @bus if @bus @bus = Denko::I2C::Bus.new(board: board, pin:5) @bus end def part @part ||= I2CPeripheralBase.new(bus: bus, i2c_address: 0x30) end def test_write_and_repeated_start part.i2c_repeated_start = true mock = MiniTest::Mock.new.expect :call, nil, [0x30, [1,2], 100000, true] bus.stub(:write, mock) do part.i2c_write [1,2] end end def test_frequency part.i2c_frequency = 400000 mock = MiniTest::Mock.new.expect :call, nil, [0x30, [1,2], 400000, false] bus.stub(:write, mock) do part.i2c_write [1,2] end end def test__read_and_repeated_start part.i2c_repeated_start = true board.inject_read_for_component(part, 5, "48-127,127,127,127,127,127") mock = MiniTest::Mock.new.expect :call, nil, [0x30, 0x03, 6, 100000, true] bus.stub(:read, mock) do part.i2c_read(0x03, 6) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
denko-0.13.2 | test/i2c/peripheral_test.rb |
denko-0.13.1 | test/i2c/peripheral_test.rb |
denko-0.13.0 | test/i2c/peripheral_test.rb |