Sha256: 434b73f00e927bbdcaae2281da26dc1b85b8c81dc44546a97affb0b128bd8113

Contents?: true

Size: 767 Bytes

Versions: 3

Compression:

Stored size: 767 Bytes

Contents

require_relative '../spec_helper'

require 'wright/util/stolen_from_activesupport'

include Wright

describe Util::ActiveSupport do
  it 'should camelize underscored words' do
    Util::ActiveSupport.camelize('foo_bar').must_equal 'FooBar'
  end

  it 'should underscore CamelCase words' do
    Util::ActiveSupport.underscore('FooBar').must_equal 'foo_bar'
    Util::ActiveSupport.underscore('FooBar::Baz').must_equal 'foo_bar/baz'
  end

  it 'should find constants with a given name' do
    nonexistent = 'ThisConstant::DoesNotExist'

    Util::ActiveSupport.constantize('Wright::Util').must_equal Wright::Util
    -> { Util::ActiveSupport.constantize(nonexistent) }.must_raise(NameError)
    Util::ActiveSupport.safe_constantize(nonexistent).must_be_nil
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wright-0.1.2 spec/util/activesupport_spec.rb
wright-0.1.1 spec/util/activesupport_spec.rb
wright-0.1.0 spec/util/activesupport_spec.rb