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-1.3.0 lib/kadmin/presenter/test_case.rb
kadmin-1.2.1 lib/kadmin/presenter/test_case.rb
kadmin-1.2.0 lib/kadmin/presenter/test_case.rb
kadmin-1.1.1 lib/kadmin/presenter/test_case.rb
kadmin-1.1.0 lib/kadmin/presenter/test_case.rb
kadmin-1.0.9 lib/kadmin/presenter/test_case.rb
kadmin-1.0.8 lib/kadmin/presenter/test_case.rb
kadmin-1.0.7 lib/kadmin/presenter/test_case.rb
kadmin-1.0.6 lib/kadmin/presenter/test_case.rb
kadmin-1.0.5 lib/kadmin/presenter/test_case.rb
kadmin-1.0.4 lib/kadmin/presenter/test_case.rb
kadmin-1.0.3 lib/kadmin/presenter/test_case.rb
kadmin-1.0.2 lib/kadmin/presenter/test_case.rb
kadmin-1.0.1 lib/kadmin/presenter/test_case.rb
kadmin-1.0.0 lib/kadmin/presenter/test_case.rb
kadmin-0.9.5 lib/kadmin/presenter/test_case.rb
kadmin-0.9.4 lib/kadmin/presenter/test_case.rb
kadmin-0.8.0 lib/kadmin/presenter/test_case.rb
kadmin-0.7.5 lib/kadmin/presenter/test_case.rb
kadmin-0.7.4 lib/kadmin/presenter/test_case.rb