Sha256: 2f9021ccd4da89285492b788febd4af5023eda47d1eeaf2d7b214392686c970d

Contents?: true

Size: 723 Bytes

Versions: 25

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

module Kadmin
  class Presenter
    # Test class for Presenters. While this will not be common, it highlights how much
    # easier presenters are to test.
    # TODO: When a use case presents itself, modify to handle JSON or other outputs that are not HTML.
    class TestCase < ActionView::TestCase
      def present(presentable)
        renderable = case presentable
        when Kadmin::Presenter
          presentable
        when Kadmin::Presentable
          presentable.present
        end

        raise ArgumentError, "don't know how to render #{presentable}" if renderable.nil?
        @rendered = renderable.render(view: self)
        return @rendered
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
kadmin-0.7.3 lib/kadmin/presenter/test_case.rb
kadmin-0.7.2 lib/kadmin/presenter/test_case.rb
kadmin-0.7.1 lib/kadmin/presenter/test_case.rb
kadmin-0.7.0 lib/kadmin/presenter/test_case.rb
kadmin-0.6.21 lib/kadmin/presenter/test_case.rb