Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
uoy-faculty-spec-helpers / lib / shared_examples / endpoint_behaviours.rb
Size: Mime:
# frozen_string_literal: true

shared_examples 'the endpoint requires login' do
  it 'responds with 401' do
    expect(subject.status).to eq(401)
  end
end

shared_examples 'the endpoint denies access' do
  it { is_expected.to be_forbidden }
end

shared_examples 'the endpoint was not found' do
  it { is_expected.to be_not_found }
end

shared_examples 'the endpoint redirects' do |to: nil|
  if to
    let(:redirect_to) { to }
    redirects = "redirects to #{to}"
  else
    redirects = 'redirects'
  end

  it redirects, :aggregate_failures do
    expect(subject).to be_redirect
    next unless respond_to? :redirect_to

    expect(subject.location).to match_url(redirect_to)
  end
end

shared_examples 'the endpoint permits access' do
  it { is_expected.to be_ok }
end