# encoding: utf-8 # require 'spec_helper' describe Mode::Sdk::WarehouseUtil do let :util do Object.new.extend(Mode::Sdk::WarehouseUtil) end describe '#normalize_name' do it 'preserves short name' do expect(util.normalize_name('foo_bar')).to eq('foo_bar') end it 'truncates long name' do expect(util.normalize_name('a' * 100).size).to eq(64) end end describe '#normalize_string' do it 'preserves simple strings' do %w(foo foo_bar foo_bar_baz).each do |string| expect(util.send(:normalize_string, string)).to eq(string) end end it 'normalizes messy strings' do expected = { ' fOO_' => 'foo', '_ foo___' => 'foo', 'fo*(*o__BaR ! ?' => 'foo_bar', 'fo__o- _!bar_b _ - az ' => 'fo_o_bar_b_az' } expected.each do |input, output| expect(util.send(:normalize_string, input)).to eq(output) end end end end