Sha256: cbf82012a32aadda56ce9e097c2b6414be4e05b0a97cdc92b0319eaa50485c2f

Contents?: true

Size: 883 Bytes

Versions: 5

Compression:

Stored size: 883 Bytes

Contents

# 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

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/representable-3.2.0/test/option_test.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/representable-3.2.0/test/option_test.rb
representable-3.2.0 test/option_test.rb
representable-3.1.1 test/option_test.rb
representable-3.1.0 test/option_test.rb