Sha256: a53ed561b47d41fd0a233870ced30dab8aaeb74d1010169adfe2ad30aa649894

Contents?: true

Size: 1008 Bytes

Versions: 2

Compression:

Stored size: 1008 Bytes

Contents

require 'spec_helper'
class DummyModelPresenter < BasePresenter
  presents :dummy
  delegate :id, to: :dummy

  def name
    dummy.name.upcase
  end

  def self.name
    "Class name"
  end
end

describe ApplicationHelper do
  let(:dummy_model) { DummyModel.new }

  let(:template) { ActionView::Base.new }

  let(:dummy_presenter) { DummyModelPresenter.new(dummy_model, template) }

  describe "without block" do

    it "#presents" do
      dummy_presenter.dummy.should eq dummy_model
    end

    it "should show formated name" do
      dummy_presenter.name.should eq("EXAMPLE NAME")
    end

    it "should show id of dummy using delegation" do
      dummy_presenter.id.should eq(123)
    end

    it "#handle_none with not blank of value" do
      value = "no empty"
      dummy_presenter.handle_none(value) {value}.should eq(value)
    end

    it "#handle_none with not blank of value" do
      value = nil
      dummy_presenter.handle_none(value) {value}.should match('<span class')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
base_presenter-0.0.9 spec/presenters/base_presenter_spec.rb
base_presenter-0.0.8 spec/presenters/base_presenter_spec.rb