Module: Oprah::TestHelpers

Defined in:
lib/oprah/test_helpers.rb

Overview

Test helpers that can be included into `Minitest::Test` or `ActiveSupport::TestCase`.

Since:

  • 0.1.2

Instance Method Summary collapse

Instance Method Details

#assert_presented(object) ⇒ Boolean

Fails unless `object` is a presenter.

Parameters:

  • object (Object)

    The object to be tested

Returns:

  • (Boolean)

Since:

  • 0.1.3


26
27
28
29
30
31
32
# File 'lib/oprah/test_helpers.rb', line 26

def assert_presented(object)
  msg = message(msg) do
    "Expected #{mu_pp(object)} to be an Oprah::Presenter"
  end

  assert object.kind_of?(Oprah::Presenter), msg
end

#present(*args, **kwargs, &block) ⇒ Object

Presents a single object.

See Also:

Since:

  • 0.1.2


17
18
19
# File 'lib/oprah/test_helpers.rb', line 17

def present(*args, **kwargs, &block)
  Presenter.present(*args, **kwargs, &block)
end

#present_many(*args, **kwargs, &block) ⇒ Object

Presents a collection of objects.

See Also:

Since:

  • 0.1.2


10
11
12
# File 'lib/oprah/test_helpers.rb', line 10

def present_many(*args, **kwargs, &block)
  Presenter.present_many(*args, **kwargs, &block)
end

#refute_presented(object) ⇒ Boolean

Fails if `object` is a presenter.

Parameters:

  • object (Object)

    The object to be tested

Returns:

  • (Boolean)

Since:

  • 0.1.3


39
40
41
42
43
44
45
# File 'lib/oprah/test_helpers.rb', line 39

def refute_presented(object)
  msg = message(msg) do
    "Expected #{mu_pp(object)} to not be an Oprah::Presenter"
  end

  refute object.kind_of?(Oprah::Presenter), msg
end