Sha256: 5f774f95ce9dded3aab2235570871e218c2d20e9de4fd57235f0f7ab4b4b7f46

Contents?: true

Size: 683 Bytes

Versions: 4

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true
shared_examples_for "has reference" do
  context "when the reference is nil" do
    before do
      subject[:reference] = nil
    end

    it "generates a valid reference" do
      expect(subject.reference).to match(/[A-z]+/)
    end
  end

  context "when the reference is already set" do
    before do
      subject[:reference] = "ARBITRARYREF"
    end

    it "keeps the pre-existing reference" do
      expect(subject.reference).to eq("ARBITRARYREF")
    end
  end

  context "when saving" do
    it "stores the reference" do
      subject.reference = nil
      subject.save!
      expect(subject.reload.reference).to_not be_blank
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.1.0 lib/decidim/core/test/shared_examples/has_reference.rb
decidim-core-0.0.8.1 lib/decidim/core/test/shared_examples/has_reference.rb
decidim-core-0.0.7 lib/decidim/core/test/shared_examples/has_reference.rb
decidim-core-0.0.6 lib/decidim/core/test/shared_examples/has_reference.rb