settings_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. require 'api_client'
  2. RSpec.describe 'Settings' do
  3. before(:all) do
  4. @client = ApiClient.new(ENV.fetch('ESPMH_HOSTNAME'), ENV.fetch('ESPMH_TEST_DEVICE_ID_BASE'))
  5. @client.upload_json('/settings', 'settings.json')
  6. end
  7. context 'radio' do
  8. it 'should store a set of channels' do
  9. val = %w(HIGH LOW)
  10. @client.put('/settings', rf24_channels: val)
  11. result = @client.get('/settings')
  12. expect(result['rf24_channels']).to eq(val)
  13. val = %w(MID LOW)
  14. @client.put('/settings', rf24_channels: val)
  15. result = @client.get('/settings')
  16. expect(result['rf24_channels']).to eq(val)
  17. val = %w(MID LOW LOW LOW)
  18. @client.put('/settings', rf24_channels: val)
  19. result = @client.get('/settings')
  20. expect(result['rf24_channels']).to eq(Set.new(val).to_a)
  21. end
  22. it 'should store a listen channel' do
  23. @client.put('/settings', rf24_listen_channel: 'MID')
  24. result = @client.get('/settings')
  25. expect(result['rf24_listen_channel']).to eq('MID')
  26. @client.put('/settings', rf24_listen_channel: 'LOW')
  27. result = @client.get('/settings')
  28. expect(result['rf24_listen_channel']).to eq('LOW')
  29. end
  30. end
  31. end