Sha256: 14a7c097b22192e27e5bc6b93989194e497051b640f4d15700355081ba9013fc

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

require_relative '../../test_helper'

DuckPuncher.(String)

class StringTest < MiniTest::Test
  def test_pluralize
    assert_equal 'hour', 'hour'.pluralize(1)
    assert_equal 'hours', 'hour'.pluralize(0)
    assert_equal 'hours', 'hour'.pluralize(2)
  end

  def test_underscore
    assert_equal 'mini_test', 'MiniTest'.underscore
    assert_equal 'mini_test_do_it_to_it', 'MiniTestDoItToIt'.underscore
    assert_equal 'mini_test/helper', 'MiniTest::Helper'.underscore
    assert_equal 'mini_test/helper/expectations', 'MiniTest::Helper::Expectations'.underscore
    assert_equal 'mini_test.rb', 'mini_test.rb'.underscore
    assert_equal 'duck_puncher/json_storage', 'DuckPuncher::JSONStorage'.underscore
  end

  def test_to_boolean
    assert 'true'.to_boolean
    assert '1'.to_boolean
    assert 'y'.to_boolean
    assert 'on'.to_boolean
    assert 'yes'.to_boolean
    refute 'false'.to_boolean
    refute '0'.to_boolean
    refute 'no'.to_boolean
    refute 'off'.to_boolean
    refute ''.to_boolean
    refute 'f'.to_boolean
  end

  def test_constantize
    assert_equal MiniTest, 'MiniTest'.constantize
    assert_equal MiniTest::Test, 'MiniTest::Test'.constantize
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
duck_puncher-4.5.1 test/lib/duck_puncher/string_test.rb
duck_puncher-4.5.0 test/lib/duck_puncher/string_test.rb
duck_puncher-4.4.2 test/lib/duck_puncher/string_test.rb
duck_puncher-4.4.1 test/lib/duck_puncher/string_test.rb
duck_puncher-4.4.0 test/lib/duck_puncher/string_test.rb
duck_puncher-4.3.1 test/lib/duck_puncher/string_test.rb
duck_puncher-4.3.0 test/lib/duck_puncher/string_test.rb