Sha256: f1361ca6684d004c76cd9cd4c8c2297b4f1523661e3aafa53980933279ed8fda

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'rad/spec/environment'

rspec do
  attr_accessor :response, :workspace

  def self.with_controller
    before :each do
      self.response = nil
    end
  end
  
  def ccall klass, method, params = {}, workspace_variables = {}, &block
    self.response = Rad::Response.new
    workspace_variables = {
      class: klass, method_name: method, params: Rad::Params.new(params), response: response
    }.merge(workspace_variables)
    
    if block            
      rad.conveyors.web.call workspace_variables do |c|
        self.workspace = rad.workspace
                
        block.call c
      end
    else                  
      self.workspace = rad.conveyors.web.call workspace_variables
    end
    
    if Rad.const_defined?(:HttpController) and klass and klass.is?(::Rad::HttpController)
      response.content_type.must_be.present
      response.status.must_be.present
    end
    
    workspace.content
  end
end

Rad::AbstractController.class_eval do
  def render_ok
    render inline: 'ok'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rad_core-0.0.13 lib/rad/spec/controller.rb