Skip to content

This gem provides comfortable using of data types mathching in your RSpec tests.

License

Notifications You must be signed in to change notification settings

somiel/rspec_typeof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

This gem provides comfortable using of data types mathching in your RSpec tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published