Sha256: 311f59079efc813a1374d12f6df3b5984cbd82bfe428fe2b00264da13bdaa50a

Contents?: true

Size: 758 Bytes

Versions: 13

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

shared_examples "form to param" do |options|
  method_name = options[:method_name] || :to_param

  describe "##{method_name}" do
    subject { described_class.new(id:) }

    context "with actual ID" do
      let(:id) { double }

      it "returns the ID" do
        expect(subject.public_send(method_name)).to be(id)
      end
    end

    context "with nil ID" do
      let(:id) { nil }

      it "returns the ID placeholder" do
        expect(subject.public_send(method_name)).to eq(options[:default_id])
      end
    end

    context "with empty ID" do
      let(:id) { "" }

      it "returns the ID placeholder" do
        expect(subject.public_send(method_name)).to eq(options[:default_id])
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-dev-0.29.1 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.4 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.29.0 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.3 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.29.0.rc4 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.29.0.rc3 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.29.0.rc2 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.29.0.rc1 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.2 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.1 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.0 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.0.rc5 lib/decidim/dev/test/form_to_param_shared_examples.rb
decidim-dev-0.28.0.rc4 lib/decidim/dev/test/form_to_param_shared_examples.rb