Sha256: 6b5674df50b3dc595e83eda2d749640df5692876921b60561f0b580645fc36b1

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

require 'test_helper'

Cell::Concept.class_eval do
  self.view_paths = ['test/fixtures/concepts']
end

# Trailblazer style:
module Record
  class Cell < Cell::Concept # cell("record")
    self.template_engine = "erb"

    def show
      render # Party On, #{model}
    end

    # cell(:song, concept: :record)
    class Song < self # cell("record/cell/song")
      def show
        render :view => :song#, :layout => "layout"
        # TODO: test layout: .. in ViewModel
      end
    end

    class Hit < ::Cell::Concept
      inherit_views Record::Cell
    end
  end
end

# app/cells/comment/views
# app/cells/comment/form/views
# app/cells/comment/views/form inherit_views Comment::Cell, render form/show


class ConceptTest < MiniTest::Spec
  describe "::controller_path" do
    it { Record::Cell.new(@controller).controller_path.must_equal "record" }
    it { Record::Cell::Song.new(@controller).controller_path.must_equal "record/song" }
  end


  describe "#_prefixes" do
    it { Record::Cell.new(@controller)._prefixes.must_equal       ["test/fixtures/concepts/record/views"] }
    it { Record::Cell::Song.new(@controller)._prefixes.must_equal ["test/fixtures/concepts/record/song/views", "test/fixtures/concepts/record/views"] }
    it { Record::Cell::Hit.new(@controller)._prefixes.must_equal  ["test/fixtures/concepts/record/hit/views", "test/fixtures/concepts/record/views"]  } # with inherit_views.
  end

  it { Record::Cell.new(@controller, "Wayne").call(:show).must_equal "Party on, Wayne!" }


  describe "#cell" do
    it { Cell::Concept.cell("record/cell", @controller).must_be_instance_of(      Record::Cell) }
    it { Cell::Concept.cell("record/cell/song", @controller).must_be_instance_of  Record::Cell::Song }
    # cell("song", concept: "record/compilation") # record/compilation/cell/song
  end

  describe "#render" do
    it { Cell::Concept.cell("record/cell/song", @controller).show.must_equal "Lalala" }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cells-4.0.0.beta4 test/concept_test.rb