Sha256: 265cfde7b3981b327a1d8da6117b5b3f20ce0fb012805049006b28c37be00e77

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

describe Transmission::Utils do
  let(:utils) {
    Class.new do
      include Transmission::Utils
    end
  }

  subject { utils.new }

  describe '.is_valid_key?' do
    describe 'with dashes' do
      let(:arguments) {[{field: 'test-me'}]}

      it 'should find valid key' do
        expect(subject.is_valid_key?('test_me', arguments)).to eq(true)
      end
    end

    describe 'with camelcase' do
      let(:arguments) {[{field: 'testMe'}]}

      it 'should find valid key' do
        expect(subject.is_valid_key?('test_me', arguments)).to eq(true)
      end
    end

    describe 'with invalid key' do
      let(:arguments) {[{field: 'testMe'}]}

      it 'should not find any key' do
        expect(subject.is_valid_key?('i_dont_exit', arguments)).to eq(false)
      end
    end
  end

  describe '.option_keys' do
    it 'should return the right option keys' do
      options = subject.option_keys('test_me')
      expect(options.include?('testMe')).to eq(true)
      expect(options.include?('test-me')).to eq(true)
    end
  end

  describe '.option_key' do
    describe 'with dashes' do
      let(:arguments) {[{field: 'test-me'}]}

      it 'should return the correct key' do
        expect(subject.option_key('test_me', arguments)).to eq('test-me')
      end
    end

    describe 'with camelcase' do
      let(:arguments) {[{field: 'testMe'}]}

      it 'should return the correct key' do
        expect(subject.option_key('test_me', arguments)).to eq('testMe')
      end
    end

    describe 'with invalid key' do
      let(:arguments) {[{field: 'testMe'}]}

      it 'should return nil' do
        expect(subject.option_key('i_dont_exit', arguments)).to eq(nil)
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
transmission-rpc-ruby-0.4.0 spec/transmission/utils_spec.rb
transmission-rpc-ruby-0.3.1 spec/transmission/utils_spec.rb
transmission-rpc-ruby-0.3.0 spec/transmission/utils_spec.rb
transmission-rpc-ruby-0.2.1 spec/transmission/utils_spec.rb
transmission-rpc-ruby-0.2.0 spec/transmission/utils_spec.rb