Sha256: 49b8682e22547c0b66f1e6865563783b3d2e8083543cb1af738c2a0f30d97ced

Contents?: true

Size: 1.7 KB

Versions: 9

Compression:

Stored size: 1.7 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
      toggle_button = 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(app).to receive(:get_object)
        .with('toggle_mute').and_return(toggle_button)
      allow(toggle_button).to receive(:set_active).and_return(muted)
      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

9 entries across 9 versions & 1 rubygems

Version Path
volay-1.1.0 spec/volay/utils_spec.rb
volay-1.0.1 spec/volay/utils_spec.rb
volay-1.0.0 spec/volay/utils_spec.rb
volay-0.7.0 spec/volay/utils_spec.rb
volay-0.6.0 spec/volay/utils_spec.rb
volay-0.5.0 spec/volay/utils_spec.rb
volay-0.4.0 spec/volay/utils_spec.rb
volay-0.3.0 spec/volay/utils_spec.rb
volay-0.2.0 spec/volay/utils_spec.rb