Skip to content

truemail-rb/truemail-rspec

Repository files navigation

Truemail RSpec helpers

Maintainability Test Coverage CircleCI Gem Version Downloads Gitter GitHub Contributor Covenant

truemail-rspec gem helps you to create Truemail::Configuration, Truemail::Auditor and Truemail::Validator instances for your RSpec environment.

Actual and maintainable documentation 📚 for developers is living here.

Table of Contents

Requirements

Ruby MRI 2.5.0+

Features

  • Ability to create Truemail::Configuration instance with random or with predefined params
  • Ability to create Truemail::Auditor instance with random or with predefined params
  • Ability to create Truemail::Validator instance with random or with predefined params

Installation

Add this line to your application's Gemfile:

group :development, :test do
  gem 'truemail-rspec', require: false
end

And add into your spec_helper.rb or rails_helper.rb:

require 'truemail/rspec'

RSpec.configure do |config|
  config.include Truemail::RSpec
end

And then execute:

bundle

Or install it yourself as:

gem install truemail-rspec

Usage

Create configuration instance

Allows to create configuration instance with random or with predefined params.

Configuration instance with default random params

create_configuration

# => returns Truemail::Configuration instance with
# random verifier_email and default Truemail::Configuration params

Configuration instance with predefined params

All Truemail::Configuration available params

create_configuration(verifier_email: 'email@domain.com', verifier_domain: 'other-domain.com')
# => returns Truemail::Configuration instance with custom settings

Create auditor instance

Allows to create auditor instance with default random or with predefined params.

create_auditor

create_auditor(
  success: true, # optional, type:Bool, by default true
  current_host_ip: current_host_ip, # optional, type:String, by default random IPv4 address
  warnings: warnings, # optional, type:Hash, by default creates auditor result warnings
  configuration: create_configuration # optional, type:Truemail::Configuration, by default creates random configuration
)

# => returns Truemail::Auditor instance follow passed params

Create validator instance

Allows to create validator instance with default random or with predefined params.

create_servers_list

create_servers_list # => returns array with random ip addresses
create_servers_list(42) # => returns array with 42 random ip addresses

create_validator

create_validator(
  validation_type, # optional, type:Symbol, can be :emails_list, :domains_list, :regex, :mx, :mx_blacklist or :smtp, by default creates :smtp validation
  email, # optional, type:String, by default random email
  mail_servers, # optional, type:Array(String), by default array with random ip addresses
  success: true, # optional, type:Bool, by default true
  rcptto_error: 'custom context of rcptto error' # optional, type:String, by default it's equal to 'user not found'
  configuration: create_configuration # optional, type:Truemail::Configuration, by default creates random configuration
)

# => returns Truemail::Validator instance follow passed params

Truemail family

All Truemail solutions: https://truemail-rb.org

Name Type Description
truemail ruby gem Configurable framework agnostic plain Ruby email validator, main core
truemail-go go package Configurable Golang email validator, main core
truemail server ruby app Lightweight rack based web API wrapper for Truemail gem
truemail-rack-docker docker image Lightweight rack based web API dockerized image 🐳 of Truemail server
truemail-ruby-client ruby gem Web API Ruby client for Truemail Server
truemail-crystal-client crystal shard Web API Crystal client for Truemail Server
truemail-java-client java lib Web API Java client for Truemail Server

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail-rspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. Please check the open tickets. Be sure to follow Contributor Code of Conduct below and our Contributing Guidelines.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the truemail-rspec project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Credits

Versioning

truemail-rspec uses Semantic Versioning 2.0.0