Sha256: 532ede10f1e8389a5dc724208b430e4af4432b57b01cc500bbc2b8a0bf683884

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'
require 'volay/utils'

describe 'Volay::Utils' do
  context 'status_icon' do
    def prepare(image, muted, volume_percent)
      app = double
      toggle_image = double
      status_icon = double
      mixer = double
      allow(app).to receive(:mixer).and_return(mixer)
      allow(app).to receive(:get_object)
        .with('status_icon').and_return(status_icon)
      allow(app).to receive(:get_object)
        .with('toggle_mute_image').and_return(toggle_image)
      allow(mixer).to receive(:muted?)
        .and_return(muted)
      allow(mixer).to receive(:percent)
        .and_return(volume_percent)
      [status_icon, toggle_image].each do |element|
        allow(element).to receive(:set_stock)
          .with(image).once.and_return(true)
      end

      app
    end

    it 'should change icon to low' do
      app = prepare('volume-low', false, 20)
      utils = Volay::Utils.new(app)
      expect(utils.update_status_icon).to be_truthy
    end

    it 'should change icon to medium' do
      app = prepare('volume-medium', false, 40)
      utils = Volay::Utils.new(app)
      expect(utils.update_status_icon).to be_truthy
    end

    it 'should change icon to high' do
      app = prepare('volume-high', false, 80)
      utils = Volay::Utils.new(app)
      expect(utils.update_status_icon).to be_truthy
    end

    it 'should change icon to muted' do
      app = prepare('volume-muted', true, 0)
      utils = Volay::Utils.new(app)
      expect(utils.update_status_icon).to be_truthy
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
volay-0.1.0 spec/volay/utils_spec.rb
volay-0.0.1 spec/volay/utils_spec.rb