Thursday, June 04, 2026 1:47:39 AM
> test_each.rb
# frozen_string_literal: true

require "test_helper"

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

  def test_without_block
    assert_kind_of(Enumerator, @input.each)
  end

  def test_with_block
    output = []

    @input.each { |k, v| output << [k, v] if v }

    assert_equal([[:a, 1], [:c, 2]], output)
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 4294fb2