Sha256: 0ba851d2b323f2259964531a641de06540f35a8d093dd8e1fdde39e4ba7f1c27

Contents?: true

Size: 1.47 KB

Versions: 26

Compression:

Stored size: 1.47 KB

Contents

require 'rails_helper'
require 'rspec_api_documentation/dsl'

resource "Ping (V1)" do
  include ApiClients
  header "Accept", "application/json; version=1"
  header "Content-Type", "application/json; version=1"

  post "/api/ping" do
    response_field :ping, "The name of the ping", "Type" => "Object"
    response_field :status, "The status of the ping", scope: "ping", "Type" => "String"
    example "ping the server to validate your client's happy path" do

      header "Authorization", "CustomKeyAuth key=#{api_client.key}"
      do_request

      result = JSON.parse(response_body)
      expect(result).to eq({ "ping" =>  { "status" => "ok" }})

      expect(status).to eql 201

    end
  end
  post "/api/ping" do
    parameter :error, "If set, will return an error instead of ok", "Type" => "Object"

    response_field :errors, "Array of errors", "Type" => "Array"
    response_field :code, "Programmer key describing the error (useful for logic)", scope: "errors", "Type" => "String"
    response_field :message, "Human-readable error message", scope: "errors", "Type" => "String"

    let(:error) { "OH NOES!" }
    let(:raw_post) { params.to_json }

    example "ping the server to validate your client's error handling" do

      header "Authorization", "CustomKeyAuth key=#{api_client.key}"
      do_request

      result = JSON.parse(response_body)
      expect(result).to eq({ "errors" => [ { "code" => "test", "message" => "OH NOES!" }]})

      expect(status).to eql 422

    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
stitches-4.2.2 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.2.1 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.2.0 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.2.0.RC3 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.2.0.RC2 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.2.0.RC1 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.0.2 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.1.0RC2 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.0.1 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.0.0 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-4.0.0.RC1 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.8.3 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.8.2 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.8.1 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.8.0 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.7.3 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.7.2 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.7.0 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.6.1 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb
stitches-3.6.0 lib/stitches/generator_files/spec/acceptance/ping_v1_spec.rb