Sha256: d922c3480f156191cf2c78153c9707d32e41dd5cfd5ebb8fb9b66266fc89b02b

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

require "controller_spec_helper"

require 'crystal_ext/user_error'

describe "User Error" do
  with_environment :test
  with_controller_ext_spec
  
  # before :all do
  #   crystal[:config].environment = :test
  #   crystal[:environment] = Crystal::Environment.new
  #   crystal[:environment].load :controller_ext_spec
  # end
  
  after :all do
    # Micon.clear
    remove_constants %w(UserErrorSpec)
  end
  
  it "user error" do
    class ::UserErrorSpec
      inherit Crystal::HttpController
      
      def call
        raise_user_error "some error"
      end      
      
      protected
        def catch_user_error
          begin
            yield
          rescue UserError => ue
            render :inline => "Catched #{ue.message}"
          end
        end
        around :catch_user_error
    end
    
    ccall(UserErrorSpec, :call).content.should == "Catched some error"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crystal_ext-0.0.7 spec/user_error_spec.rb