Sha256: 138c1bb93c252ef7bfbcef0b5d49d732af2580d87c8ea0d5ef7ab54f33e505b8

Contents?: true

Size: 875 Bytes

Versions: 16

Compression:

Stored size: 875 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Hyperdrive::Middleware::Error do
  before do
    get '/'
  end

  context "Known Error" do
    def app
      Rack::Builder.new do
        use Hyperdrive::Middleware::Error
        run ->(env) { raise Hyperdrive::Errors::MethodNotAllowed.new('GET') }
      end
    end

    it "traps errors" do
      last_response.status.must_equal 405
    end

    it "returns a formatted error message" do
      last_response.body.must_match(/error/)
    end
  end

  context "Unknown Error" do
    def app
      Rack::Builder.new do
        use Hyperdrive::Middleware::Error
        run ->(env) { raise 'Woah there, fella!' }
      end
    end

    it "traps errors" do
      last_response.status.must_equal 500
    end

    it "returns a formatted error message" do
      last_response.body.must_match(/Unknown Error/)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hyperdrive-0.0.23 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.22 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.21 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.20 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.19 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.18 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.17 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.16 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.15 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.14 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.13 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.12 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.11 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.10 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.9 spec/hyperdrive/middleware/error_spec.rb
hyperdrive-0.0.8 spec/hyperdrive/middleware/error_spec.rb