Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Minitest 5 #41

Merged
merged 6 commits into from
Apr 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
appraise "minitest4" do
gem 'minitest', '4.7.5'
end

appraise "minitest5" do
gem 'minitest'
end
46 changes: 30 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,32 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (3.1.3)
multi_json (~> 1.0)
colorize (0.6.0)
coveralls (0.5.8)
colorize
json
activesupport (4.0.4)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
atomic (1.1.16)
coveralls (0.7.0)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
docile (1.1.1)
json (1.8.1)
method_source (0.8.1)
mime-types (2.0)
minitest (2.11.4)
multi_json (1.0.4)
mustache (0.99.4)
rake (10.0.4)
rdiscount (1.6.8)
redcarpet (2.0.1)
docile (1.1.3)
i18n (0.6.9)
method_source (0.8.2)
mime-types (2.2)
minitest (4.7.5)
multi_json (1.9.2)
mustache (0.99.5)
rake (10.1.1)
rdiscount (2.1.7)
redcarpet (3.1.1)
rest-client (1.6.7)
mime-types (>= 1.16)
rocco (0.8.2)
Expand All @@ -37,13 +44,20 @@ GEM
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.18.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tins (1.0.1)
tzinfo (0.3.39)

PLATFORMS
ruby

DEPENDENCIES
activesupport
appraisal
coveralls
m!
minitest
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ SUPPORT
- MiniTest::Unit::TestCase


CONTRIBUTING
============

You can run the tests for minitest 4 with:

rake appraisal:minitest4 test

and the ones for minitest 5 with:

rake appraisal:minitest5 test TEST=test/minitest_5_test.rb

In the case of minitest 5 the whole suite will fail due to incompatibilities
with ruby (at least until 2.1.1).


LICENSE
=======

Expand Down
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env rake
require 'rubygems'
require 'bundler/setup'
require 'appraisal'
require "bundler/gem_tasks"
require 'rake/clean'
require "rake/testtask"
Expand Down
8 changes: 8 additions & 0 deletions gemfiles/minitest4.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "coveralls", :require=>false
gem "minitest", "4.7.5"

gemspec :path=>"../"
64 changes: 64 additions & 0 deletions gemfiles/minitest4.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
PATH
remote: /Users/zamith/Projects/personal/m
specs:
m (1.3.2)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (4.0.2)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
atomic (1.1.14)
colorize (0.6.0)
coveralls (0.5.8)
colorize
json
rest-client
simplecov (>= 0.7)
thor
docile (1.1.1)
i18n (0.6.9)
json (1.8.1)
method_source (0.8.2)
mime-types (2.0)
minitest (4.7.5)
multi_json (1.8.4)
mustache (0.99.4)
rake (10.1.1)
rdiscount (1.6.8)
redcarpet (3.0.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rocco (0.8.2)
mustache
redcarpet
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
thor (0.18.1)
thread_safe (0.1.3)
atomic
tzinfo (0.3.38)

PLATFORMS
ruby

DEPENDENCIES
activesupport
appraisal
coveralls
m!
minitest (= 4.7.5)
rdiscount
rocco
8 changes: 8 additions & 0 deletions gemfiles/minitest5.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "coveralls", :require=>false
gem "minitest"

gemspec :path=>"../"
57 changes: 57 additions & 0 deletions gemfiles/minitest5.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
PATH
remote: /Users/zamith/Projects/personal/m
specs:
m (1.3.2)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.16)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
appraisal (0.5.2)
bundler
rake
colorize (0.6.0)
coveralls (0.5.8)
colorize
json
rest-client
simplecov (>= 0.7)
thor
docile (1.1.1)
i18n (0.6.9)
json (1.8.1)
method_source (0.8.2)
mime-types (2.0)
minitest (5.3.1)
multi_json (1.8.4)
mustache (0.99.4)
rake (10.1.1)
rdiscount (1.6.8)
redcarpet (3.0.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rocco (0.8.2)
mustache
redcarpet
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
thor (0.18.1)

PLATFORMS
ruby

DEPENDENCIES
activesupport
appraisal
coveralls
m!
minitest
rdiscount
rocco
15 changes: 12 additions & 3 deletions lib/m.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
### M, your metal test runner
# Maybe this gem should have a longer name? Metal?
module M
require_relative 'm/frameworks'
VERSION = "1.3.2" unless defined?(VERSION)

# Accept arguments coming from bin/m and run tests, then bail out immediately.
Expand Down Expand Up @@ -189,7 +190,9 @@ def execute
test_arguments = ["-n", "/^(#{test_names})$/"]

# directly run the tests from here and exit with the status of the tests passing or failing
if defined?(MiniTest)
if Frameworks.minitest5?
Minitest.run test_arguments
elsif Frameworks.minitest4?
MiniTest::Unit.runner.run test_arguments
elsif defined?(Test)
Test::Unit::AutoRunner.run(false, nil, test_arguments)
Expand Down Expand Up @@ -232,7 +235,9 @@ def suites
end

# Figure out what test framework we're using
if defined?(MiniTest)
if Frameworks.minitest5?
suites = Minitest::Runnable.runnables
elsif Frameworks.minitest4?
suites = MiniTest::Unit::TestCase.test_suites
elsif defined?(Test)
suites = Test::Unit::TestCase.test_suites
Expand All @@ -244,7 +249,11 @@ def suites
# Use some janky internal APIs to group test methods by test suite.
suites.inject({}) do |suites, suite_class|
# End up with a hash of suite class name to an array of test methods, so we can later find them and ignore empty test suites
suites[suite_class] = suite_class.test_methods if suite_class.test_methods.size > 0
if Frameworks.minitest5?
suites[suite_class] = suite_class.runnable_methods if suite_class.runnable_methods.size > 0
else
suites[suite_class] = suite_class.test_methods if suite_class.test_methods.size > 0
end
suites
end
end
Expand Down
11 changes: 11 additions & 0 deletions lib/m/frameworks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module M
class Frameworks
def self.minitest5?
defined?(Minitest) && Minitest::Unit::VERSION.start_with?("5")
end

def self.minitest4?
defined?(MiniTest)
end
end
end
1 change: 1 addition & 0 deletions m.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "rdiscount"
gem.add_development_dependency "rocco"
gem.add_development_dependency "minitest"
gem.add_development_dependency "appraisal"

gem.required_ruby_version = ">= 1.9"

Expand Down
36 changes: 36 additions & 0 deletions test/examples/minitest_4_example_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'minitest/unit'
if M::Frameworks.minitest4?

class Meme
def i_can_has_cheezburger?
"OHAI!"
end

def will_it_blend?
"YES!"
end
end


class TestMeme < MiniTest::Unit::TestCase
def setup
@meme = Meme.new
end

def test_that_kitty_can_eat
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
end

def test_that_it_will_not_blend
refute_match /^maybe/i, @meme.will_it_blend?
refute_match /^no/i, @meme.will_it_blend?
refute_match /^lolz/i, @meme.will_it_blend?
end

def test_that_kitty_can_eat_two_time
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
end

end
end
35 changes: 35 additions & 0 deletions test/examples/minitest_5_example_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'minitest/autorun'
if M::Frameworks.minitest5?
class Meme
def i_can_has_cheezburger?
"OHAI!"
end

def will_it_blend?
"YES!"
end
end


class TestMeme < Minitest::Test
def setup
@meme = Meme.new
end

def test_that_kitty_can_eat
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
end

def test_that_it_will_not_blend
refute_match /^maybe/i, @meme.will_it_blend?
refute_match /^no/i, @meme.will_it_blend?
refute_match /^lolz/i, @meme.will_it_blend?
end

def test_that_kitty_can_eat_two_time
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
end

end
end
Loading