Sha256: 4b017e437ebb2501ff1c8f2b3fe69dc7da68d7c45ca3cca08aad9a3956226547

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

# Used in rspec-cells, etc.
module Cell
  module Testing
    def cell(name, *args)
      ViewModel.cell_for(name, controller, *args)
    end

    def concept(name, *args)
      Concept.cell_for(name, controller, *args)
    end



    # Rails specific.
    def controller
      # TODO: test without controller.
      return unless self.class.controller_class

      # TODO: test with controller.
      self.class.controller_class.new.tap do |ctl|
        ctl.request = ActionController::TestRequest.new
        ctl.instance_variable_set :@routes, Rails.application.routes.url_helpers
      end
    end

    def self.included(base)
      base.class_eval do
        extend Uber::InheritableAttr
        inheritable_attr :controller_class

        def self.controller(name)
          self.controller_class = name
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cells-4.0.0.beta2 lib/cell/testing.rb