Sha256: e9d04ea3f730c566bf791789b363efb1b868919ae67ba4310c5d274b143dde5b

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe Serinette::SoxOptions do
  context 'a method #randomize_options_as_string' do
    it 'should exist' do
      expect(Serinette::SoxOptions).to respond_to(:randomize_options_as_string)
    end
  end

  context 'a method #stringify_option' do
    it 'should exist' do
      expect(Serinette::SoxOptions).to respond_to(:stringify_option)
    end

    it 'should return correct string when given type: :flag' do
      good_option1 = {
        type: :flag,
        name: 'wet-only',
        value: '-w'
      }

      allow_any_instance_of(Array).to receive(:sample).and_return(true)
      expect(Serinette::SoxOptions.stringify_option(good_option1)).to eq('-w')
    end

    it 'should return correct string when given type: :trait as range' do
      good_option2 = {
        type: :trait,
        name: 'reverberance',
        value: (0..100),
        default: 50
      }

      result = Serinette::SoxOptions.stringify_option(good_option2)

      expect(result).not_to be_nil
      expect(result.to_i).to be_between(0, 100)
    end

    it 'should return correct string when given type: :trait as array' do
      good_option2 = {
        type: :trait,
        name: 'reverberance',
        value: [0, 50, 100],
        default: 50
      }

      allow_any_instance_of(Array).to receive(:sample).and_return(50)

      result = Serinette::SoxOptions.stringify_option(good_option2)

      expect(result).not_to be_nil
      expect(result.to_i).to eq(50)
    end

    it 'should return correct string when given type: :trait as proc'

    it 'should fail when type is bad' do
      bad_option = {
        type: :bad,
        name: 'wet-only',
        value: '-w'
      }

      error = Serinette::Error
      expect { Serinette::SoxOptions.stringify_option(bad_option) }.to raise_error(error)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
serinette-0.0.3 spec/serinette/mixins/sox_options_spec.rb
serinette-0.0.2 spec/serinette/mixins/sox_options_spec.rb
serinette-0.0.0.pre spec/serinette/mixins/sox_options_spec.rb