phocus 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Manifest +19 -0
- data/README +7 -10
- data/Rakefile +71 -61
- data/TODO +3 -1
- data/gem.watchr +39 -0
- data/lib/phocus.rb +2 -3
- data/lib/phocus/autodetect.rb +3 -9
- data/phocus.gemspec +71 -21
- data/specs.watchr +37 -0
- data/test/README +1 -1
- data/test/compat/test_contest.rb +0 -7
- data/test/compat/test_context.rb +5 -0
- data/test/compat/test_minitest.rb +0 -7
- data/test/compat/test_shoulda.rb +0 -9
- data/test/compat/test_test_unit.rb +0 -7
- data/test/test_helper.rb +5 -13
- data/test/test_phocus.rb +110 -122
- metadata +71 -18
data/.gitignore
ADDED
data/Manifest
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
.gitignore
|
2
|
+
LICENSE
|
3
|
+
Manifest
|
4
|
+
README
|
5
|
+
Rakefile
|
6
|
+
TODO
|
7
|
+
gem.watchr
|
8
|
+
lib/phocus.rb
|
9
|
+
lib/phocus/autodetect.rb
|
10
|
+
phocus.gemspec
|
11
|
+
specs.watchr
|
12
|
+
test/README
|
13
|
+
test/compat/test_contest.rb
|
14
|
+
test/compat/test_context.rb
|
15
|
+
test/compat/test_minitest.rb
|
16
|
+
test/compat/test_shoulda.rb
|
17
|
+
test/compat/test_test_unit.rb
|
18
|
+
test/test_helper.rb
|
19
|
+
test/test_phocus.rb
|
data/README
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Phocus let's you temporarily focus some tests, ignoring all others, even across test classes.
|
4
4
|
|
5
|
+
==== Install
|
6
|
+
|
7
|
+
gem install phocus --source http://gemcutter.org
|
5
8
|
|
6
9
|
==== Features
|
7
10
|
|
@@ -12,11 +15,9 @@ Phocus let's you temporarily focus some tests, ignoring all others, even across
|
|
12
15
|
* Simple code (< 50 LOCs)
|
13
16
|
* Compatible with various testing frameworks
|
14
17
|
|
15
|
-
|
16
18
|
==== Examples
|
17
19
|
|
18
20
|
require 'test/unit'
|
19
|
-
require 'rubygems'
|
20
21
|
require 'phocus'
|
21
22
|
|
22
23
|
class TestUser < Test::Unit::TestCase
|
@@ -43,17 +44,17 @@ Phocus let's you temporarily focus some tests, ignoring all others, even across
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
Executing these tests (say with
|
47
|
-
only run
|
47
|
+
Executing these tests (say with +rake test+ or +autotest+), will
|
48
|
+
only run +test_foo+ and +test_xyz+.
|
48
49
|
|
49
|
-
Also works fine with
|
50
|
+
Also works fine with +test "description"+ style tests (or +it+,
|
51
|
+
or +should+, ...).
|
50
52
|
|
51
53
|
focus
|
52
54
|
test "abc" do
|
53
55
|
assert true
|
54
56
|
end
|
55
57
|
|
56
|
-
|
57
58
|
==== Testing Framework Compatibility
|
58
59
|
|
59
60
|
Phocus is known to be compatible with the following testing frameworks (see test/compat/*):
|
@@ -68,12 +69,8 @@ It is possibly compatible out of the box with other test/unit-based testing
|
|
68
69
|
frameworks as well, but it should be fairly easy to set up if it isn't (include
|
69
70
|
Phocus in parent testcase class and set proper method_pattern. See rdocs)
|
70
71
|
|
71
|
-
|
72
72
|
==== Links
|
73
73
|
|
74
74
|
source:: http://github.com/mynyml/phocus
|
75
75
|
rdocs:: http://docs.github.com/mynyml/phocus
|
76
76
|
|
77
|
-
|
78
|
-
==== License
|
79
|
-
MIT. See LICENSE file.
|
data/Rakefile
CHANGED
@@ -1,79 +1,89 @@
|
|
1
|
+
require 'rake/rdoctask'
|
2
|
+
|
1
3
|
# --------------------------------------------------
|
2
|
-
#
|
4
|
+
# Gem
|
3
5
|
# --------------------------------------------------
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def gemspec
|
7
|
+
@gemspec ||= Gem::Specification.new do |s|
|
8
|
+
s.name = "phocus"
|
9
|
+
s.summary = "Run focused tests"
|
10
|
+
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."
|
11
|
+
s.author = "Martin Aumont"
|
12
|
+
s.email = "mynyml@gmail.com"
|
13
|
+
s.homepage = "http://github.com/mynyml/watchr"
|
14
|
+
s.rubyforge_project = "phocus"
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.require_path = "lib"
|
17
|
+
s.version = "1.1"
|
18
|
+
s.files = File.read("Manifest").strip.split("\n")
|
8
19
|
|
9
|
-
|
10
|
-
|
11
|
-
|
20
|
+
s.add_development_dependency 'nanotest'
|
21
|
+
s.add_development_dependency 'minitest'
|
22
|
+
s.add_development_dependency 'thoughtbot-shoulda'
|
23
|
+
s.add_development_dependency 'citrusbyte-contest'
|
24
|
+
s.add_development_dependency 'jeremymcanally-context'
|
25
|
+
end
|
26
|
+
end
|
12
27
|
|
13
|
-
|
14
|
-
|
28
|
+
desc "Create a Ruby GEM package with the given name and version."
|
29
|
+
task(:gem) do
|
30
|
+
file = Gem::Builder.new(gemspec).build
|
31
|
+
FileUtils.mv file, "pkg/#{file}", :verbose => true
|
15
32
|
end
|
16
33
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
34
|
+
desc "Create gemspec file"
|
35
|
+
task(:gemspec) do
|
36
|
+
open("#{gemspec.name}.gemspec", 'w') {|f| f << YAML.dump(gemspec) }
|
21
37
|
end
|
22
38
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
39
|
+
# --------------------------------------------------
|
40
|
+
# Tests
|
41
|
+
# --------------------------------------------------
|
42
|
+
namespace(:test) do
|
43
|
+
|
44
|
+
desc "run framework compatibility tests"
|
45
|
+
task(:all) do
|
46
|
+
paths = %w(
|
47
|
+
test/compat/test_contest.rb
|
48
|
+
test/compat/test_context.rb
|
49
|
+
test/compat/test_minitest.rb
|
50
|
+
test/compat/test_shoulda.rb
|
51
|
+
test/compat/test_test_unit.rb
|
52
|
+
test/test_phocus.rb
|
53
|
+
)
|
54
|
+
paths.each do |path|
|
55
|
+
cmd = "ruby -rubygems -I.:lib #{path}"
|
56
|
+
puts(cmd) if ENV['VERBOSE']
|
57
|
+
system(cmd)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Run all tests on multiple ruby versions (requires rvm)"
|
62
|
+
task(:portability) do
|
63
|
+
versions = %w( 1.8.6 1.8.7 1.9 1.9.2 jruby )
|
64
|
+
versions.each do |version|
|
65
|
+
system <<-BASH
|
66
|
+
bash -c 'source ~/.rvm/scripts/rvm;
|
67
|
+
rvm use #{version};
|
68
|
+
echo "--------- #{version} ----------\n";
|
69
|
+
rake -s test:all'
|
70
|
+
BASH
|
71
|
+
end
|
72
|
+
end
|
34
73
|
end
|
35
74
|
|
75
|
+
# --------------------------------------------------
|
76
|
+
# Docs
|
77
|
+
# --------------------------------------------------
|
36
78
|
desc "Generate rdoc documentation."
|
37
|
-
Rake::RDocTask.new(
|
79
|
+
Rake::RDocTask.new(:rdoc => 'rdoc', :clobber_rdoc => 'rdoc:clean', :rerdoc => 'rdoc:force') do |rdoc|
|
38
80
|
rdoc.rdoc_dir = 'doc/rdoc'
|
39
|
-
rdoc.title =
|
81
|
+
rdoc.title = 'Phocus'
|
40
82
|
rdoc.options << '--line-numbers' << '--inline-source'
|
41
83
|
rdoc.options << '--charset' << 'utf-8'
|
42
84
|
rdoc.rdoc_files.include('README')
|
85
|
+
rdoc.rdoc_files.include('LICENSE')
|
86
|
+
rdoc.rdoc_files.include('VERSION')
|
43
87
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
-
}
|
45
|
-
|
46
|
-
Rake::GemPackageTask.new(spec) do |p|
|
47
|
-
p.gem_spec = spec
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "Remove package products"
|
51
|
-
task :clean => :clobber_package
|
52
|
-
|
53
|
-
desc "Update the gemspec for GitHub's gem server"
|
54
|
-
task :gemspec do
|
55
|
-
Pathname("#{spec.name}.gemspec").open('w') {|f| f << YAML.dump(spec) }
|
56
88
|
end
|
57
89
|
|
58
|
-
desc "Install gem"
|
59
|
-
task :install => [:clobber, :package] do
|
60
|
-
sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
|
61
|
-
end
|
62
|
-
|
63
|
-
desc "Uninstall gem"
|
64
|
-
task :uninstall => :clean do
|
65
|
-
sh "#{SUDO} #{gem} uninstall -v #{spec.version} -x #{spec.name}"
|
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
data/gem.watchr
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Run me with:
|
2
|
+
#
|
3
|
+
# $ watchr gem.watchr
|
4
|
+
#
|
5
|
+
# Manifest file can be automatically generated with:
|
6
|
+
#
|
7
|
+
# $ cat .git/hooks/post-commit
|
8
|
+
# #!bin/sh
|
9
|
+
# git ls-files > Manifest
|
10
|
+
#
|
11
|
+
|
12
|
+
# --------------------------------------------------
|
13
|
+
# Helpers
|
14
|
+
# --------------------------------------------------
|
15
|
+
def build
|
16
|
+
system "rake -s gemspec; rake -s gem"; puts
|
17
|
+
end
|
18
|
+
|
19
|
+
# --------------------------------------------------
|
20
|
+
# Watchr Rules
|
21
|
+
# --------------------------------------------------
|
22
|
+
watch( '^Rakefile$' ) { build }
|
23
|
+
watch( '^Manifest$' ) { build }
|
24
|
+
watch( '^VERSION$' ) { build }
|
25
|
+
|
26
|
+
# --------------------------------------------------
|
27
|
+
# Signal Handling
|
28
|
+
# --------------------------------------------------
|
29
|
+
# Ctrl-\
|
30
|
+
Signal.trap('QUIT') do
|
31
|
+
puts " --- Building Gem ---\n\n"
|
32
|
+
build
|
33
|
+
end
|
34
|
+
|
35
|
+
# Ctrl-C
|
36
|
+
Signal.trap('INT') { abort("\n") }
|
37
|
+
|
38
|
+
|
39
|
+
# vim:ft=ruby
|
data/lib/phocus.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'pathname'
|
2
1
|
|
3
2
|
# Phocus let's you single out selected methods out of a defined group of methods.
|
4
3
|
#
|
@@ -100,7 +99,6 @@ module Phocus
|
|
100
99
|
# remove them later.
|
101
100
|
#
|
102
101
|
def method_added(name) #:nodoc:
|
103
|
-
super
|
104
102
|
if name.to_s.match(Phocus.method_pattern)
|
105
103
|
if @@__focused
|
106
104
|
@@__focus_next ? @@__focus_next = false : remove_method(name)
|
@@ -120,4 +118,5 @@ module Phocus
|
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
123
|
-
require
|
121
|
+
require 'phocus/autodetect'
|
122
|
+
|
data/lib/phocus/autodetect.rb
CHANGED
@@ -4,14 +4,13 @@
|
|
4
4
|
# Somewhat hackish, but simple/straightforward. If there ever is a need for
|
5
5
|
# extendability I'll gladly refactor.
|
6
6
|
|
7
|
-
|
8
7
|
# --------------------------------------------------
|
9
8
|
# test/unit, contest
|
10
9
|
# --------------------------------------------------
|
11
10
|
if defined?(Test::Unit::TestCase)
|
12
11
|
|
13
12
|
Test::Unit::TestCase.class_eval { include ::Phocus }
|
14
|
-
Test::Unit::TestSuite.class_eval { def empty?() false end }
|
13
|
+
Test::Unit::TestSuite.class_eval { def empty?() false end } if defined?(Test::Unit::TestSuite)
|
15
14
|
Phocus.method_pattern = /^test_/
|
16
15
|
end
|
17
16
|
|
@@ -29,18 +28,13 @@ end
|
|
29
28
|
# --------------------------------------------------
|
30
29
|
if defined?(Test::Unit::TestCase) &&
|
31
30
|
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
31
|
Phocus.method_pattern = /test:/
|
35
32
|
end
|
36
33
|
|
37
34
|
# --------------------------------------------------
|
38
35
|
# shoulda (test/unit)
|
39
36
|
# --------------------------------------------------
|
40
|
-
if defined?(
|
41
|
-
defined?(Shoulda)
|
42
|
-
|
43
|
-
Test::Unit::TestCase.class_eval { include ::Phocus }
|
44
|
-
Test::Unit::TestSuite.class_eval { def empty?() false end }
|
37
|
+
if defined?(Shoulda)
|
45
38
|
Phocus.method_pattern = /^test:/
|
46
39
|
end
|
40
|
+
|
data/phocus.gemspec
CHANGED
@@ -9,10 +9,59 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-05 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: minitest
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thoughtbot-shoulda
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: citrusbyte-contest
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: jeremymcanally-context
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: expectations
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
16
65
|
description: Tell test/unit exactly which tests you want run. It will ignore all the other ones and let you concentrate on a few.
|
17
66
|
email: mynyml@gmail.com
|
18
67
|
executables: []
|
@@ -22,27 +71,28 @@ extensions: []
|
|
22
71
|
extra_rdoc_files: []
|
23
72
|
|
24
73
|
files:
|
74
|
+
- .gitignore
|
75
|
+
- LICENSE
|
76
|
+
- Manifest
|
77
|
+
- README
|
25
78
|
- Rakefile
|
26
|
-
- test
|
27
|
-
- test/test_phocus.rb
|
28
|
-
- test/compat
|
29
|
-
- test/compat/test_shoulda.rb
|
30
|
-
- test/compat/test_context.rb
|
31
|
-
- test/compat/test_contest.rb
|
32
|
-
- test/compat/test_test_unit.rb
|
33
|
-
- test/compat/test_minitest.rb
|
34
|
-
- test/README
|
35
|
-
- test/test_helper.rb
|
36
79
|
- TODO
|
37
|
-
-
|
38
|
-
-
|
39
|
-
- lib/phocus/autodetect.rb
|
80
|
+
- VERSION
|
81
|
+
- gem.watchr
|
40
82
|
- lib/phocus.rb
|
83
|
+
- lib/phocus/autodetect.rb
|
41
84
|
- phocus.gemspec
|
42
|
-
-
|
43
|
-
- README
|
85
|
+
- specs.watchr
|
86
|
+
- test/README
|
87
|
+
- test/compat/test_contest.rb
|
88
|
+
- test/compat/test_context.rb
|
89
|
+
- test/compat/test_minitest.rb
|
90
|
+
- test/compat/test_shoulda.rb
|
91
|
+
- test/compat/test_test_unit.rb
|
92
|
+
- test/test_helper.rb
|
93
|
+
- test/test_phocus.rb
|
44
94
|
has_rdoc: true
|
45
|
-
homepage:
|
95
|
+
homepage: http://github.com/mynyml/watchr
|
46
96
|
licenses: []
|
47
97
|
|
48
98
|
post_install_message:
|
@@ -64,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
114
|
version:
|
65
115
|
requirements: []
|
66
116
|
|
67
|
-
rubyforge_project:
|
68
|
-
rubygems_version: 1.3.
|
117
|
+
rubyforge_project: phocus
|
118
|
+
rubygems_version: 1.3.5
|
69
119
|
signing_key:
|
70
120
|
specification_version: 3
|
71
121
|
summary: Run focused tests on test/unit.
|
data/specs.watchr
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Run me with:
|
2
|
+
#
|
3
|
+
# $ watchr specs.watchr
|
4
|
+
|
5
|
+
# --------------------------------------------------
|
6
|
+
# Helpers
|
7
|
+
# --------------------------------------------------
|
8
|
+
def run(cmd)
|
9
|
+
puts(cmd)
|
10
|
+
system(cmd)
|
11
|
+
end
|
12
|
+
|
13
|
+
def run_all_tests
|
14
|
+
# see Rakefile for the definition of the test:all task
|
15
|
+
system( "rake -s test:all VERBOSE=true" )
|
16
|
+
end
|
17
|
+
|
18
|
+
# --------------------------------------------------
|
19
|
+
# Watchr Rules
|
20
|
+
# --------------------------------------------------
|
21
|
+
watch( '^test.*/test_.*\.rb' ) { |m| run( "ruby -rubygems -Ilib %s" % m[0] ) }
|
22
|
+
watch( '^lib/phocus\.rb' ) { |m| run( "ruby -rubygems -Ilib test/test_phocus.rb" ) }
|
23
|
+
watch( '^lib/phocus/autodetect\.rb' ) { run_all_tests }
|
24
|
+
watch( '^test/test_helper\.rb' ) { run_all_tests }
|
25
|
+
|
26
|
+
# --------------------------------------------------
|
27
|
+
# Signal Handling
|
28
|
+
# --------------------------------------------------
|
29
|
+
# Ctrl-\
|
30
|
+
Signal.trap('QUIT') do
|
31
|
+
puts " --- Running all tests ---\n\n"
|
32
|
+
run_all_tests
|
33
|
+
end
|
34
|
+
|
35
|
+
# Ctrl-C
|
36
|
+
Signal.trap('INT') { abort("\n") }
|
37
|
+
|
data/test/README
CHANGED
data/test/compat/test_contest.rb
CHANGED
@@ -2,13 +2,6 @@ require 'test/test_helper'
|
|
2
2
|
require 'contest'
|
3
3
|
require 'lib/phocus'
|
4
4
|
|
5
|
-
class Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
reset_phocused_classes(TestContestA, TestContestB, TestContestC)
|
8
|
-
reset_phocus
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
5
|
# should focus a method
|
13
6
|
class TestContestA < Test::Unit::TestCase
|
14
7
|
test "foo" do
|
data/test/compat/test_context.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# context doesn't run under 1.9 (despite its tests passing)
|
2
|
+
if RUBY_VERSION <= "1.8.7"
|
3
|
+
|
1
4
|
require 'test/test_helper'
|
2
5
|
require 'context'
|
3
6
|
require 'lib/phocus'
|
@@ -40,3 +43,5 @@ class TestContextC < Test::Unit::TestCase
|
|
40
43
|
test "xyz" do
|
41
44
|
end
|
42
45
|
end
|
46
|
+
|
47
|
+
end #/if RUBY_VERSION
|
@@ -2,13 +2,6 @@ require 'test/test_helper'
|
|
2
2
|
require 'minitest/autorun'
|
3
3
|
require 'lib/phocus'
|
4
4
|
|
5
|
-
class MiniTest::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
reset_phocused_classes(TestMiniTestA, TestMiniTestB, TestMiniTestC)
|
8
|
-
reset_phocus
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
5
|
# should focus a method
|
13
6
|
class TestMiniTestA < MiniTest::Unit::TestCase
|
14
7
|
def test_foo
|
data/test/compat/test_shoulda.rb
CHANGED
@@ -3,15 +3,6 @@ require 'test/unit'
|
|
3
3
|
require 'shoulda'
|
4
4
|
require 'lib/phocus'
|
5
5
|
|
6
|
-
# testing shoulda/test_unit
|
7
|
-
|
8
|
-
class Test::Unit::TestCase
|
9
|
-
def setup
|
10
|
-
reset_phocused_classes(TestShouldaA, TestShouldaB, TestShouldaC)
|
11
|
-
reset_phocus
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
6
|
# should focus a method
|
16
7
|
class TestShouldaA < Test::Unit::TestCase
|
17
8
|
should "foo" do
|
@@ -2,13 +2,6 @@ require 'test/test_helper'
|
|
2
2
|
require 'test/unit'
|
3
3
|
require 'lib/phocus'
|
4
4
|
|
5
|
-
class Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
reset_phocused_classes(TestTestUnitA, TestTestUnitB, TestTestUnitC)
|
8
|
-
reset_phocus
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
5
|
# should focus a method
|
13
6
|
class TestTestUnitA < Test::Unit::TestCase
|
14
7
|
def test_foo
|
data/test/test_helper.rb
CHANGED
@@ -1,27 +1,19 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'set'
|
3
|
-
require 'rubygems'
|
4
1
|
begin
|
5
2
|
require 'ruby-debug'
|
6
3
|
rescue LoadError, RuntimeError
|
7
4
|
end
|
8
5
|
|
9
|
-
class Object
|
10
|
-
def self.metaclass
|
11
|
-
(class << self; self; end)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
6
|
def reset_phocused_classes(*classes)
|
16
7
|
Array(classes).flatten.each do |klass|
|
17
|
-
klass.
|
18
|
-
|
19
|
-
class_variable_set(:@@__focus_next, false )
|
20
|
-
class_variable_set(:@@__test_methods, {} )
|
8
|
+
klass.class_eval do
|
9
|
+
instance_methods(false).each {|name| remove_method(name) }
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|
24
13
|
|
25
14
|
def reset_phocus
|
26
15
|
Phocus.method_pattern = nil
|
16
|
+
Phocus::ClassMethods.send(:class_variable_set, :@@__focused, false)
|
17
|
+
Phocus::ClassMethods.send(:class_variable_set, :@@__focus_next, false)
|
18
|
+
Phocus::ClassMethods.send(:class_variable_set, :@@__test_methods, {} )
|
27
19
|
end
|
data/test/test_phocus.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test/test_helper'
|
2
|
-
require '
|
2
|
+
require 'nanotest'
|
3
3
|
require 'lib/phocus'
|
4
4
|
|
5
5
|
class TestCase
|
@@ -9,128 +9,116 @@ class TestA < TestCase; end
|
|
9
9
|
class TestB < TestCase; end
|
10
10
|
|
11
11
|
def reset
|
12
|
-
|
13
|
-
reset_phocused_classes(*klasses)
|
14
|
-
klasses.each do |klass|
|
15
|
-
klass.class_eval do
|
16
|
-
instance_methods(false).each {|name| remove_method(name) }
|
17
|
-
end
|
18
|
-
end
|
12
|
+
reset_phocused_classes(TestA, TestB)
|
19
13
|
reset_phocus
|
20
14
|
end
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
expect %w( test_baz test:bar).to_set do
|
39
|
-
reset
|
40
|
-
Phocus.method_pattern = /^test:/
|
41
|
-
class TestA
|
42
|
-
define_method(:'test:foo') {}
|
43
|
-
focus
|
44
|
-
define_method(:'test:bar') {}
|
45
|
-
define_method(:'test_baz') {}
|
46
|
-
end
|
47
|
-
|
48
|
-
TestA.instance_methods(false).to_set
|
49
|
-
end
|
50
|
-
|
51
|
-
## focused tests
|
52
|
-
|
53
|
-
# only keeps focused method
|
54
|
-
expect %w( test_foo ).to_set do
|
55
|
-
reset
|
56
|
-
class TestA
|
57
|
-
focus
|
58
|
-
def test_foo() end
|
59
|
-
def test_bar() end
|
60
|
-
end
|
61
|
-
|
62
|
-
TestA.instance_methods(false).to_set
|
63
|
-
end
|
64
|
-
|
65
|
-
# keeps more than one focused methods
|
66
|
-
expect %w( test_foo test_bar ).to_set do
|
67
|
-
reset
|
68
|
-
class TestA
|
69
|
-
focus
|
70
|
-
def test_foo() end
|
71
|
-
focus
|
72
|
-
def test_bar() end
|
73
|
-
def test_baz() end
|
74
|
-
end
|
75
|
-
|
76
|
-
TestA.instance_methods(false).to_set
|
77
|
-
end
|
78
|
-
|
79
|
-
# focuses across subclasses
|
80
|
-
expect %w( test_foo ).to_set do
|
81
|
-
reset
|
82
|
-
class TestA
|
83
|
-
focus
|
84
|
-
def test_foo() end
|
85
|
-
def test_bar() end
|
86
|
-
end
|
87
|
-
class TestB
|
88
|
-
def test_abc() end
|
89
|
-
end
|
90
|
-
|
91
|
-
TestA.instance_methods(false).to_set +
|
92
|
-
TestB.instance_methods(false).to_set
|
93
|
-
end
|
94
|
-
|
95
|
-
# focuses more than one methods across subclasses
|
96
|
-
expect %w( test_foo test_def ).to_set do
|
97
|
-
reset
|
98
|
-
class TestA
|
99
|
-
focus
|
100
|
-
def test_foo() end
|
101
|
-
def test_bar() end
|
102
|
-
end
|
103
|
-
class TestB
|
104
|
-
def test_abc() end
|
105
|
-
focus
|
106
|
-
def test_def() end
|
107
|
-
end
|
108
|
-
|
109
|
-
TestA.instance_methods(false).to_set +
|
110
|
-
TestB.instance_methods(false).to_set
|
111
|
-
end
|
112
|
-
|
113
|
-
# non-test methods aren't touched
|
114
|
-
expect %w( test_foo helper ).to_set do
|
115
|
-
reset
|
116
|
-
class TestA
|
117
|
-
focus
|
118
|
-
def test_foo() end
|
119
|
-
def test_bar() end
|
120
|
-
def helper() end
|
121
|
-
end
|
122
|
-
|
123
|
-
TestA.instance_methods(false).to_set
|
124
|
-
end
|
125
|
-
|
126
|
-
# test methods don't get removed if nothing is focused (control test)
|
127
|
-
expect %w( test_foo test_bar ).to_set do
|
128
|
-
reset
|
129
|
-
class TestA
|
130
|
-
def test_foo() end
|
131
|
-
def test_bar() end
|
132
|
-
end
|
133
|
-
|
134
|
-
TestA.instance_methods(false).to_set
|
135
|
-
end
|
16
|
+
include NanoTest
|
17
|
+
|
18
|
+
# api
|
19
|
+
reset
|
20
|
+
assert { TestA.respond_to?(:focus ) }
|
21
|
+
assert { TestA.respond_to?(:focused) }
|
22
|
+
assert { TestA.respond_to?(:phocus ) }
|
23
|
+
|
24
|
+
# method pattern
|
25
|
+
reset
|
26
|
+
Phocus.method_pattern = /^test:/
|
27
|
+
class TestA
|
28
|
+
define_method(:'test:foo') {}
|
29
|
+
focus
|
30
|
+
define_method(:'test:bar') {}
|
31
|
+
define_method(:'test_baz') {}
|
136
32
|
end
|
33
|
+
|
34
|
+
assert { TestA.method_defined?(:'test_baz') }
|
35
|
+
assert { TestA.method_defined?(:'test:bar') }
|
36
|
+
assert { not TestA.method_defined?(:'test:foo') }
|
37
|
+
|
38
|
+
|
39
|
+
# only keeps focused method
|
40
|
+
reset
|
41
|
+
class TestA
|
42
|
+
focus
|
43
|
+
def test_foo() end
|
44
|
+
def test_bar() end
|
45
|
+
end
|
46
|
+
|
47
|
+
assert { TestA.method_defined?(:test_foo) }
|
48
|
+
assert { not TestA.method_defined?(:test_bar) }
|
49
|
+
|
50
|
+
|
51
|
+
# keeps more than one focused methods
|
52
|
+
reset
|
53
|
+
class TestA
|
54
|
+
focus
|
55
|
+
def test_foo() end
|
56
|
+
focus
|
57
|
+
def test_bar() end
|
58
|
+
def test_baz() end
|
59
|
+
end
|
60
|
+
|
61
|
+
assert { TestA.method_defined?(:test_foo) }
|
62
|
+
assert { TestA.method_defined?(:test_bar) }
|
63
|
+
assert { not TestA.method_defined?(:test_baz) }
|
64
|
+
|
65
|
+
|
66
|
+
# focuses across subclasses
|
67
|
+
reset
|
68
|
+
class TestA
|
69
|
+
focus
|
70
|
+
def test_foo() end
|
71
|
+
def test_bar() end
|
72
|
+
end
|
73
|
+
class TestB
|
74
|
+
def test_abc() end
|
75
|
+
end
|
76
|
+
|
77
|
+
assert { TestA.method_defined?(:test_foo) }
|
78
|
+
assert { not TestA.method_defined?(:test_bar) }
|
79
|
+
assert { not TestB.method_defined?(:test_abc) }
|
80
|
+
|
81
|
+
|
82
|
+
# focuses more than one methods across subclasses
|
83
|
+
reset
|
84
|
+
class TestA
|
85
|
+
focus
|
86
|
+
def test_foo() end
|
87
|
+
def test_bar() end
|
88
|
+
end
|
89
|
+
class TestB
|
90
|
+
def test_abc() end
|
91
|
+
focus
|
92
|
+
def test_def() end
|
93
|
+
end
|
94
|
+
|
95
|
+
assert { TestA.method_defined?(:test_foo) }
|
96
|
+
assert { TestB.method_defined?(:test_def) }
|
97
|
+
assert { not TestA.method_defined?(:test_bar) }
|
98
|
+
assert { not TestB.method_defined?(:test_abc) }
|
99
|
+
|
100
|
+
|
101
|
+
# non-test methods aren't touched
|
102
|
+
reset
|
103
|
+
class TestA
|
104
|
+
focus
|
105
|
+
def test_foo() end
|
106
|
+
def test_bar() end
|
107
|
+
def helper() end
|
108
|
+
end
|
109
|
+
|
110
|
+
assert { TestA.method_defined?(:helper) }
|
111
|
+
assert { TestA.method_defined?(:test_foo) }
|
112
|
+
assert { not TestA.method_defined?(:test_bar) }
|
113
|
+
|
114
|
+
|
115
|
+
# methods don't get removed if nothing is focused (control test)
|
116
|
+
reset
|
117
|
+
class TestA
|
118
|
+
def test_foo() end
|
119
|
+
def test_bar() end
|
120
|
+
end
|
121
|
+
|
122
|
+
assert { TestA.method_defined?(:test_foo) }
|
123
|
+
assert { TestA.method_defined?(:test_bar) }
|
124
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phocus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.1"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Aumont
|
@@ -9,10 +9,59 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-30 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nanotest
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: minitest
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: thoughtbot-shoulda
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: citrusbyte-contest
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeremymcanally-context
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
16
65
|
description: Tell test/unit exactly which tests you want run. It will ignore all the other ones and let you concentrate on a few.
|
17
66
|
email: mynyml@gmail.com
|
18
67
|
executables: []
|
@@ -22,23 +71,27 @@ extensions: []
|
|
22
71
|
extra_rdoc_files: []
|
23
72
|
|
24
73
|
files:
|
74
|
+
- .gitignore
|
75
|
+
- LICENSE
|
76
|
+
- Manifest
|
77
|
+
- README
|
25
78
|
- Rakefile
|
26
|
-
- test/test_phocus.rb
|
27
|
-
- test/compat/test_shoulda.rb
|
28
|
-
- test/compat/test_context.rb
|
29
|
-
- test/compat/test_contest.rb
|
30
|
-
- test/compat/test_test_unit.rb
|
31
|
-
- test/compat/test_minitest.rb
|
32
|
-
- test/README
|
33
|
-
- test/test_helper.rb
|
34
79
|
- TODO
|
35
|
-
-
|
80
|
+
- gem.watchr
|
36
81
|
- lib/phocus.rb
|
82
|
+
- lib/phocus/autodetect.rb
|
37
83
|
- phocus.gemspec
|
38
|
-
-
|
39
|
-
- README
|
84
|
+
- specs.watchr
|
85
|
+
- test/README
|
86
|
+
- test/compat/test_contest.rb
|
87
|
+
- test/compat/test_context.rb
|
88
|
+
- test/compat/test_minitest.rb
|
89
|
+
- test/compat/test_shoulda.rb
|
90
|
+
- test/compat/test_test_unit.rb
|
91
|
+
- test/test_helper.rb
|
92
|
+
- test/test_phocus.rb
|
40
93
|
has_rdoc: true
|
41
|
-
homepage:
|
94
|
+
homepage: http://github.com/mynyml/watchr
|
42
95
|
licenses: []
|
43
96
|
|
44
97
|
post_install_message:
|
@@ -60,10 +113,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
113
|
version:
|
61
114
|
requirements: []
|
62
115
|
|
63
|
-
rubyforge_project:
|
116
|
+
rubyforge_project: phocus
|
64
117
|
rubygems_version: 1.3.5
|
65
118
|
signing_key:
|
66
119
|
specification_version: 3
|
67
|
-
summary: Run focused tests
|
120
|
+
summary: Run focused tests
|
68
121
|
test_files: []
|
69
122
|
|