Sha256: 16cba332883623307046c42cd358790363e33c966b9b17fb4d57b38732d345b3
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe Brewby::Inputs::DS18B20 do it 'accepts a hardware_id' do sensor = Brewby::Inputs::DS18B20.new hardware_id: 'something' sensor.hardware_id.should == 'something' end it 'picks the first hardware_id it finds when no hardware_id is specified' do Dir.mktmpdir do |dir| File.write "#{dir}/28-12345", "1" sensor = Brewby::Inputs::DS18B20.new device_path: dir sensor.hardware_id.should == '28-12345' end end context 'reading sensor data' do before do Brewby::Inputs::DS18B20.any_instance.stub(:read_raw) { "f5 00 4b 46 7f ff 0b 10 d7 : crc=d7 YES\nf5 00 4b 46 7f ff 0b 10 d7 t=15312" } @sensor = Brewby::Inputs::DS18B20.new device_path: @device_dir, hardware_id: '28-12345' end it 'reads the temperaturee and returns it in fahrenheit' do input = @sensor.read input.should == 59.562 end it 'parses the raw data to celsius' do tempC = @sensor.parse @sensor.read_raw tempC.should == 15.312 end it 'returns nil when an error occurs when parsing' do Brewby::Inputs::DS18B20.any_instance.stub(:read_raw) { "f5 00 4b 46 7f ff 0b 10 d7 : crc=d7 NO\nf5 00 4b 46 7f ff 0b 10 d7" } input = @sensor.read input.should be_nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brewby-0.1.1 | spec/inputs/ds18b20_spec.rb |
brewby-0.1.0 | spec/inputs/ds18b20_spec.rb |