# typed: false

RSpec::Matchers.define :eq_link_for_source do |model:, title:|
  match do |actual_url|
    actual = helper.link_for_source(actual_url)
    expect(actual).to be_a(Domain::PostsHelper::LinkForSource)
    expect(actual.model).to eq(model)
    expect(actual.title).to eq(title)
  end

  failure_message do |actual_url|
    actual = helper.link_for_source(actual_url)
    if actual.nil?
      binding.pry
      "link for source was nil for url #{actual_url}"
    elsif actual.model != model
      "expected model #{model.to_gid.uri.to_s} to be #{actual.model.to_gid.uri.to_s} for url #{actual_url}"
    elsif actual.title != title
      "expected title #{title} to be #{actual.title} for url #{actual_url}"
    else
      "unknown failure"
    end
  end
end
