Skip to content
Vassil Kovatchev edited this page Dec 9, 2018 · 14 revisions

[specs]: Slacker Tests After Slacker is installed, you can create a new project by running:

slacker_new project_name

A Slacker project has the following structure:

project_name
           ├ database.yml
           ├+ spec
           ├+ sql
           ├+ data
           ├ lib
           │    └+ helpers
           └ debug
                  ├+ passed_examples
                  └+ failed_examples
  • database.yml

A YAML file which contains the information about a connection to a database:

driver: tiny_tds # Optional - tiny_tds or odbc; Defaults to odbc.
server: my_server
port: 1433 # Optional and valid only for tiny_tds driver; Defaults to 1433.
database: my_database
user: my_user
password: my_password

Note: At this point Slacker only supports SQL Server Authentication.
If you are getting YAML-related errors after you modify database.yml, make sure you've put a space between each property name and value.

  • spec - Contains your Slacker tests (also known as specifications).
  • sql - Contains your SQL templates invoked by the specifications.
  • data - Contains CSV data files which represent data fixtures (seed data), expected resultsets and test matrices.
  • lib/helpers - Optionally contains helper modules.
  • debug - Contains the SQL trace scripts generated as a result of a Slacker execution.

ODBC vs TDS

Originally Slacker connected to SQL Server using driver ruby-odbc.

As of version 1.0.16, support was added for the more robust cross-platform TDS protocol via driver tiny_tds.

If you plan on running Slacker on Linux, macOS and Windows, it is highly recommended that you connect to SQL Server via TDS instead of ODBC.

Azure SQL Databases

When using tiny_tds, Slacker supports access to Azure SQL databases. To enable access to an Azure SQL database, edit database.yml and set azure to true.

UTF-8

The ODBC driver used by Slacker encodes data in ASCII. There is a UTF-8 edition of the ODBC driver, however, it does not return proper resultsets when executing scripts which combine DELETE and SELECT statements.

If you plan on using non-ASCII characters in your tests, you should use tiny_tds which has proper support for UTF-8.

Note about CSV files: Slacker expects CSV files to be encoded using UTF-8 encoding.

Driver Setup

ODBC Setup

  • Make sure that named pipes are enabled for the SQL Server instance.
  • Set driver to odbc.
  • When targeting a named instance set server to the full instance name - for example my-host\mssql2014.

TDS Setup

  • Make sure that TCP/IP protocol is enabled for the SQL Server instance.
  • Set driver to tiny_tds.
  • Set server to point at the host of SQL Server (not the full instance name).
  • In case of a named instance do not use the full instance name.
    Use a combination of server (IP address or name of SQL Server host) and port (the port the named instance is listening on).

To find the TCP/IP port your server is listening on, run the following against master:

SELECT DISTINCT 
    local_tcp_port 
FROM sys.dm_exec_connections 
WHERE local_tcp_port IS NOT NULL;

Also see Configure SQL Server Instance to Listen on a Specific TCP Port.