Sha256: fd20a3ef48fd873e3a2341dbac52b9f800a9a14a5b474c33d46930e3269da85c

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

RSpec.describe Rails::Auth::ACL do
  let(:example_config) { fixture_path("example_acl.yml").read }

  let(:example_acl) do
    described_class.from_yaml(
      example_config,
      matchers: {
        allow_x509_subject: Rails::Auth::X509::Matcher,
        allow_claims:       ClaimsMatcher
      }
    )
  end

  describe "#initialize" do
    it "raises TypeError if given a non-Array ACL type" do
      expect { described_class.new(:bogus) }.to raise_error(TypeError)
    end
  end

  describe "#match" do
    it "matches routes against the ACL" do
      expect(example_acl.match(env_for(:get, "/"))).to eq true
      expect(example_acl.match(env_for(:get, "/foo/bar/baz"))).to eq true
      expect(example_acl.match(env_for(:get, "/_admin"))).to eq false
    end
  end

  describe "#matching_resources" do
    it "finds Rails::Auth::ACL::Resource objects that match the request" do
      resources = example_acl.matching_resources(env_for(:get, "/foo/bar/baz"))
      expect(resources.first.path).to eq %r{\A/foo/bar/.*\z}
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails-auth-1.3.0 spec/rails/auth/acl_spec.rb
rails-auth-1.2.0 spec/rails/auth/acl_spec.rb
rails-auth-1.1.0 spec/rails/auth/acl_spec.rb
rails-auth-1.0.0 spec/rails/auth/acl_spec.rb
rails-auth-0.5.3 spec/rails/auth/acl_spec.rb
rails-auth-0.5.2 spec/rails/auth/acl_spec.rb
rails-auth-0.5.1 spec/rails/auth/acl_spec.rb
rails-auth-0.5.0 spec/rails/auth/acl_spec.rb
rails-auth-0.4.1 spec/rails/auth/acl_spec.rb