minitest-spec-rails 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +71 -4
- data/lib/minitest-spec-rails/version.rb +1 -1
- data/minitest-spec-rails.gemspec +1 -1
- metadata +8 -9
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,83 @@
|
|
1
|
-
|
2
1
|
# MiniTest::Spec For Rails
|
3
2
|
|
4
|
-
|
3
|
+
|
4
|
+
This gem makes it easy to use the MiniTest Spec DSL in Rails 3 application tests.
|
5
|
+
|
6
|
+
|
7
|
+
# Example Gemfile
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'minitest-spec-rails'
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# Example Test
|
15
|
+
|
16
|
+
# ./test/unit/myclass_test.rb
|
17
|
+
require 'test_helper'
|
18
|
+
class MyClassTest < ActiveSupport::TestCase
|
19
|
+
it "does something"
|
20
|
+
100.must_equal 100
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Example Run
|
25
|
+
|
26
|
+
$ ruby -Itest test/unit/myclass_test.rb
|
27
|
+
...
|
28
|
+
MyClassTest
|
29
|
+
PASS test_0001_does_something (0:00:00.002)
|
30
|
+
...
|
31
|
+
|
32
|
+
|
33
|
+
# Advantages
|
34
|
+
|
35
|
+
With minitest-spec-rails, we have a working solution by replacing MiniTest::Spec as the superclass for ActiveSupport::TestCase. This solution is simple and does not require you to recreate a new test case in your test_helper.rb or to use generators supplied by gems like minitest-rails.
|
36
|
+
|
37
|
+
MinitTest::Spec is built on top of MiniTest::Unit which a replacement for Test::Unit, so is stable and consistent.
|
38
|
+
|
39
|
+
It's easy to change an existing Rails application from Test Unit to MiniTest::Spec simply installing this gem.
|
40
|
+
|
41
|
+
As Rails evolves to leverage MiniTest::Spec, your test case code will not have to change.
|
42
|
+
|
43
|
+
|
44
|
+
# How it works
|
45
|
+
|
46
|
+
|
47
|
+
This gem makes Test::Unit::TestCase a subclass of of MiniTest::Spec with a simple shim.
|
48
|
+
|
49
|
+
The gem tricks ActiveSupport::TestCase to use MiniTest::Spec instead. The gem includes any monkey patches to make using MiniTest::Spec a drop in behavior change for any Rails 3.x project.
|
50
|
+
|
51
|
+
Full Details here:
|
5
52
|
|
6
53
|
http://metaskills.net/2011/03/26/using-minitest-spec-with-rails/
|
7
54
|
|
8
55
|
|
9
|
-
#
|
56
|
+
# Styles
|
10
57
|
|
11
|
-
If there are any issues using this in Rails 3 outside the normal few assertions that change from Test::Unit to MiniTest::Unit, please open an issue here on github.
|
12
58
|
|
59
|
+
This <a href="http://cheat.errtheblog.com/s/minitest/1">cheat sheet</a> shows the Test Unit assert methods and the MiniTest::Spec methods.
|
60
|
+
|
61
|
+
Test Unit style:
|
62
|
+
|
63
|
+
assert_equal 100, foo
|
64
|
+
|
65
|
+
MiniTest::Spec style:
|
13
66
|
|
67
|
+
foo.must_equal 100
|
14
68
|
|
15
69
|
|
70
|
+
# Gotchas
|
71
|
+
|
72
|
+
There are a few missing assertions available in Test::Unit that are changed or no longer available in MiniTest.
|
73
|
+
|
74
|
+
* The method <code>assert_raise</code> is renamed <code>assert_raises</code>.
|
75
|
+
|
76
|
+
* There is no method <code>assert_nothing_raised</code>. There are good reasons for this on Ryan's blog.
|
77
|
+
|
78
|
+
|
79
|
+
# Issues
|
80
|
+
|
81
|
+
If there are any issues using this in Rails 3 outside the normal few assertions that change from Test::Unit to MiniTest::Unit, please open an issue here on github.
|
82
|
+
|
16
83
|
|
data/minitest-spec-rails.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ['lib']
|
18
|
-
s.add_runtime_dependency 'minitest'
|
18
|
+
s.add_runtime_dependency 'minitest'
|
19
19
|
s.add_runtime_dependency 'rails', '~> 3.0'
|
20
20
|
s.add_development_dependency 'rake'
|
21
21
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-spec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 2
|
10
|
+
version: 3.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Collins
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
@@ -23,13 +23,12 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 3
|
29
29
|
segments:
|
30
|
-
-
|
31
|
-
|
32
|
-
version: "2.11"
|
30
|
+
- 0
|
31
|
+
version: "0"
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
- !ruby/object:Gem::Dependency
|