0.0
No commit activity in last 3 years
No release in over 3 years
This gem provides comfortable using of data types mathching in your RSpec tests
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 11.2

Runtime

~> 3.3
 Project Readme

RspecTypeof

Gem Version CodeClimate Build Status

Welcome to rspec_typeof, with this gem you can use "typeof" or "type_of" expectation in your tests for comfortable data format matching of both single data examples and data collections

Installation

Add this line to your application's Gemfile in the group :development, :test:

gem 'rspec_typeof'

And then execute:

$ bundle

Usage examples

expect(true).to typeof(:true) or expect(true).to type_of(:true)

expect(true).to typeof(:string_or_nil_or_true)

expect({string: 'string', fixnum: 2, hash: {}, array: [], custom_class: CustomClass.new}).to match(
  string:       typeof(:string_or_nil),
  fixnum:       typeof(:fixnum_or_nil),
  hash:         typeof(:hash_or_nil_or_string),
  array:        typeof(:array_or_nil),
  custom_class: typeof(:custom_class_or_nil_or_array)
)

expect(['a', 'b', 'c']).to typeof(:array_of_string)

expect(['a', 'b', 1]).to typeof(:array_of_string_or_integer)

expect(1).to typeof(:numeric)

Contributing

Send improvement propositions, bug reports and pull requests on GitHub at https://github.com/Somiel/rspec_typeof.