Sha256: 9aba7ca00949c7338fa29a2d0206d2c955e535d094204475886aa113db588576

Contents?: true

Size: 729 Bytes

Versions: 10

Compression:

Stored size: 729 Bytes

Contents

class ObjectSupportTest < ActiveSupport::TestCase
  
  test "ensure that symbols stay symbols" do
    assert_same :sym, :sym.to_enum_sym
  end
  
  test "ensure that strings are just converted to symbols, whatever they look like" do
    assert_same :sym, 'sym'.to_enum_sym
    assert_same :OtherSym, 'OtherSym'.to_enum_sym
  end
  
  test "convert custom class to symbol, by providing attr_accessor :name" do
    has_name = Class.new do
      attr_accessor :name
    end
    
    named = has_name.new
    named.name = 'sym'
    
    assert_same :sym, named.to_enum_sym
    
    another_named = has_name.new
    another_named.name = 'Contains Spaces?'
        
    assert_same :contains_spaces, another_named.to_enum_sym
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
lwe-simple_enum-0.3.0 test/object_support_test.rb
simple_enum-1.3.2 test/object_support_test.rb
simple_enum-1.3.1 test/object_support_test.rb
simple_enum-1.3.0 test/object_support_test.rb
simple_enum-1.2.0 test/object_support_test.rb
simple_enum-1.1.0 test/object_support_test.rb
simple_enum-1.0.1 test/object_support_test.rb
simple_enum-1.0.0 test/object_support_test.rb
simple_enum-0.9.0 test/object_support_test.rb
simple_enum-0.3.0 test/object_support_test.rb