Sha256: a5aa81eaa45377b4fdd1b6533f01b86b8f4d64e9fc8a23931bcd77e2b9a442bf

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'

class Base
  def true?
    true
  end

  def false?
    false
  end
end
class BasePresenter < Marilyne::Presenter;end;

class MarilyneTest < ActiveSupport::TestCase
  include Marilyne::Helper

  def render(options)
    options
  end

  test "presenter_for without option" do
    options = presenter_for 'base'

    assert_equal options[:partial], 'base'
    assert options[:object].is_a? BasePresenter
  end

  test "presenter_for with object" do
    options = presenter_for 'base', object: Base.new

    assert_equal options[:partial], 'base'
    assert options[:object].is_a? BasePresenter
  end

  test "presenter_for with multiple objects" do
    options = presenter_for 'base', objects: [Base.new, Base.new]

    assert_equal options[:partial], 'base'
    assert options[:object].is_a? BasePresenter
    assert_equal options[:object].objects.length, 2
  end

  test "presenter_for with block at true" do
    options = presenter_for('base', object: Base.new) { |b| b.true? }

    assert_equal options[:partial], 'base'
    assert options[:object].is_a? BasePresenter
  end

  test "presenter_for with block at false" do
    options = presenter_for('base', object: Base.new) { |b| b.false? }

    assert_nil options
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
marilyne-1.1.0 test/marilyne_test.rb
marilyne-1.0.1 test/marilyne_test.rb