Sha256: e07d6924cd11c868b8d83fb91cc892cd8ac25bd94b96e6ade4f29962322a649a

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

RSpec.shared_examples "error_collection" do |codes|
  if codes.include?("400")
    response 400, " Недопустимые параметры" do
      let(:params) { {data: "invalid"} }
      schema "$ref": "#/components/schemas/ErrorsOutput"
      run_test!
    end
  end

  if codes.include?("401")
    response 401, "Учетная запись не авторизована" do
      let(:Authorization) { nil }
      schema "$ref": "#/components/schemas/ErrorsOutput"
      run_test!
    end
  end

  if codes.include?("403")
    response 403, "Нет прав доступа к ресурсу" do
      let(:permissions) {[]}
      schema "$ref": "#/components/schemas/ErrorsOutput"
      run_test!
    end
  end

  if codes.include?("404")
    response 404, "Ресурс не найден" do
      let(:organization_id) { SecureRandom.uuid }
      schema "$ref": "#/components/schemas/ErrorsOutput"
      run_test!
    end
  end

  if codes.include?("422")
    response 422, "Недопустимая модель ресурса" do
      let(:params) { invalid_params }
      schema "$ref": "#/components/schemas/ErrorsOutput"
      run_test!
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
care-0.1.6 lib/care/support/error_collection.rb
care-0.1.5 lib/care/support/error_collection.rb
care-0.1.4 lib/care/support/error_collection.rb
care-0.1.3 lib/care/support/error_collection.rb
care-0.1.1 lib/care/support/error_collection.rb
care-0.1.0 lib/care/support/error_collection.rb