Sha256: ffc902abcc9d12123826397451cee0bfff00f4f52cda5c0e6e4c077549e3a546

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

RSpec.describe Rails::Auth::RSpec::HelperMethods, acl_spec: true do
  let(:example_cn) { "127.0.0.1" }
  let(:example_ou) { "ponycopter" }

  describe "#x509_certificate" do
    subject { x509_certificate(cn: example_cn, ou: example_ou) }

    it "creates instance doubles for Rails::Auth::X509::Certificates" do
      # Method syntax
      expect(subject.cn).to eq example_cn
      expect(subject.ou).to eq example_ou

      # Hash-like syntax
      expect(subject[:cn]).to eq example_cn
      expect(subject[:ou]).to eq example_ou
    end
  end

  describe "#x509_certificate_hash" do
    subject { x509_certificate_hash(cn: example_cn, ou: example_ou) }

    it "creates a certificate hash with an Rails::Auth::X509::Certificate double" do
      expect(subject["x509"].cn).to eq example_cn
    end
  end

  Rails::Auth::ACL::Resource::HTTP_METHODS.each do |method|
    describe "##{method.downcase}_request" do
      it "returns a Rack environment" do
        # These methods introspect self.class.description to find the path
        allow(self.class).to receive(:description).and_return("/")
        env = method("#{method.downcase}_request").call

        expect(env["REQUEST_METHOD"]).to eq method
      end

      it "raises ArgumentError if the description doesn't start with /" do
        expect { method("#{method.downcase}_request").call }.to raise_error(ArgumentError)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails-auth-1.3.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-1.2.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-1.1.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-1.0.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.5.3 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.5.2 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.5.1 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.5.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.4.1 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.4.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.3.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.2.0 spec/rails/auth/rspec/helper_methods_spec.rb
rails-auth-0.1.0 spec/rails/auth/rspec/helper_methods_spec.rb