require 'spec_helper'
autoload :JSON, 'json'

describe Unikey::Lock do
  it 'implements Virtus' do
    expect(Unikey::Lock.attribute_set.instance_of?(Virtus::AttributeSet)).to be true
  end

  it 'properly accepts parsed JSON upon initilization' do
    json = %({
      "id": "4e269466-e6b1-4e34-8e0e-d74f3fd65688",
      "name": "Home - Front Door",
      "online_status": "online",
      "bolt_state": "locked"
    })
    parsed_json = JSON.parse json
    new_lock = Unikey::Lock.new parsed_json

    expect(new_lock.id).to eql '4e269466-e6b1-4e34-8e0e-d74f3fd65688'
    expect(new_lock.name).to eql 'Home - Front Door'
    expect(new_lock.online_status).to eql 'online'
    expect(new_lock.bolt_state).to eql 'locked'
  end
end
