Sha256: 845b0787e6dd8e182a4441f272093f9216e5f607800d4be25aa176babd96ee3b

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

shared_examples_for "decoration-aware #==" do |subject|
  it "is true for itself" do
    expect(subject == subject).to be_true
  end

  it "is false for another object" do
    expect(subject == Object.new).to be_false
  end

  it "is true for a decorated version of itself" do
    decorated = double(object: subject, decorated?: true)

    expect(subject == decorated).to be_true
  end

  it "is false for a decorated other object" do
    decorated = double(object: Object.new, decorated?: true)

    expect(subject == decorated).to be_false
  end

  it "is false for a decoratable object with a `object` association" do
    decoratable = double(object: subject, decorated?: false)

    expect(subject == decoratable).to be_false
  end

  it "is false for an undecoratable object with a `object` association" do
    undecoratable = double(object: subject)

    expect(subject == undecoratable).to be_false
  end

  it "is true for a multiply-decorated version of itself" do
    decorated = double(object: subject, decorated?: true)
    redecorated = double(object: decorated, decorated?: true)

    expect(subject == redecorated).to be_true
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
draper-1.4.0 spec/support/shared_examples/decoratable_equality.rb
draper-1.3.1 spec/support/shared_examples/decoratable_equality.rb
draper-1.3.0 spec/support/shared_examples/decoratable_equality.rb
draper-1.2.1 spec/support/shared_examples/decoratable_equality.rb