1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
# frozen_string_literal: true
require 'test_helper'
class OptionTest < Minitest::Spec
class Callable
include Uber::Callable
def call(*); "callable" end
end
class MyRepresenter < Representable::Decorator
include Representable::JSON
property :static, getter: "static"
property :symbol, getter: :symbol
property :proc, getter: ->(*) { "proc" }
property :callable, getter: Callable.new
end
Album = Struct.new(:static) do
def symbol(*); "symbol" end
end
let(:album_representer) { MyRepresenter.new(Album.new) }
describe ::Representable::Option do
it "supports all types of callables (method, proc, static etc)" do
_(album_representer.to_hash).must_equal({
"static" => "static",
"symbol" => "symbol",
"proc" => "proc",
"callable" => "callable",
})
end
end
end
|