mynyml-phocus 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +23 -25
- data/Rakefile +14 -1
- data/TODO +3 -1
- data/lib/phocus/autodetect.rb +46 -0
- data/lib/phocus.rb +5 -1
- data/phocus.gemspec +3 -7
- data/test/README +2 -0
- data/test/compat/test_contest.rb +2 -1
- data/test/compat/test_context.rb +2 -1
- data/test/compat/test_minitest.rb +2 -1
- data/test/compat/test_shoulda.rb +5 -1
- data/test/compat/test_test_unit.rb +2 -1
- metadata +3 -7
- data/lib/phocus/contest.rb +0 -13
- data/lib/phocus/context.rb +0 -13
- data/lib/phocus/minitest.rb +0 -15
- data/lib/phocus/shoulda.rb +0 -23
- data/lib/phocus/test_unit.rb +0 -22
data/README
CHANGED
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Phocus let's you temporarily focus some tests, ignoring all others, even across test classes.
|
|
4
4
|
|
|
5
|
+
===== Features
|
|
6
|
+
|
|
7
|
+
* Ultra simple to use
|
|
8
|
+
* Works accross testcase classes
|
|
9
|
+
* Works within contexts
|
|
10
|
+
* Can focus multiple tests
|
|
11
|
+
* Simple code (< 50 LOCs)
|
|
12
|
+
* Compatible with at least 5 different testing frameworks
|
|
13
|
+
|
|
5
14
|
==== Examples
|
|
6
15
|
|
|
7
16
|
require 'test/unit'
|
|
8
|
-
require 'phocus
|
|
17
|
+
require 'phocus'
|
|
9
18
|
|
|
10
19
|
class TestUser < Test::Unit::TestCase
|
|
11
20
|
|
|
@@ -43,7 +52,7 @@ Also works fine with <tt>test "description"</tt> style tests.
|
|
|
43
52
|
|
|
44
53
|
==== Phocus Vs. Editor
|
|
45
54
|
|
|
46
|
-
"Dude, MY editor already does that! Just get a real editor!!
|
|
55
|
+
"Dude, MY editor already does that! Just get a real editor!!"
|
|
47
56
|
|
|
48
57
|
Actually, so does my editor. But I've found that in many situations, it was far
|
|
49
58
|
from enough.
|
|
@@ -51,7 +60,7 @@ from enough.
|
|
|
51
60
|
Contexts:
|
|
52
61
|
Some frameworks like shoulda, context and contest allow you to embed tests
|
|
53
62
|
within context blocks, which throws off the editor's "run a single test"
|
|
54
|
-
|
|
63
|
+
functionality, since they expand the test method names.
|
|
55
64
|
|
|
56
65
|
Debugging:
|
|
57
66
|
Some editors will even allow you to step into the code when using
|
|
@@ -61,33 +70,22 @@ as the console.
|
|
|
61
70
|
Multiple Tests:
|
|
62
71
|
Phocus allows focusing more than one tests.
|
|
63
72
|
|
|
64
|
-
====
|
|
65
|
-
|
|
66
|
-
Phocus is compatible with various testing frameworks. To use with your
|
|
67
|
-
framework of choice, simply require the right compatibility file:
|
|
73
|
+
==== Testing Framework Compatibility
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
require 'phocus/minitest'
|
|
71
|
-
require 'phocus/shoulda'
|
|
72
|
-
require 'phocus/context'
|
|
73
|
-
require 'phocus/contest'
|
|
75
|
+
Phocus is known to be compatible with the following testing frameworks (see test/compat/*):
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
* test/unit
|
|
78
|
+
* minitest/unit
|
|
79
|
+
* shoulda
|
|
80
|
+
* context
|
|
81
|
+
* contest
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
is the standalone phocus functionality. You can require it directly, but you'll
|
|
83
|
-
have to set it up (which pretty much just means setting the right
|
|
84
|
-
Phocus.method_pattern for your test framework and including the mixin). You
|
|
85
|
-
really don't need to bother though, that work has been taken care of for you if
|
|
86
|
-
you <tt>require 'phocus/...'</tt> directly. Though it will be useful if you're
|
|
87
|
-
trying to get Phocus working with another framework. Refer to the rdocs in this
|
|
88
|
-
case (or better yet, you can read the source; it's < 50 LOCs)
|
|
83
|
+
It is possibly compatible out of the box with other test/unit-based testing
|
|
84
|
+
frameworks as well, but it should be fairly easy to set up if it isn't (include
|
|
85
|
+
Phocus in parent testcase class and set proper method_pattern. See rdocs)
|
|
89
86
|
|
|
90
87
|
==== Links
|
|
88
|
+
|
|
91
89
|
source:: http://github.com/mynyml/phocus
|
|
92
90
|
rdocs:: http://docs.github.com/mynyml/phocus
|
|
93
91
|
|
data/Rakefile
CHANGED
|
@@ -22,7 +22,7 @@ end
|
|
|
22
22
|
|
|
23
23
|
spec = Gem::Specification.new do |s|
|
|
24
24
|
s.name = 'phocus'
|
|
25
|
-
s.version = '0.9.
|
|
25
|
+
s.version = '0.9.9'
|
|
26
26
|
s.summary = "Run focused tests on test/unit."
|
|
27
27
|
s.description = "Tell test/unit exactly which tests you want run. It will ignore all the other ones and let you concentrate on a few."
|
|
28
28
|
s.author = "Martin Aumont"
|
|
@@ -64,3 +64,16 @@ desc "Uninstall gem"
|
|
|
64
64
|
task :uninstall => :clean do
|
|
65
65
|
sh "#{SUDO} #{gem} uninstall -v #{spec.version} -x #{spec.name}"
|
|
66
66
|
end
|
|
67
|
+
|
|
68
|
+
desc "run framework compatibility tests"
|
|
69
|
+
task :test_all do
|
|
70
|
+
paths = %w(
|
|
71
|
+
test/compat/test_contest.rb
|
|
72
|
+
test/compat/test_context.rb
|
|
73
|
+
test/compat/test_minitest.rb
|
|
74
|
+
test/compat/test_shoulda.rb
|
|
75
|
+
test/compat/test_test_unit.rb
|
|
76
|
+
test/test_phocus.rb
|
|
77
|
+
)
|
|
78
|
+
paths.each {|path| system("ruby #{path}") }
|
|
79
|
+
end
|
data/TODO
CHANGED
|
@@ -7,7 +7,7 @@ o test (implement?) compatibility with test/unit plugins
|
|
|
7
7
|
o test/spec
|
|
8
8
|
...
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
x add docs
|
|
11
11
|
- rdocs, README
|
|
12
12
|
|
|
13
13
|
o focus do
|
|
@@ -16,3 +16,5 @@ o focus do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
to focus a group of tests at once
|
|
19
|
+
|
|
20
|
+
x autodetect test framework; simply use `require 'phocus'`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# :stopdoc:
|
|
2
|
+
# Script to auto detect the test framework in use, and set it up with Phocus.
|
|
3
|
+
|
|
4
|
+
# Somewhat hackish, but simple/straightforward. If there ever is a need for
|
|
5
|
+
# extendability I'll gladly refactor.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# --------------------------------------------------
|
|
9
|
+
# test/unit, contest
|
|
10
|
+
# --------------------------------------------------
|
|
11
|
+
if defined?(Test::Unit::TestCase)
|
|
12
|
+
|
|
13
|
+
Test::Unit::TestCase.class_eval { include ::Phocus }
|
|
14
|
+
Test::Unit::TestSuite.class_eval { def empty?() false end }
|
|
15
|
+
Phocus.method_pattern = /^test_/
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# --------------------------------------------------
|
|
19
|
+
# minitest
|
|
20
|
+
# --------------------------------------------------
|
|
21
|
+
if defined?(MiniTest::Unit::TestCase)
|
|
22
|
+
|
|
23
|
+
MiniTest::Unit::TestCase.class_eval { include ::Phocus }
|
|
24
|
+
Phocus.method_pattern = /^test_/
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# --------------------------------------------------
|
|
28
|
+
# context
|
|
29
|
+
# --------------------------------------------------
|
|
30
|
+
if defined?(Test::Unit::TestCase) &&
|
|
31
|
+
Test::Unit::TestCase.class_eval { class << self; self; end }.included_modules.map {|m| m.to_s }.include?('Context::Context')
|
|
32
|
+
|
|
33
|
+
Test::Unit::TestCase.class_eval { include ::Phocus }
|
|
34
|
+
Phocus.method_pattern = /test:/
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# --------------------------------------------------
|
|
38
|
+
# shoulda (test/unit)
|
|
39
|
+
# --------------------------------------------------
|
|
40
|
+
if defined?(Test::Unit::TestCase) &&
|
|
41
|
+
defined?(Shoulda)
|
|
42
|
+
|
|
43
|
+
Test::Unit::TestCase.class_eval { include ::Phocus }
|
|
44
|
+
Test::Unit::TestSuite.class_eval { def empty?() false end }
|
|
45
|
+
Phocus.method_pattern = /^test:/
|
|
46
|
+
end
|
data/lib/phocus.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
1
3
|
# Phocus let's you single out selected methods out of a defined group of methods.
|
|
2
4
|
#
|
|
3
5
|
# It is intended to be used to focus one or more tests in a test suite,
|
|
@@ -93,7 +95,7 @@ module Phocus
|
|
|
93
95
|
# If the method belongs to target group (method_pattern), then remove it
|
|
94
96
|
# unless it is focused.
|
|
95
97
|
#
|
|
96
|
-
#
|
|
98
|
+
# We don't want any methods removed if focus is never used, so until it is,
|
|
97
99
|
# keep a reference to methods being defined so that we can come back and
|
|
98
100
|
# remove them later.
|
|
99
101
|
#
|
|
@@ -117,3 +119,5 @@ module Phocus
|
|
|
117
119
|
end
|
|
118
120
|
end
|
|
119
121
|
end
|
|
122
|
+
|
|
123
|
+
require Pathname(__FILE__).dirname.expand_path + 'phocus/autodetect'
|
data/phocus.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phocus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Aumont
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-06-10 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -36,11 +36,7 @@ files:
|
|
|
36
36
|
- TODO
|
|
37
37
|
- lib
|
|
38
38
|
- lib/phocus
|
|
39
|
-
- lib/phocus/
|
|
40
|
-
- lib/phocus/shoulda.rb
|
|
41
|
-
- lib/phocus/contest.rb
|
|
42
|
-
- lib/phocus/minitest.rb
|
|
43
|
-
- lib/phocus/test_unit.rb
|
|
39
|
+
- lib/phocus/autodetect.rb
|
|
44
40
|
- lib/phocus.rb
|
|
45
41
|
- phocus.gemspec
|
|
46
42
|
- LICENSE
|
data/test/README
CHANGED
data/test/compat/test_contest.rb
CHANGED
data/test/compat/test_context.rb
CHANGED
data/test/compat/test_shoulda.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mynyml-phocus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Aumont
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-06-09 21:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -36,11 +36,7 @@ files:
|
|
|
36
36
|
- TODO
|
|
37
37
|
- lib
|
|
38
38
|
- lib/phocus
|
|
39
|
-
- lib/phocus/
|
|
40
|
-
- lib/phocus/shoulda.rb
|
|
41
|
-
- lib/phocus/contest.rb
|
|
42
|
-
- lib/phocus/minitest.rb
|
|
43
|
-
- lib/phocus/test_unit.rb
|
|
39
|
+
- lib/phocus/autodetect.rb
|
|
44
40
|
- lib/phocus.rb
|
|
45
41
|
- phocus.gemspec
|
|
46
42
|
- LICENSE
|
data/lib/phocus/contest.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
require 'contest'
|
|
3
|
-
|
|
4
|
-
root = Pathname(__FILE__).dirname.parent.parent.expand_path
|
|
5
|
-
require root + 'lib/phocus'
|
|
6
|
-
|
|
7
|
-
module Test #:nodoc: all
|
|
8
|
-
class Unit::TestCase
|
|
9
|
-
include ::Phocus
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Phocus.method_pattern = /^test_/
|
data/lib/phocus/context.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
require 'context'
|
|
3
|
-
|
|
4
|
-
root = Pathname(__FILE__).dirname.parent.parent.expand_path
|
|
5
|
-
require root + 'lib/phocus'
|
|
6
|
-
|
|
7
|
-
module Test #:nodoc: all
|
|
8
|
-
class Unit::TestCase
|
|
9
|
-
include ::Phocus
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Phocus.method_pattern = /test:/
|
data/lib/phocus/minitest.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
require 'minitest/unit'
|
|
3
|
-
|
|
4
|
-
root = Pathname(__FILE__).dirname.parent.parent.expand_path
|
|
5
|
-
require root + 'lib/phocus'
|
|
6
|
-
|
|
7
|
-
module MiniTest #:nodoc: all
|
|
8
|
-
class Unit::TestCase
|
|
9
|
-
include ::Phocus
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Phocus.method_pattern = /^test_/
|
|
14
|
-
|
|
15
|
-
MiniTest::Unit.autorun
|
data/lib/phocus/shoulda.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
require 'shoulda'
|
|
4
|
-
|
|
5
|
-
root = Pathname(__FILE__).dirname.parent.parent.expand_path
|
|
6
|
-
require root + 'lib/phocus'
|
|
7
|
-
|
|
8
|
-
module Test #:nodoc: all
|
|
9
|
-
class Unit::TestCase
|
|
10
|
-
include ::Phocus
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module Test #:nodoc: all
|
|
15
|
-
class Unit::TestSuite
|
|
16
|
-
# TODO only override when @@__focused
|
|
17
|
-
def empty?
|
|
18
|
-
false
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
Phocus.method_pattern = /^test:/
|
data/lib/phocus/test_unit.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
|
|
4
|
-
root = Pathname(__FILE__).dirname.parent.parent.expand_path
|
|
5
|
-
require root + 'lib/phocus'
|
|
6
|
-
|
|
7
|
-
module Test #:nodoc: all
|
|
8
|
-
class Unit::TestCase
|
|
9
|
-
include ::Phocus
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
module Test #:nodoc: all
|
|
14
|
-
class Unit::TestSuite
|
|
15
|
-
# TODO only override when @@__focused
|
|
16
|
-
def empty?
|
|
17
|
-
false
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
Phocus.method_pattern = /^test_/
|