All Projects → rmm5t → minitest-matchers_vaccine

rmm5t / minitest-matchers_vaccine

Licence: MIT license
💉 Adds matcher support to minitest without all the other RSpec-style expectation "infections."

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to minitest-matchers vaccine

honey format
Makes working with CSVs as smooth as honey.
Stars: ✭ 13 (-60.61%)
Mutual labels:  rubygem
evil systems
An easy way to enhance your system tests with Rails and Capybara using EvilMartians System of a Test.
Stars: ✭ 41 (+24.24%)
Mutual labels:  minitest
restcountry
This is a Ruby wrapper library around the API provided by REST Countries http://restcountries.eu
Stars: ✭ 32 (-3.03%)
Mutual labels:  rubygem
bdd
Given/When/Then/And/But output to RSpec and Minitest
Stars: ✭ 33 (+0%)
Mutual labels:  minitest
capybara select2
Capybara helpers for https://select2.org select box (supports Select2 version 2/3/4)
Stars: ✭ 48 (+45.45%)
Mutual labels:  minitest
rspec-hanami
RSpec Matchers for Hanami
Stars: ✭ 47 (+42.42%)
Mutual labels:  matchers
sidekiq queue metrics
Records stats of each sidekiq queue and exposes APIs to retrieve them
Stars: ✭ 29 (-12.12%)
Mutual labels:  rubygem
modular routes
Dedicated controllers for each of your Rails route actions.
Stars: ✭ 45 (+36.36%)
Mutual labels:  rubygem
git statistics
A gem that allows you to get detailed statistics of a git repository.
Stars: ✭ 62 (+87.88%)
Mutual labels:  rubygem
dry-transformer
Data transformation toolkit
Stars: ✭ 59 (+78.79%)
Mutual labels:  rubygem
strings-case
Convert strings between different cases.
Stars: ✭ 65 (+96.97%)
Mutual labels:  rubygem
ruby-sdk
♦️ Ruby SDK to use the IBM Watson services.
Stars: ✭ 45 (+36.36%)
Mutual labels:  rubygem
glimmer-dsl-tk
Glimmer DSL for Tk (Ruby Tk Desktop Development GUI Library)
Stars: ✭ 26 (-21.21%)
Mutual labels:  rubygem
dry-logger
[WIP] Logging library
Stars: ✭ 16 (-51.52%)
Mutual labels:  rubygem
ruby attic
💍 Unmaintained ruby projects needing people!
Stars: ✭ 26 (-21.21%)
Mutual labels:  rubygem
material-sass
A rubygem of Material Design for Bootstrap 4
Stars: ✭ 55 (+66.67%)
Mutual labels:  rubygem
jekyll-target-blank
Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
Stars: ✭ 86 (+160.61%)
Mutual labels:  rubygem
consul-templaterb
consul-template-like with erb (ruby) template expressiveness
Stars: ✭ 65 (+96.97%)
Mutual labels:  rubygem
bootswatch-sass
bootswatch ruby gems for assets pipeline
Stars: ✭ 12 (-63.64%)
Mutual labels:  rubygem
benchmark-trend
Measure performance trends of Ruby code
Stars: ✭ 60 (+81.82%)
Mutual labels:  rubygem

Minitest::MatchersVaccine

Gem Version Build Status Maintainability

Adds matcher support to minitest without all the other RSpec-style expectation infections.

Using matchers with RSpec-style expectations requires that we infect the objects that we are testing with new methods. Matcher implementations are typically overkill, but there are a lot of good testing libraries that still insist on standardizing on matchers. These matchers still have some value, and this gem tries to extract that value with straight-forward assertions that adhere to the matcher spec.

Why not use minitest-matchers? This gem is actually heavily inspired by and based upon the assertions in minitest-matchers; however, everything else that minitest-matchers brings to the table is unnecessary unless you're bent on a true RSpec-style syntax.

Installation

Add this line to your application's Gemfile:

gem "minitest-matchers_vaccine"

And then execute:

$ bundle

Or install it yourself as:

$ gem install minitest-matchers_vaccine

Usage

Includes both assert_must and assert_wont assertions, but also includes must and wont facilitator assertions that automatically default to using the current subject method (aka "let variable") or @subject instance variable.

NOTE: This gem does not allow matchers to be used with an expectation syntax. Let's avoid infecting the objects we're testing.

Minitest::Test

class UserTest < Minitest::Test
  def setup
    @subject = User.new
  end

  def test_fields_and_associations
    must have_db_column :name
    must belong_to :account
    assert_must have_many(:widgets), @subject
  end

  def test_validations
    must have_valid(:email).when("[email protected]", "[email protected]", "[email protected]")
    wont have_valid(:email).when(nil, "foo", "foo@bar", "@bar.com")
  end

  # Works with matchers in other libs
  def test_stripping
    assert_must strip_attribute(:name), User.new
  end
end

Minitest::Spec

describe User do
  subject { User.new }

  # Works with shoulda-matchers
  it "should have fields and associations" do
    must have_db_column :name
    must belong_to :account
    must have_many :widgets
  end

  # Works with valid_attribute
  it "should validate" do
    must have_valid(:email).when("[email protected]", "[email protected]", "[email protected]")
    wont have_valid(:email).when(nil, "foo", "foo@bar", "@bar.com")
  end

  # Works with matchers in other libs
  it "should strip attributes" do
    must strip_attribute :name
  end
end

Contributing

  1. Fork it ( https://github.com/rmm5t/minitest-matchers_vaccine/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Credits

The idea was originally inspired by the matcher assertions implementation in minitest-matchers.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].