Sha256: 0f3c01372e3bdc9d935ecef4685aaabc5c7e3ded662998c15aeac0a7dc7ca30b
Contents?: true
Size: 853 Bytes
Versions: 4
Compression:
Stored size: 853 Bytes
Contents
require 'spec_helper' describe Formulaic::Label do it 'returns the string if there are no translations and it can not human_attribute_name the class' do expect(label(nil, 'My label')).to eq 'My label' end it 'returns human_attribute_name if available' do expect(label(:user, :attribute)).to eq 'Human Attribute Name' end it 'uses a translation if available' do I18n.backend.store_translations(:en, { simple_form: { labels: { user: { name: 'Translated' } } } } ) expect(label(:user, :name)).to eq('Translated') end it 'should leave cases alone' do expect(label(:user, 'Work URL')).to eq 'Work URL' end def label(model_name, attribute, action = :create) Formulaic::Label.new(model_name, attribute, action).to_str end end class User def self.human_attribute_name(*) 'Human Attribute Name' end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
formulaic-0.0.6 | spec/formulaic/label_spec.rb |
formulaic-0.0.5 | spec/formulaic/label_spec.rb |
formulaic-0.0.4 | spec/formulaic/label_spec.rb |
formulaic-0.0.3 | spec/formulaic/label_spec.rb |