Skip to content

Instantly share code, notes, and snippets.

@jaredbeck
Last active January 7, 2022 04:38
Show Gist options
  • Save jaredbeck/8e65388a1389c989b5594195a7dfe66a to your computer and use it in GitHub Desktop.
Save jaredbeck/8e65388a1389c989b5594195a7dfe66a to your computer and use it in GitHub Desktop.
require 'active_support/all'
require 'minitest/autorun'
require 'zeitwerk'
class ASITest < Minitest::Test
module CodeInflector
extend ActiveSupport::Inflector
def self.inflections
i = ActiveSupport::Inflector::Inflections.new
i.acronym 'SSN'
i
end
end
def test_camelize
{
'create_wombats' => 'CreateWombats', # passes
'create_ssn' => 'CreateSSN', # passes
'create_ssns' => 'CreateSSNs' # fails with "CreateSsns"
}.each do |k, v|
assert_equal v, CodeInflector.camelize(k)
end
end
end
class ZeitTest < Minitest::Test
def test_camelize
i = Zeitwerk::Inflector.new
{
'create_wombats' => 'CreateWombats',
'create_ssns' => 'CreateSSNs'
}.each do |k, v|
i.inflect(k => v)
assert_equal v, i.camelize(k, '/dev/null')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment