Sha256: f3ef718e0888e8fb5195ca3413f8c3a761ffbf6c50b367332d443f8fad4d74a9
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
describe Transmission::Fields do [ {className: Transmission::Fields::SessionGet, fields: ['alt-speed-down']}, {className: Transmission::Fields::TorrentGet, fields: ['doneDate']}, {className: Transmission::Fields::SessionStats, fields: ['activeTorrentCount']} ].each do |klass| describe "#{klass[:className]}" do describe '#new' do it 'should create an instance with correct fields' do instance = klass[:className].new expect(instance.fields.size).to eq(klass[:className]::ATTRIBUTES.size) end it 'should create an instance with given fields' do instance = klass[:className].new klass[:fields] expect(instance.fields.size).to eq(1) end it 'should raise an error if invalid arguments is given' do expect { klass[:className].new 'i-dont-exist' => '' }.to raise_error(Transmission::Fields::InvalidField) end end end end describe '.is_valid?' do describe 'with valid key' do it 'should return true' do stub_const("Transmission::Fields::ATTRIBUTES", [{field: 'test-me'}]) expect(Transmission::Fields.is_valid?('test_me')).to eq(true) end end describe 'with invalid key' do it 'should return true' do stub_const("Transmission::Fields::ATTRIBUTES", [{field: 'test-me'}]) expect(Transmission::Fields.is_valid?('testMee')).to eq(false) end end end describe '.real_key' do describe 'with valid key' do it 'should return real key' do stub_const("Transmission::Fields::ATTRIBUTES", [{field: 'test-me'}]) expect(Transmission::Fields.real_key('test_me')).to eq('test-me') end end describe 'with invalid key' do it 'should return nil' do stub_const("Transmission::Fields::ATTRIBUTES", [{field: 'test-me'}]) expect(Transmission::Fields.real_key('testMee')).to eq(nil) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems