Sha256: 0a60e3b4abf7ff21e67d8075b720427fdf8cacf3e5ac1a95aa8a084166dc9448

Contents?: true

Size: 737 Bytes

Versions: 12

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

require "hanami/router"
require "hanami/extensions/router/errors"

RSpec.describe(Hanami::Router::NotAllowedError) do
  subject(:error) { described_class.new(env, allowed_methods) }

  let(:env) { Rack::MockRequest.env_for("http://example.com/example", method: "POST") }
  let(:allowed_methods) { ["GET", "HEAD"] }

  it "is a Hanami::Router::Error" do
    expect(error.class).to be < Hanami::Router::Error
  end

  it "returns a relevant message" do
    expect(error.to_s).to eq "Only GET, HEAD requests are allowed at /example"
  end

  it "returns the env" do
    expect(error.env).to be env
  end

  it "returns the allowed methods" do
    expect(error.allowed_methods).to be allowed_methods
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.2.0 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.2.0.rc1 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.2.0.beta2 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.2.0.beta1 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0.rc3 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0.rc2 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0.rc1 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0.beta2.1 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0.beta2 spec/unit/hanami/router/errors/not_allowed_error_spec.rb
hanami-2.1.0.beta1 spec/unit/hanami/router/errors/not_allowed_error_spec.rb