Sha256: 56245d99090f66da8329193b24727bf38caa455e85428ff3c0d1cfb3121c1f76

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'extra_core/string_transformation_test_cases'
require 'volt/extra_core/string'

describe '#camelize' do
  CamelToUnderscore.each do |camel, underscore|
    it 'camelizes' do
      expect(underscore.camelize).to eq(camel)
    end
  end

  it 'camelizes lower' do
    expect('capital_city'.camelize(:lower)).to eq('capitalCity')
  end

  it 'camelizes upper' do
    expect('capital_city'.camelize(:upper)).to eq('CapitalCity')
  end

  it 'camelizes upper default' do
    expect('capital_city'.camelize).to eq('CapitalCity')
  end

  UnderscoreToLowerCamel.each do |underscored, lower_camel|
    it 'camelizes lower' do
      expect(underscored.camelize(:lower)).to eq(lower_camel)
    end
  end

  UnderscoresToDashes.each do |underscored, dasherized|
    it 'dasherizes' do
      expect(underscored.dasherize).to eq(dasherized)
    end
  end

  CamelToUnderscore.each do |camel, underscore|
    it 'underscores' do
      expect(camel.underscore).to eq(underscore)
    end
  end

  it 'underscores acronyms' do
    expect('HTMLTidy'.underscore).to eq('html_tidy')
    expect('HTMLTidyGenerator'.underscore).to eq('html_tidy_generator')
  end
end

describe '#headerize' do
  it "headerizes" do
    expect('test_case'.headerize).to eq('Test-Case')
  end

  UnderscoresToHeaders.each do |underscored, headerized|
    it 'underscores' do
      expect(underscored.headerize).to eq(headerized)
    end
  end  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
volt-0.9.1 spec/extra_core/string_transformations_spec.rb
volt-0.9.1.pre5 spec/extra_core/string_transformations_spec.rb
volt-0.9.1.pre4 spec/extra_core/string_transformations_spec.rb
volt-0.9.1.pre3 spec/extra_core/string_transformations_spec.rb
volt-0.9.1.pre2 spec/extra_core/string_transformations_spec.rb
volt-0.9.1.pre1 spec/extra_core/string_transformations_spec.rb
volt-0.9.0 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre7 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre6 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre5 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre4 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre3 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre2 spec/extra_core/string_transformations_spec.rb
volt-0.9.0.pre1 spec/extra_core/string_transformations_spec.rb
volt-0.8.27.beta9 spec/extra_core/string_transformations_spec.rb
volt-0.8.27.beta8 spec/extra_core/string_transformations_spec.rb
volt-0.8.27.beta7 spec/extra_core/string_transformations_spec.rb