Sha256: a0ee765a8480e49959e6c54b2032acd786ed9edb22c07a12fa38bacc72034f11

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'

class Base
  def true?
    true
  end

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

class MarilynTest < ActiveSupport::TestCase
  include Marilyn::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

1 entries across 1 versions & 1 rubygems

Version Path
marilyne-1.0.0 test/marilyn_test.rb