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