Sha256: 68d1d9199817d06f50acbebd7846a2dc7fed192b59866d60215a5cbbe699ab99

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

require 'rspec_ext'
require "#{__FILE__.dirname}/with_controller_ext"

require 'crystal_ext/user_error'
require 'with_controller_ext'

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.5 spec/user_error_spec.rb