Sha256: d3b4255aedd11574227a8adb562b307c775bbe2d9b943c0eee5e79ec60124f54

Contents?: true

Size: 1.83 KB

Versions: 6

Compression:

Stored size: 1.83 KB

Contents

Feature: controller schema scaffolding

  When you prefer to test controller not in a unit-test fashion,
  but including `render_views` - you can add `:lurker` metadata
  to get a json schema for your api-documented endpoint

  Scenario: scaffold a json schema for a "users/show" in controller spec
    Given a file named "spec/controllers/api/v1/users_controller_spec.rb" with:
      """ruby
      require "spec_helper"

      describe Api::V1::UsersController, :lurker do
        render_views

        let!(:user) do
          User.where(name: 'razum2um', surname: 'Marley').first_or_create!
        end

        it "shows user" do
          get :show, id: user.id, format: 'json'
          expect(response).to be_success
        end
      end
      """

  When I run `bin/rspec spec/controllers/api/v1/users_controller_spec.rb`
  Then the example should pass
  Then a file named "lurker/api/v1/users/__id-GET.json.yml" should exist
  Then the file "lurker/api/v1/users/__id-GET.json.yml" should contain exactly:
    """yml
    ---
    description: user
    prefix: users management
    requestParameters:
      description: ''
      type: object
      additionalProperties: false
      required: []
      properties: {}
    responseCodes:
    - status: 200
      successful: true
      description: ''
    responseParameters:
      description: ''
      type: object
      additionalProperties: false
      required: []
      properties:
        id:
          description: ''
          type: integer
          example: 1
        name:
          description: ''
          type: string
          example: razum2um
        surname:
          description: ''
          type: string
          example: Marley
    extensions:
      method: GET
      path_info: "/api/v1/users/1.json"
      path_params:
        controller: api/v1/users
        action: show
        id: '1'

  """

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lurker-0.6.12 features/controller_schema_scaffolding.feature
lurker-0.6.11 features/controller_schema_scaffolding.feature
lurker-0.6.10 features/controller_schema_scaffolding.feature
lurker-0.6.9 features/controller_schema_scaffolding.feature
lurker-0.6.8 features/controller_schema_scaffolding.feature
lurker-0.6.7 features/controller_schema_scaffolding.feature