phocus 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright © 2009 Martin Aumont (mynyml)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,79 @@
1
+ ==== Summary
2
+
3
+ Phocus let's you temporarily focus some tests, ignoring all others, even across test classes.
4
+
5
+
6
+ ==== Features
7
+
8
+ * Ultra simple to use
9
+ * Works accross testcase classes
10
+ * Works within contexts
11
+ * Can focus multiple tests
12
+ * Simple code (< 50 LOCs)
13
+ * Compatible with various testing frameworks
14
+
15
+
16
+ ==== Examples
17
+
18
+ require 'test/unit'
19
+ require 'rubygems'
20
+ require 'phocus'
21
+
22
+ class TestUser < Test::Unit::TestCase
23
+
24
+ focus
25
+ def test_foo
26
+ assert User.do_something
27
+ end
28
+
29
+ def test_bar
30
+ assert User.do_something_else
31
+ end
32
+ end
33
+
34
+ class TestAcmeWidget < Test::Unit::TestCase
35
+
36
+ def test_abc
37
+ assert true
38
+ end
39
+
40
+ focus
41
+ def test_xyz
42
+ assert true
43
+ end
44
+ end
45
+
46
+ Executing these tests (say with <tt>rake test</tt> or <tt>autotest</tt>), will
47
+ only run <tt>test_foo</tt> and <tt>test_xyz</tt>.
48
+
49
+ Also works fine with <tt>test "description"</tt> style tests.
50
+
51
+ focus
52
+ test "abc" do
53
+ assert true
54
+ end
55
+
56
+
57
+ ==== Testing Framework Compatibility
58
+
59
+ Phocus is known to be compatible with the following testing frameworks (see test/compat/*):
60
+
61
+ * test/unit
62
+ * minitest/unit
63
+ * shoulda
64
+ * context
65
+ * contest
66
+
67
+ It is possibly compatible out of the box with other test/unit-based testing
68
+ frameworks as well, but it should be fairly easy to set up if it isn't (include
69
+ Phocus in parent testcase class and set proper method_pattern. See rdocs)
70
+
71
+
72
+ ==== Links
73
+
74
+ source:: http://github.com/mynyml/phocus
75
+ rdocs:: http://docs.github.com/mynyml/phocus
76
+
77
+
78
+ ==== License
79
+ MIT. See LICENSE file.
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ # --------------------------------------------------
2
+ # based on thin's Rakefile (http://github.com/macournoyer/thin)
3
+ # --------------------------------------------------
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'pathname'
7
+ require 'yaml'
8
+
9
+ RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
10
+ WIN = (RUBY_PLATFORM =~ /mswin|cygwin/)
11
+ SUDO = (WIN ? "" : "sudo")
12
+
13
+ def gem
14
+ RUBY_1_9 ? 'gem19' : 'gem'
15
+ end
16
+
17
+ def all_except(res)
18
+ Dir['**/*'].reject do |path|
19
+ Array(res).any? {|re| path.match(re) }
20
+ end
21
+ end
22
+
23
+ spec = Gem::Specification.new do |s|
24
+ s.name = 'phocus'
25
+ s.version = '1.0'
26
+ s.summary = "Run focused tests on test/unit."
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
+ s.author = "Martin Aumont"
29
+ s.email = 'mynyml@gmail.com'
30
+ s.homepage = ''
31
+ s.has_rdoc = true
32
+ s.require_path = "lib"
33
+ s.files = all_except([/doc/, /pkg/])
34
+ end
35
+
36
+ desc "Generate rdoc documentation."
37
+ Rake::RDocTask.new("rdoc") { |rdoc|
38
+ rdoc.rdoc_dir = 'doc/rdoc'
39
+ rdoc.title = "Phocus"
40
+ rdoc.options << '--line-numbers' << '--inline-source'
41
+ rdoc.options << '--charset' << 'utf-8'
42
+ rdoc.rdoc_files.include('README')
43
+ 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
+ end
57
+
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 ADDED
@@ -0,0 +1,17 @@
1
+ o compatibility
2
+ o with test/unit plugins
3
+ x test/unit
4
+ x minitest
5
+ x context
6
+ x shoulda
7
+ x contest
8
+ o test/spec
9
+ ...
10
+ o Rails
11
+
12
+ o focus a group of tests at once
13
+
14
+ focus do
15
+ ...
16
+ ...
17
+ end
@@ -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 ADDED
@@ -0,0 +1,123 @@
1
+ require 'pathname'
2
+
3
+ # Phocus let's you single out selected methods out of a defined group of methods.
4
+ #
5
+ # It is intended to be used to focus one or more tests in a test suite,
6
+ # although it is generic enough that it could conceivably be used in other
7
+ # circumstances as well.
8
+ #
9
+ # Use the <tt>focus</tt> statement right before defining your test method.
10
+ #
11
+ # ===== Examples
12
+ # require 'test/unit'
13
+ # require 'phocus'
14
+ #
15
+ # Phocus.method_pattern = /^test_/
16
+ #
17
+ # class TestUser < Test::Unit::TestCase
18
+ # include Phocus
19
+ #
20
+ # focus
21
+ # def test_foo
22
+ # assert true
23
+ # end
24
+ #
25
+ # def test_bar
26
+ # flunk "not focused"
27
+ # end
28
+ # end
29
+ #
30
+ # When executed, only test_foo will be run. Can also be used on more than one
31
+ # methods.
32
+ #
33
+ # Phocus also let's you focus methods across classes, which is almost always
34
+ # the desired behaviour. Simply include the mixin in the parent class. In the
35
+ # case of test/unit and test/unit based testing frameworks, this means:
36
+ #
37
+ # class Test::Unit::TestCase
38
+ # include Phocus
39
+ # end
40
+ #
41
+ # Now focusing will work across *all* your tests. Not much benifit if you run
42
+ # your test files individually, but indispensable when using <tt>rake test</tt>
43
+ # or autotest.
44
+ #
45
+ module Phocus
46
+ class << self
47
+ attr_accessor :method_pattern
48
+
49
+ # Specify a pattern that identifies the names of the group of methods
50
+ # focusing will apply to.
51
+ #
52
+ # For example, when using test/unit, you want the relevant group of methods
53
+ # to be your test methods, which are the ones starting with <tt>test_</tt>.
54
+ #
55
+ # Phocus.method_pattern = /^test_/
56
+ #
57
+ # (which happens to be the default pattern)
58
+ #
59
+ # On the other hand, context (http://github.com/jeremymcanally/context),
60
+ # has test methods starting with <tt>test:</tt>, so you can specify:
61
+ #
62
+ # Phocus.method_pattern = /^test:/
63
+ #
64
+ # In reality, it's not so much that Phocus focuses on certain methods, but
65
+ # rather it ignores others. Since we don't want to ignore helper methods
66
+ # (setup, teardown, custom helpers, etc.), we must restrict the scope of
67
+ # ignored methods, which is what <tt>method_pattern</tt> allows us to do.
68
+ def method_pattern
69
+ @method_pattern || /^test_/
70
+ end
71
+ end
72
+
73
+ def self.included(base) #:nodoc:
74
+ base.extend ClassMethods
75
+ end
76
+
77
+ module ClassMethods
78
+ @@__test_methods = {}
79
+ @@__focused = false
80
+ @@__focus_next = false
81
+
82
+ # Use right before defining a method to focus it.
83
+ def focus
84
+ unless @@__focused
85
+ clear_test_methods!
86
+ @@__focused = true
87
+ end
88
+ @@__focus_next = true
89
+ end
90
+ # :stopdoc:
91
+ alias :focused :focus
92
+ alias :phocus :focus
93
+ # :startdoc:
94
+
95
+ # If the method belongs to target group (method_pattern), then remove it
96
+ # unless it is focused.
97
+ #
98
+ # We don't want any methods removed if focus is never used, so until it is,
99
+ # keep a reference to methods being defined so that we can come back and
100
+ # remove them later.
101
+ #
102
+ def method_added(name) #:nodoc:
103
+ super
104
+ if name.to_s.match(Phocus.method_pattern)
105
+ if @@__focused
106
+ @@__focus_next ? @@__focus_next = false : remove_method(name)
107
+ else
108
+ @@__test_methods[self] ||= []
109
+ @@__test_methods[self] << name
110
+ end
111
+ end
112
+ end
113
+
114
+ private
115
+ def clear_test_methods!
116
+ @@__test_methods.each do |klass, method_names|
117
+ method_names.each {|name| klass.class_eval { remove_method(name) } }
118
+ end
119
+ end
120
+ end
121
+ end
122
+
123
+ require Pathname(__FILE__).dirname.expand_path + 'phocus/autodetect'
data/phocus.gemspec ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phocus
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Martin Aumont
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-11 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ 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
+ email: mynyml@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - 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
+ - TODO
37
+ - lib
38
+ - lib/phocus
39
+ - lib/phocus/autodetect.rb
40
+ - lib/phocus.rb
41
+ - phocus.gemspec
42
+ - LICENSE
43
+ - README
44
+ has_rdoc: true
45
+ homepage: ""
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.3
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Run focused tests on test/unit.
72
+ test_files: []
73
+
data/test/README ADDED
@@ -0,0 +1,8 @@
1
+ Each test file uses it's own framework, so they must be run individually.
2
+
3
+ ruby test/test_phocus.rb
4
+ ruby test/compat/test_test_unit.rb
5
+ ruby test/compat/test_context.rb
6
+ ...
7
+
8
+ <tt>rake test_all</tt> will do just that.
@@ -0,0 +1,49 @@
1
+ require 'test/test_helper'
2
+ require 'contest'
3
+ require 'lib/phocus'
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
+ # should focus a method
13
+ class TestContestA < Test::Unit::TestCase
14
+ test "foo" do
15
+ flunk "not focused"
16
+ end
17
+
18
+ focus
19
+ test "bar" do
20
+ assert true
21
+ end
22
+
23
+ test "baz" do
24
+ flunk "not focused"
25
+ end
26
+ end
27
+
28
+ # should focus methods across test classes
29
+ class TestContestB < Test::Unit::TestCase
30
+ test "abc" do
31
+ flunk "not focused"
32
+ end
33
+
34
+ focus
35
+ test "def" do
36
+ assert true
37
+ end
38
+
39
+ focus
40
+ test "ghi" do
41
+ assert true
42
+ end
43
+ end
44
+
45
+ # should not complain when no methods are left after focusing
46
+ class TestContestC < Test::Unit::TestCase
47
+ test "xyz" do
48
+ end
49
+ end
@@ -0,0 +1,42 @@
1
+ require 'test/test_helper'
2
+ require 'context'
3
+ require 'lib/phocus'
4
+
5
+ # should focus a method
6
+ class TestContextA < Test::Unit::TestCase
7
+ test "foo" do
8
+ flunk "not focused"
9
+ end
10
+
11
+ focus
12
+ test "bar" do
13
+ assert true
14
+ end
15
+
16
+ test "baz" do
17
+ flunk "not focused"
18
+ end
19
+ end
20
+
21
+ # should focus methods across test classes
22
+ class TestContextB < Test::Unit::TestCase
23
+ test "abc" do
24
+ flunk "not focused"
25
+ end
26
+
27
+ focus
28
+ test "def" do
29
+ assert true
30
+ end
31
+
32
+ focus
33
+ test "ghi" do
34
+ assert true
35
+ end
36
+ end
37
+
38
+ # should not complain when no methods are left after focusing
39
+ class TestContextC < Test::Unit::TestCase
40
+ test "xyz" do
41
+ end
42
+ end
@@ -0,0 +1,50 @@
1
+ require 'test/test_helper'
2
+ require 'minitest/autorun'
3
+ require 'lib/phocus'
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
+ # should focus a method
13
+ class TestMiniTestA < MiniTest::Unit::TestCase
14
+ def test_foo
15
+ flunk "not focused"
16
+ end
17
+
18
+ focus
19
+ def test_bar
20
+ assert true
21
+ end
22
+
23
+ def test_baz
24
+ flunk "not focused"
25
+ end
26
+ end
27
+
28
+ # should focus methods across test classes
29
+ class TestMiniTestB < MiniTest::Unit::TestCase
30
+ def test_abc
31
+ flunk "not focused"
32
+ end
33
+
34
+ focus
35
+ def test_def
36
+ assert true
37
+ end
38
+
39
+ focus
40
+ def test_ghi
41
+ assert true
42
+ end
43
+ end
44
+
45
+ # should not complain when no methods are left after focusing
46
+ class TestMiniTestC < MiniTest::Unit::TestCase
47
+ def test_xyz
48
+ flunk "not focused"
49
+ end
50
+ end
@@ -0,0 +1,53 @@
1
+ require 'test/test_helper'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'lib/phocus'
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
+ # should focus a method
16
+ class TestShouldaA < Test::Unit::TestCase
17
+ should "foo" do
18
+ flunk "not focused"
19
+ end
20
+
21
+ focus
22
+ should "bar" do
23
+ assert true
24
+ end
25
+
26
+ should "baz" do
27
+ flunk "not focused"
28
+ end
29
+ end
30
+
31
+ # should focus methods across test classes
32
+ class TestShouldaB < Test::Unit::TestCase
33
+ should "abc" do
34
+ flunk "not focused"
35
+ end
36
+
37
+ focus
38
+ should "def" do
39
+ assert true
40
+ end
41
+
42
+ focus
43
+ should "ghi" do
44
+ assert true
45
+ end
46
+ end
47
+
48
+ # should not complain when no methods are left after focusing
49
+ class TestShouldaC < Test::Unit::TestCase
50
+ should "xyz" do
51
+ flunk "not focused"
52
+ end
53
+ end
@@ -0,0 +1,50 @@
1
+ require 'test/test_helper'
2
+ require 'test/unit'
3
+ require 'lib/phocus'
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
+ # should focus a method
13
+ class TestTestUnitA < Test::Unit::TestCase
14
+ def test_foo
15
+ flunk "not focused"
16
+ end
17
+
18
+ focus
19
+ def test_bar
20
+ assert true
21
+ end
22
+
23
+ def test_baz
24
+ flunk "not focused"
25
+ end
26
+ end
27
+
28
+ # should focus methods across test classes
29
+ class TestTestUnitB < Test::Unit::TestCase
30
+ def test_abc
31
+ flunk "not focused"
32
+ end
33
+
34
+ focus
35
+ def test_def
36
+ assert true
37
+ end
38
+
39
+ focus
40
+ def test_ghi
41
+ assert true
42
+ end
43
+ end
44
+
45
+ # should not complain when no methods are left after focusing
46
+ class TestTestUnitC < Test::Unit::TestCase
47
+ def test_xyz
48
+ flunk "not focused"
49
+ end
50
+ end
@@ -0,0 +1,27 @@
1
+ require 'pathname'
2
+ require 'set'
3
+ require 'rubygems'
4
+ begin
5
+ require 'ruby-debug'
6
+ rescue LoadError, RuntimeError
7
+ end
8
+
9
+ class Object
10
+ def self.metaclass
11
+ (class << self; self; end)
12
+ end
13
+ end
14
+
15
+ def reset_phocused_classes(*classes)
16
+ Array(classes).flatten.each do |klass|
17
+ klass.metaclass.class_eval do
18
+ class_variable_set(:@@__focused, false )
19
+ class_variable_set(:@@__focus_next, false )
20
+ class_variable_set(:@@__test_methods, {} )
21
+ end
22
+ end
23
+ end
24
+
25
+ def reset_phocus
26
+ Phocus.method_pattern = nil
27
+ end
@@ -0,0 +1,136 @@
1
+ require 'test/test_helper'
2
+ require 'expectations'
3
+ require 'lib/phocus'
4
+
5
+ class TestCase
6
+ include Phocus
7
+ end
8
+ class TestA < TestCase; end
9
+ class TestB < TestCase; end
10
+
11
+ def reset
12
+ klasses = [TestA, TestB]
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
19
+ reset_phocus
20
+ end
21
+
22
+ Expectations do
23
+
24
+ ## api
25
+
26
+ expect true do
27
+ reset
28
+ TestA.respond_to?(:focus) &&
29
+ TestA.respond_to?(:focused) &&
30
+ TestA.respond_to?(:phocus)
31
+ end
32
+
33
+ ## pattern
34
+
35
+ # custom pattern for relevant methods.
36
+ # all other methods will be ignored by Phocus
37
+ # (i.e. they cannot be focused, nor will they ever be removed)
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
136
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phocus
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Martin Aumont
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-25 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ 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
+ email: mynyml@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - 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
+ - TODO
35
+ - lib/phocus/autodetect.rb
36
+ - lib/phocus.rb
37
+ - phocus.gemspec
38
+ - LICENSE
39
+ - README
40
+ has_rdoc: true
41
+ homepage: ""
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Run focused tests on test/unit.
68
+ test_files: []
69
+