Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/product.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'forwardable'

class Product
attr_reader :name, :category, :tags

Expand All @@ -6,6 +8,16 @@ def initialize(name, category, tags = [])
@category = category
@tags = tags
end
end

class ProductDecorator
extend Forwardable

def_delegators :@context, :name, :category, :tags

def initialize(context)
@context = context
end

def as_html_row
<<~EOF
Expand Down
2 changes: 1 addition & 1 deletion spec/anything_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
end

it 'can be printed as HTML table row' do
expect(tomato.as_html_row).to eq(expected_result)
expect(ProductDecorator.new(tomato).as_html_row).to eq(expected_result)
end
end