GitXplorerGitXplorer
j

minitest-tagz

public
6 stars
0 forks
3 issues

Commits

List of commits on branch master.
Unverified
3c05b40b24a52c5fdec207c32ee8f7b336f87471

bump to 1.7.0

committed 6 years ago
Unverified
81c3d68c0d61a793b6e32674275a7e5aa6606cb6

big refactor

committed 6 years ago
Unverified
29a59cf49cc4c99f8e081d0d6ec4697b30a41b6e

update travis rubies

jjbodah committed 7 years ago
Unverified
2009a8fb4a8d37162d72852b4f627d5a47d195e8

bump to 1.6.0

jjbodah committed 7 years ago
Unverified
a182a765f1c809a5a597413b994411f1acf4e6d2

remove dependency on state_machines and fix all of the 2.4.x/2.5.x

jjbodah committed 7 years ago
Unverified
2a94044a73ff633a07bffd4341e3b62108a69308

fix chosen_tags reference error

jjbodah committed 7 years ago

README

The README file for this repository.

Minitest::Tagz

Build Status Code Climate Gem Version

yet another tags implementation for Minitest

Note: backupify/minitest-tagz is no longer maintained. Please refer to this fork for the maintenance.

Requirements

  • Ruby 2.0.0+

Installation

Add this line to your application's Gemfile:

gem 'minitest-tagz'

Setup

In your test_helper.rb you'll need to require Minitest::Tagz. You'll also want to tell Tagz which tags you want to use. I suggest using the TAGS environment variable:

require 'minitest/tagz'
Minitest::Tagz.choose_tags(*ENV['TAGS'].split(',')) if ENV['TAGS']

Then, for example, you can run all tests with the :fast and :login tags:

bundle exec rake test TAGS=fast,login

You can also run all test without a particular tag or mix any subset. Below we run all the :fast tags, but not the :login tags

bundle exec rake test TAGS=-login,fast

Here's another example which will allow you to drop in a :focus tag wherever you want:

require 'minitest/tagz'
tags = ENV['TAGS'].split(',') if ENV['TAGS']
tags ||= []
tags << 'focus'
Minitest::Tagz.choose_tags(*tags, run_all_if_no_match: true)

Usage

Minitest::Tagz works with both Minitest::Test and Minitest::Spec. You can declare tags by using the tag helper.

# Using Minitest::Spec
class MySpec < Minitest::Spec
  tag :fast, :unit
  it 'should run' do
    assert true
  end

  tag :fast
  it 'should not run' do
    refute true
  end

  it 'also should not run' do
    refute true
  end
end

# Using Minitest::Test
class MyTest < Minitest::Test
  tag :fast
  def test_my_stuff
    assert true
  end
end

With Minitest::Spec adding tags to a describe will add the tags to all of the tests in the block:

class MySpec < Minitest::Spec
  tag :login
  describe 'all tests in this are tagged with :login' do
    it 'tests this' do
      assert true
    end

    it 'also tests this' do
      assert true
    end
  end
end

You can also use the run_all_if_no_match option to do something like always have a :focus tag on-demand:

Minitest::Tagz.choose_tags(*ENV['TAGS'].split(','), run_all_if_no_match: true) if ENV['TAGS']

This is how we add tag :focus in our projects:

require 'minitest/tagz/focus'

Debugging

You can save a reference to the tagger and watch the internal state machine:

tagger = tag :focus
it 'should work' do
  require 'rubygems'; require 'pry'; binding.pry
end

pry(main)> tagger
#=> #<Minitest::Tagz::Tagger:0x007fa296102008 @owner=#<Class:0x007fa2957317b8>, @patchers=[Minitest::Tagz::MinitestPatcher], @pending_tags=[:focus], @state="applying_tags">

Contributing

  1. Fork it ( https://github.com/backupify/minitest-tagz/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