Sha256: c72aadb7e09a8faa1ab7136ccc8aeccc1ef7e34580ebc71d30c540ea9a56da80

Contents?: true

Size: 1022 Bytes

Versions: 55

Compression:

Stored size: 1022 Bytes

Contents

require_relative '../spec_helper'

describe RestfulResource::OpenObject do
  it "should act as an openstruct" do
    object = RestfulResource::OpenObject.new(name: 'David', surname: 'Santoro')

    expect(object.name).to eq 'David'
    expect(object.surname).to eq 'Santoro'
  end

  it "should raise an error when accessing a field that doesn't exist" do
    object = RestfulResource::OpenObject.new({name: 'David', surname: 'Santoro'})

    expect { object.age }.to raise_error(NoMethodError)
  end

  it "should implement equality operators correctly" do
    a = RestfulResource::OpenObject.new({name: 'Joe', age: 13})
    b = RestfulResource::OpenObject.new({name: 'Joe', age: 13})
    c = RestfulResource::OpenObject.new({name: 'Mike', age: 13})

    list = [a, b, c]

    expect(a == b).to eq true
    expect(a.eql?(b)).to eq true
    expect(a.equal?(b)).to eq false

    expect(a == c).to eq false
    expect(a.eql?(c)).to eq false
    expect(a.equal?(c)).to eq false
    expect(list.uniq.length).to eq 2
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
restful_resource-2.3.0 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.8 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.7 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.6 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.5 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.4 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.3 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.2 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.1 spec/restful_resource/open_object_spec.rb
restful_resource-2.2.0 spec/restful_resource/open_object_spec.rb
restful_resource-2.0.2 spec/restful_resource/open_object_spec.rb
restful_resource-2.0.1 spec/restful_resource/open_object_spec.rb
restful_resource-1.6.0 spec/restful_resource/open_object_spec.rb
restful_resource-1.5.0 spec/restful_resource/open_object_spec.rb
restful_resource-1.4.3 spec/restful_resource/open_object_spec.rb
restful_resource-1.4.2 spec/restful_resource/open_object_spec.rb
restful_resource-1.4.1 spec/restful_resource/open_object_spec.rb
restful_resource-1.4.0 spec/restful_resource/open_object_spec.rb
restful_resource-1.3.0 spec/restful_resource/open_object_spec.rb
restful_resource-1.2.2 spec/restful_resource/open_object_spec.rb