Sha256: 000c5db4220d2bf2eefc489eb38e84896550cb455b8d797801fb9a328b7a5912

Contents?: true

Size: 1.26 KB

Versions: 11

Compression:

Stored size: 1.26 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
      expect(subject.serialize).to eq(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
      expect(subject.parse(values[:alt_hex])).to eq(values[:size])
      expect(subject.value).to eq(values[:alt])
    end

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

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

end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rubyntlm-0.6.1/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
rubyntlm-0.6.1 spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rubyntlm-0.6.0/spec/support/shared/examples/net/ntlm/int_shared.rb
rubyntlm-0.6.0 spec/support/shared/examples/net/ntlm/int_shared.rb