Testing Type Aliases

Last updated: 12 September 2017

Basic Test Structure

Tests for data type aliases should be placed under spec/type_aliases. For example, the tests for the MyModule::Shape type alias would be placed in spec/type_aliases/mymodule_shape_spec.rb.

require 'spec_helper'

describe 'MyModule::Shape' do
  # tests go here

Testing The Allowed Value(s)

The allow_value matcher is used to test how the type alias behaves when given a particular value.

it { is_expected.to allow_value('square') }

Multiple values can be provided in a single test using the allow_values matcher

it { is_expected.to allow_values('circle', 'triangle') }