Sha256: 5c892e1fb355112d16238f942e874c0852c8a62d98c7ce309b74283dd3aedc33

Contents?: true

Size: 802 Bytes

Versions: 8

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

describe Yaoc::Helper::StructHashConstructor do
  subject{
    Yaoc::Helper::StructH(:id, :name).new(id: 1, name: "no name")
  }

  it "creates a struct with a hash enabled constructor" do
    expect(subject.id).to eq 1
    expect(subject.name).to eq "no name"
  end

  context "with equal support" do
    subject{
      Yaoc::Helper::StructHE(:id, :name)
    }

    it "returns true when all attributes are equal" do
      first = subject.new(id: 1, name: "no name")
      second = subject.new(id: 1, name: "no name")

      expect(first).to eq second
    end

    it "returns false when not all atributes are equal" do
      first = subject.new(id: 1, name: "no name")
      second = subject.new(id: 1, name: "no name2")

      expect(first).not_to eq second
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yaoc-0.0.13 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.12 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.11 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.10 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.9 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.8 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.7 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb
yaoc-0.0.6 spec/unit/lib/yaoc/helper/struct_hash_constructor_spec.rb