diff --git a/lib/dough/html_options.rb b/lib/dough/html_options.rb index 50f6bd4d..5228102e 100644 --- a/lib/dough/html_options.rb +++ b/lib/dough/html_options.rb @@ -11,6 +11,10 @@ def method_missing(m, *args, &block) super end + def classes + self[:classes] ||= '' + end + def to_s hash = table.dup hash[:class] = hash.delete(:classes) diff --git a/spec/lib/dough/html_options_spec.rb b/spec/lib/dough/html_options_spec.rb index 593067a3..5097c3c6 100644 --- a/spec/lib/dough/html_options_spec.rb +++ b/spec/lib/dough/html_options_spec.rb @@ -1,6 +1,12 @@ require 'spec_helper' describe Dough::HtmlOptions do + describe '#classes' do + it 'defaults to an empty string' do + expect(described_class.new.classes).to eq('') + end + end + describe 'to_s' do subject { described_class.new(id: 'a', classes: 'b c') }