Sha256: b345b6b966ff4ea5af391a2f2f3663c9b91260b432665c167d985ed57bfa13bc

Contents?: true

Size: 722 Bytes

Versions: 21

Compression:

Stored size: 722 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

21 entries across 21 versions & 1 rubygems

Version Path
kadmin-0.6.19 lib/kadmin/presenter/test_case.rb
kadmin-0.6.18 lib/kadmin/presenter/test_case.rb
kadmin-0.6.17 lib/kadmin/presenter/test_case.rb
kadmin-0.6.16 lib/kadmin/presenter/test_case.rb
kadmin-0.6.13 lib/kadmin/presenter/test_case.rb
kadmin-0.6.12 lib/kadmin/presenter/test_case.rb
kadmin-0.6.11 lib/kadmin/presenter/test_case.rb
kadmin-0.6.10 lib/kadmin/presenter/test_case.rb
kadmin-0.6.9 lib/kadmin/presenter/test_case.rb
kadmin-0.6.8 lib/kadmin/presenter/test_case.rb
kadmin-0.6.7 lib/kadmin/presenter/test_case.rb
kadmin-0.6.6 lib/kadmin/presenter/test_case.rb
kadmin-0.6.5 lib/kadmin/presenter/test_case.rb
kadmin-0.6.4 lib/kadmin/presenter/test_case.rb
kadmin-0.6.3 lib/kadmin/presenter/test_case.rb
kadmin-0.6.1 lib/kadmin/presenter/test_case.rb
kadmin-0.5.7 lib/kadmin/presenter/test_case.rb
kadmin-0.5.6 lib/kadmin/presenter/test_case.rb
kadmin-0.4.2 lib/kadmin/presenter/test_case.rb
kadmin-0.4.1 lib/kadmin/presenter/test_case.rb