Skip to content

Instantly share code, notes, and snippets.

@jaredbeck
Last active January 7, 2022 04:38
Show Gist options
  • Select an option

  • Save jaredbeck/8e65388a1389c989b5594195a7dfe66a to your computer and use it in GitHub Desktop.

Select an option

Save jaredbeck/8e65388a1389c989b5594195a7dfe66a to your computer and use it in GitHub Desktop.

Revisions

  1. jaredbeck revised this gist Jan 7, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion rails_issue_44075_code_inflection.rb
    Original file line number Diff line number Diff line change
    @@ -6,15 +6,17 @@ class ASITest < Minitest::Test
    module CodeInflector
    extend ActiveSupport::Inflector

    def inflections
    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)
  2. jaredbeck revised this gist Jan 7, 2022. 1 changed file with 21 additions and 7 deletions.
    28 changes: 21 additions & 7 deletions rails_issue_44075_code_inflection.rb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,17 @@
    require 'active_support/all'
    require 'minitest/autorun'
    require 'zeitwerk'

    module CodeInflector
    extend ActiveSupport::Inflector
    class ASITest < Minitest::Test
    module CodeInflector
    extend ActiveSupport::Inflector

    def inflections
    i = ActiveSupport::Inflector::Inflections.new
    i.acronym 'SSN'
    def inflections
    i = ActiveSupport::Inflector::Inflections.new
    i.acronym 'SSN'
    end
    end
    end

    class MyTest < Minitest::Test
    def test_camelize
    {
    'create_wombats' => 'CreateWombats', # passes
    @@ -20,3 +21,16 @@ def test_camelize
    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
  3. jaredbeck created this gist Jan 7, 2022.
    22 changes: 22 additions & 0 deletions rails_issue_44075_code_inflection.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    require 'active_support/all'
    require 'minitest/autorun'

    module CodeInflector
    extend ActiveSupport::Inflector

    def inflections
    i = ActiveSupport::Inflector::Inflections.new
    i.acronym 'SSN'
    end
    end

    class MyTest < Minitest::Test
    def test_camelize
    {
    'create_wombats' => 'CreateWombats', # passes
    'create_ssns' => 'CreateSSNs' # fails with "CreateSsns"
    }.each do |k, v|
    assert_equal v, CodeInflector.camelize(k)
    end
    end
    end