Sha256: dece4a1adb3173c20c7f7237ddcfb1b24fba6dc67dabd7283b9e31489b18c97a

Contents?: true

Size: 1007 Bytes

Versions: 7

Compression:

Stored size: 1007 Bytes

Contents

require 'spec_helper'

describe AdminIt::Utils do
  subject { AdminIt::Utils }

  describe '.assert_symbol_arg' do
    it 'just passes throw symbol args' do
      expect(subject.assert_symbol_arg(:test)).to eq :test
    end

    it 'converts string to symbol' do
      expect(subject.assert_symbol_arg('test')).to eq :test
    end

    it 'calls block if it given for non-symbol args' do
      test = false
      subject.assert_symbol_arg(10) { |value| test = value }
      expect(test).to eq 10
    end
  end

  describe '.assert_symbol_arg!' do
    def some_method(name)
      subject.assert_symbol_arg!(10, name)
    end

    it 'calls .assert_symbol_arg' do
      expect(subject).to receive(:assert_symbol_arg).with(:test)
      subject.assert_symbol_arg!(:test, name: 'name')
    end

    it 'raises ArgumentError for wrong args' do
      expect { some_method('arg') }.to raise_error(
        ArgumentError,
        'Argument arg for some_method should be a String or Symbol'
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
admin_it-1.0.7 spec/lib/utils_spec.rb
admin_it-1.0.6 spec/lib/utils_spec.rb
admin_it-1.0.5 spec/lib/utils_spec.rb
admin_it-1.0.4 spec/lib/utils_spec.rb
admin_it-1.0.3 spec/lib/utils_spec.rb
admin_it-1.0.2 spec/lib/utils_spec.rb
admin_it-1.0.1 spec/lib/utils_spec.rb