Sha256: 1ef13bba73e661ff2b70162f3be486fa727daf5460a3fa0bf9ed3a1735e08bbd

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

require 'device_map'

RSpec.describe DeviceMap::DeviceData::Device do
  describe '.parse' do
    it 'returns new instance of this class' do
      properties = { id: 'iphone', vendor: 'Apple' }
      device_node = generate_device_node(properties)
      device = described_class.parse(device_node)

      expect(device.id).to eq properties.fetch(:id)
      expect(device.vendor).to eq properties.fetch(:vendor)
    end

    def generate_device_node(properties)
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.device(id: properties.fetch(:id)) do
          properties.each do |name, value|
            xml.property(name: name, value: value)
          end
        end
      end

      builder.doc.child
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
device_map-0.1.2 spec/device_data/device_spec.rb
device_map-0.1.1 spec/device_data/device_spec.rb
device_map-0.1.0 spec/device_data/device_spec.rb