Thursday, June 04, 2026 1:46:17 AM
> test_join_map.rb
# frozen_string_literal: true

require "test_helper"

class TestOstructJoinMap < Minitest::Test
  def setup
    @input = OpenStruct.new(
      a: 1,
      b: nil,
      c: 2,
      d: nil,
      e: 3
    )
  end

  def test_it_joins_without_block
    assert_equal(
      "a 1 b c 2 d e 3",
      @input.join_map(" ")
    )
  end

  def test_it_joins_with_block
    assert_equal(
      "a-1, c-2, e-3",
      @input.join_map(", ") { |k, v| "#{k}-#{v}" if v }
    )
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 4294fb2