Sha256: 41e2af5238efca14c6e9490e9b00552c01b0d1d48026ddfc7079232181c9b2bd
Contents?: true
Size: 1.13 KB
Versions: 8
Compression:
Stored size: 1.13 KB
Contents
RSpec.describe Rails::Auth::Monitor::Middleware do let(:request) { Rack::MockRequest.env_for("https://www.example.com") } describe "access granted" do let(:code) { 200 } let(:app) { ->(env) { [code, env, "Hello, world!"] } } it "fires the callback with the env and true" do callback_fired = false middleware = described_class.new(app, lambda do |env, success| callback_fired = true expect(env).to be_a Hash expect(success).to eq true end) response = middleware.call(request) expect(callback_fired).to eq true expect(response.first).to eq code end end describe "access denied" do let(:app) { ->(_env) { raise(Rails::Auth::NotAuthorizedError, "not authorized!") } } it "renders the error page" do callback_fired = false middleware = described_class.new(app, lambda do |env, success| callback_fired = true expect(env).to be_a Hash expect(success).to eq false end) expect { middleware.call(request) }.to raise_error(Rails::Auth::NotAuthorizedError) expect(callback_fired).to eq true end end end
Version data entries
8 entries across 8 versions & 1 rubygems