Sha256: 266d2149f00ebcf0c4eafd4ffc8a29dc40c3a42108c072d41e18692b025ca2c9

Contents?: true

Size: 1.12 KB

Versions: 3

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(source: subject, decorated?: true)

    expect(subject == decorated).to be_true
  end

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

    expect(subject == decorated).to be_false
  end

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

    expect(subject == decoratable).to be_false
  end

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

    expect(subject == undecoratable).to be_false
  end

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

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
draper-1.2.0 spec/support/shared_examples/decoratable_equality.rb
jamesgolick-draper-1.1.1a spec/support/shared_examples/decoratable_equality.rb
draper-1.1.0 spec/support/shared_examples/decoratable_equality.rb