Sha256: 11e54ae4036a317d66aeeba007b368ebfff4d8efbdb23317ef6230ce7ea71953

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe Mpg321::Client do
  include_context 'fake_mpg321'

  describe '#volume_up' do
    it 'sends a message to increase the volume' do
      subject.volume_up 10
      expect(last_command).to set_volume_to 60
    end

    it 'has a maximum volume of 100' do
      subject.volume_up 55
      expect(subject.volume).to eq 100
      expect(last_command).to set_volume_to 100
    end
  end

  describe '#volume_down' do
    it 'sends a message to decrease the volume' do
      subject.volume_down 10
      expect(last_command).to set_volume_to 40
    end

    it 'has a minimum volume of 0' do
      subject.volume_down 55
      expect(subject.volume).to eq 0
      expect(last_command).to set_volume_to 0
    end
  end

  describe '#volume' do
    it 'returns the current volume' do
      expect(subject.volume).to eq 50
      subject.volume_up 5
      expect(subject.volume).to eq 55
    end
  end

  describe '#volume=' do
    it 'sets the volume' do
      expect(subject.volume).to eq 50
      subject.volume = 11
      expect(subject.volume).to eq 11
    end

    it 'casts float arguments to integer' do
      expect(subject.volume).to eq 50
      subject.volume = 47.11
      expect(subject.volume).to eq 47
    end

    it 'has a minimum of 0' do
      subject.volume = -1
      expect(subject.volume).to eq 0
    end

    it 'has a maximum of 100' do
      subject.volume = 101
      expect(subject.volume).to eq 100
    end

    it 'sends a message to set the volume' do
      subject.volume = 11
      expect(last_command).to set_volume_to 11
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mpg321-1.0.0 spec/volume_control_spec.rb