Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 1.11 KB

readme.md

File metadata and controls

47 lines (29 loc) · 1.11 KB

Sinatra Testing with Rack::Test

Introduction

We're going to create a simple Sinatra application that authenticates a user via a JSON API and returns an authentication token. For now the user credentials (username/password) will be hard-coded.

The application will be tested with Rack::Test and should have at least two test cases:

  • Testing a user successfully authenticates and receives an authentication token
  • Testing a user fails to authenticate and returns an empty response

Example Output

The response for a successful request should be similar to:

{
  success: true,
  token: '32925e4e8b6648afa2659f807e74cce8'
}

The response for an unsuccessful request should be similar to:

{
  success: false,
  token: null
}

This response should also return a 401 Unauthorized status code.

Walk-through

Coding walk-through to be done in person with group.

Solutions