Sha256: db8fae3d69360fb40b8bd7e03f2e6782f17c3becbcc1338bc75d73071fb97914

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

# coding: utf-8

require 'spec_helper'

RSpec.describe TTY::Table::Header, '#==' do
  let(:attributes) { [:id, :name] }
  let(:object) { described_class.new(attributes) }

  subject { object == other }

  context 'with the same object' do
    let(:other) { object }

    it { is_expected.to eql(true) }

    it 'is symmetric' do
      is_expected.to eql(other == object)
    end
  end

  context 'with an equivalent object' do
    let(:other) { object.dup }

    it { is_expected.to eql(true) }

    it 'is symmetric' do
      is_expected.to eql(other == object)
    end
  end

  context 'with an equivalent object of subclass' do
    let(:other) { Class.new(described_class).new(attributes) }

    it { is_expected.to eql(true) }

    it 'is symmetric' do
      is_expected.to eql(other == object)
    end
  end

  context 'with an object having different attributes' do
    let(:other_attributes) { [:text] }
    let(:other) { described_class.new(other_attributes) }

    it { is_expected.to eql(false) }

    it 'is symmetric' do
      is_expected.to eql(other == object)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tty-table-0.10.0 spec/unit/header/equality_spec.rb
tty-table-0.9.0 spec/unit/header/equality_spec.rb
tty-table-0.8.0 spec/unit/header/equality_spec.rb
tty-table-0.7.0 spec/unit/header/equality_spec.rb
tty-table-0.6.0 spec/unit/header/equality_spec.rb
tty-table-0.5.0 spec/unit/header/equality_spec.rb
tty-table-0.4.0 spec/unit/header/equality_spec.rb
tty-table-0.3.0 spec/unit/header/equality_spec.rb
tty-table-0.2.0 spec/unit/header/equality_spec.rb
tty-table-0.1.0 spec/unit/header/equality_spec.rb