Skip to content

Commit

Permalink
Workaround odd OpenStruct issue
Browse files Browse the repository at this point in the history
Due to differences in Ruby 2.7/3.0 The field isn't correctly initialised
otherwise.
  • Loading branch information
benlovell committed Feb 22, 2024
1 parent 13a9483 commit d59e150
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/dough/html_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/dough/html_options_spec.rb
Original file line number Diff line number Diff line change
@@ -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') }

Expand Down

0 comments on commit d59e150

Please sign in to comment.