Sha256: 14cd0e91f724989f5e4032286616ab3e1cd1e330d43e6c3cb65fcf69a9637d16

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

shared_examples_for 'an integer field' do  |values|

  subject do
    described_class.new({
      :value => values[:default],
      :active => true
    })
  end

  context '#serialize' do
    it 'should serialize properly with an integer value' do
      subject.serialize.should == values[:default_hex]
    end

    it 'should raise an Exception for a String' do
      subject.value = 'A'
      expect {subject.serialize}.to raise_error
    end

    it 'should raise an Exception for Nil' do
      subject.value = nil
      expect {subject.serialize}.to raise_error
    end
  end

  context '#parse' do
    it "should parse a raw #{values[:bits].to_s}-bit integer from a string" do
      subject.parse(values[:alt_hex]).should == values[:size]
      subject.value.should == values[:alt]
    end

    it "should use an offset to find the #{values[:bits].to_s}-bit integer in the string" do
      subject.parse("Value:#{values[:alt_hex]}",6).should == values[:size]
      subject.value.should == values[:alt]
    end

    it 'should return 0 and not change the value if the string is not big enough' do
      subject.parse(values[:small]).should == 0
      subject.value.should == values[:default]
    end
  end

end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.4.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/rubyntlm-0.4.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rubyntlm-0.4.0/spec/support/shared/examples/net/ntlm/int_shared.rb
rubyntlm-0.4.0 spec/support/shared/examples/net/ntlm/int_shared.rb