• Stars
    star
    377
  • Rank 113,535 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 13 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Test::Unit runner that can run tests by line number.

M.RB

Gem Version Code Climate Build Status Coverage Status


m stands for metal, a better test/unit and minitest test runner that can run tests by line number.

INSTALL

Install via:

$ gem install m

If youโ€™re using Bundler, youโ€™ll need to include it in your Gemfile. Toss it into the test group:

group :test do
  gem "m"
end

USAGE

Basically, I was sick of using the -n flag to grab one test to run. Instead, I prefer how RSpecโ€™s test runner allows tests to be run by line number.

Given this file:

$ cat -n test/example_test.rb
 1  require 'test/unit'
 2
 3  class ExampleTest < Test::Unit::TestCase
 4    def test_apple
 5      assert_equal 1, 1
 6    end
 7
 8    def test_banana
 9      assert_equal 1, 1
10    end
11  end

You can run a test by line number, using format m TEST_FILE:LINE_NUMBER_OF_TEST:

$ m test/example_test.rb:4
Run options: -n /test_apple/

# Running tests:

.

Finished tests in 0.000525s, 1904.7619 tests/s, 1904.7619 assertions/s.

1 tests, 1 assertions, 0 failures, 0 errors, 0 skips

Hit the wrong line number? No problem, m helps you out:

$ m test/example_test.rb:2
No tests found on line 2. Valid tests to run:

 test_apple: m test/examples/test_unit_example_test.rb:4
test_banana: m test/examples/test_unit_example_test.rb:8

Want to run the whole test? Just leave off the line number.

$ m test/example_test.rb
Run options:

# Running tests:

..

Finished tests in 0.001293s, 1546.7904 tests/s, 3093.5808 assertions/s.

1 tests, 2 assertions, 0 failures, 0 errors, 0 skips

If you want to run all the tests in a directory as well as its subdirectories, use the -r flag:

$ m -r test/models
"Searching provided directory for tests recursively"
Run options:

..

Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s.

156 tests, 303 assertions, 0 failures, 0 errors, 13 skips

If you need to pass some option down to the actual runner, that is also supported:

$ m test/models -- --seed 1234
Run options: --seed 1234

..

Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s.

156 tests, 303 assertions, 0 failures, 0 errors, 13 skips

Ensure that you use the -- before the options, otherwise you'll get an invalid option error. Also, these extra option should always be the last argument.

SUPPORT

m works with a few Ruby test frameworks:

  • Test::Unit
  • ActiveSupport::TestCase
  • MiniTest::Unit::TestCase
  • Minitest

CONTRIBUTING

Testing

You can run all the tests with:

bundle exec rake tests

You can also run tests selectively. For minitest 4 run:

bundle exec rake test:minitest4

and the ones for minitest 5 with:

bundle exec rake test:minitest5

LICENSE

This gem is MIT licensed, please see LICENSE for more information.

More Repositories

1

sub

a delicious way to organize programs
Shell
1,744
star
2

unix

Mirror of the Restoration of 1st Edition UNIX kernel sources from pdf document.
C
791
star
3

motion-layout

A nice way to use iOS6+ autolayout in your RubyMotion app. Use ASCII-art inspired format strings to build your app's layout!
Ruby
215
star
4

hola

example gem repo
Ruby
124
star
5

motion-settings-bundle

Create a Settings.bundle for your RubyMotion app
Ruby
110
star
6

gitready

learn git one commit at a time. updates weekly or when great tips are found
98
star
7

vim-fu

Combining the awesomeness of various vim plugins in one easy configurable unit.
Vim Script
38
star
8

shp

A new UI for git. This doesn't work yet.
Rust
28
star
9

pubsub

easy example of redis pubsub
Ruby
27
star
10

qrush.github.com

coding with spice
CSS
26
star
11

skyway

Official news, tour, stats and community site for Aqueous
Ruby
22
star
12

rebase

A weekly update about GitHub!
Ruby
15
star
13

react-native-wkwebview

WKWebView for React Native (+ a few nice things)
Objective-C
12
star
14

snake

A simple Snake game, written in Shoes.
Ruby
9
star
15

danger_danger

example rails 3.1.1 app using high_voltage for a static site
Ruby
9
star
16

gsay

SPEAK LIKE A GOOGLE ROBOT
Ruby
9
star
17

mon

A pokemon battle simulator
Ruby
7
star
18

kidsmash-mac

Kidsmash: ๐ŸŽ
Swift
6
star
19

beardo

Co-ops are run by dirty hippies; dirty hippies have beards; therefore, this app is called beardo.
5
star
20

higo

go, on heroku!
Ruby
5
star
21

kidsmash

KID SMASH - JavaScript port of BabySmash for SE444
JavaScript
5
star
22

beesknees

a boggle clone && an experiment with redis
Ruby
4
star
23

dfat

DWARF FORTRESS ADVENTURE TIME
Ruby
4
star
24

gemwhisperer

THE GEM WHISPERER: HE SPEAKS TO GEMS
JavaScript
3
star
25

go

explorations into google's go
Go
3
star
26

archive

My twitter archive
JavaScript
3
star
27

nyruby

nyruby: the empire state's ruby group
Ruby
3
star
28

LookInside

An actual compiling sample code repo from WWDC 2014: A Look Inside Presentation Controllers
Objective-C
3
star
29

test-without-issues

2
star
30

wedding

JavaScript
2
star
31

mwnbot

Java
2
star
32

counter

a carcassonne counter
Ruby
2
star
33

df

dorf fortress.
2
star
34

ThreadMessages

Ruby
2
star
35

mwrc

sandbox/playground for my MWRC 2011 talk
Ruby
2
star
36

q-tracer

c# raytracer project for cg2
C#
1
star
37

arel-test

Ruby
1
star
38

gifs

CSS
1
star
39

ec2bootstrapper

git-svn clone of the C# EC2 bootstrapper from CodePlex
C#
1
star
40

q

Shell
1
star
41

nathanlanevsraptor

a tweetstream demo, made during BarCampBoston 6
JavaScript
1
star
42

historian-extension

1
star
43

aftest

Ruby
1
star
44

q-blizzard

another CG2 project, this time a c# particle system
C#
1
star
45

notvirus.news

CSS
1
star
46

cheeseburger

redis: data cheeseburgers!
Ruby
1
star
47

stupidrubytricks

WNYRuby December 2011 Talk
Ruby
1
star