Sha256: 10f480b48a66986ee2480e894c328a20cb1ef00176fa5b7070be745fe79250ef

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

require File.expand_path('../spec_helper',__FILE__)

describe Handle::Field do
  let(:handle_str)  { Handle::Field::Base.from_data(' index=2 ttl=15200 type=URL rwr- "http://www.example.edu/fake-handle"') }
  let(:handle_hash) { Handle::Field::Base.from_data({ index: 2, ttl: 15200, type: 'URL', perms: 14, value: 'http://www.example.edu/fake-handle' }) }

  it "#from_hash" do
    handle = handle_hash
    expect(handle).to be_a(Handle::Field::URL)
    expect(handle.class.value_type).to eq('URL')
    expect(handle.ttl).to eq(15200)
    expect(handle.value).to eq('http://www.example.edu/fake-handle')
    expect(handle.value_str).to eq('http://www.example.edu/fake-handle')
  end

  it "#from_string" do
    handle = handle_str
    expect(handle).to be_a(Handle::Field::URL)
    expect(handle.class.value_type).to eq('URL')
    expect(handle.ttl).to eq(15200)
    expect(handle.value).to eq('http://www.example.edu/fake-handle')
    expect(handle.value_str).to eq('http://www.example.edu/fake-handle')
  end

  it "#to_hash" do
    h = handle_str.to_h
    expect(h).to be_a(Hash)
    expect(h).to eq({
      index: 2,
      type:  'URL',
      ttl:   15200,
      perms: 14,
      value: 'http://www.example.edu/fake-handle'
    })
  end

  it "#to_s" do
    expect(handle_hash.to_s).to eq(handle_str.to_s)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
handle-system-0.1.1 spec/field_spec.rb
handle-system-0.1.0 spec/field_spec.rb
handle-system-0.0.7 spec/field_spec.rb
handle-system-0.0.6 spec/field_spec.rb
handle-system-0.0.5 spec/field_spec.rb
handle-system-0.0.4 spec/field_spec.rb
handle-system-0.0.3 spec/field_spec.rb