Class: Kadmin::Presenter::TestCase

Inherits:
ActionView::TestCase
  • Object
show all
Defined in:
lib/kadmin/presenter/test_case.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#present(presentable) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kadmin/presenter/test_case.rb', line 9

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