mynyml-phocus 0.5 → 0.9.4

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/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.5'
25
+ s.version = '0.9.4'
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"
data/TODO CHANGED
@@ -1,8 +1,18 @@
1
1
  o test (implement?) compatibility with test/unit plugins
2
- - context, shoulda, test/spec, contess, etc.
3
-
4
- o handle errors when a TestCase doesn't define any test method
5
- `def default_test() end` works, but test count should not go up
2
+ x test/unit
3
+ x minitest
4
+ x context
5
+ x shoulda
6
+ x contest
7
+ o test/spec
8
+ ...
6
9
 
7
10
  o add docs
8
11
  - rdocs, README
12
+
13
+ o focus do
14
+ ...
15
+ ...
16
+ end
17
+
18
+ to focus a group of tests at once
@@ -0,0 +1,11 @@
1
+ require 'pathname'
2
+ require 'contest'
3
+
4
+ root = Pathname(__FILE__).dirname.parent.parent.expand_path
5
+ require root + 'lib/phocus'
6
+
7
+ class Test::Unit::TestCase
8
+ include ::Phocus
9
+ end
10
+
11
+ Phocus.method_pattern = /^test_/
@@ -0,0 +1,11 @@
1
+ require 'pathname'
2
+ require 'context'
3
+
4
+ root = Pathname(__FILE__).dirname.parent.parent.expand_path
5
+ require root + 'lib/phocus'
6
+
7
+ class Test::Unit::TestCase
8
+ include ::Phocus
9
+ end
10
+
11
+ Phocus.method_pattern = /test:/
@@ -0,0 +1,13 @@
1
+ require 'pathname'
2
+ require 'minitest/unit'
3
+
4
+ root = Pathname(__FILE__).dirname.parent.parent.expand_path
5
+ require root + 'lib/phocus'
6
+
7
+ class MiniTest::Unit::TestCase
8
+ include ::Phocus
9
+ end
10
+
11
+ Phocus.method_pattern = /^test_/
12
+
13
+ MiniTest::Unit.autorun
@@ -0,0 +1,19 @@
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
+ class Test::Unit::TestCase
9
+ include ::Phocus
10
+ end
11
+
12
+ class Test::Unit::TestSuite
13
+ # TODO only override when @@__focused
14
+ def empty?
15
+ false
16
+ end
17
+ end
18
+
19
+ Phocus.method_pattern = /^test:/
@@ -0,0 +1,18 @@
1
+ require 'pathname'
2
+ require 'test/unit'
3
+
4
+ root = Pathname(__FILE__).dirname.parent.parent.expand_path
5
+ require root + 'lib/phocus'
6
+
7
+ class Test::Unit::TestCase
8
+ include ::Phocus
9
+ end
10
+
11
+ class Test::Unit::TestSuite
12
+ # TODO only override when @@__focused
13
+ def empty?
14
+ false
15
+ end
16
+ end
17
+
18
+ Phocus.method_pattern = /^test_/
data/lib/phocus.rb CHANGED
@@ -1,4 +1,12 @@
1
1
  module Phocus
2
+ class << self
3
+ attr_accessor :method_pattern
4
+
5
+ def method_pattern
6
+ @method_pattern || /^test_/
7
+ end
8
+ end
9
+
2
10
  def self.included(base)
3
11
  base.extend ClassMethods
4
12
  end
@@ -20,7 +28,8 @@ module Phocus
20
28
 
21
29
  def method_added(name)
22
30
  super
23
- if name.to_s.match(/^test_/)
31
+ #if name.to_s.match(/^test/)
32
+ if name.to_s.match(Phocus.method_pattern)
24
33
  if @@__focused
25
34
  @@__focus_next ? @@__focus_next = false : remove_method(name)
26
35
  else
data/phocus.gemspec ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phocus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.4
5
+ platform: ruby
6
+ authors:
7
+ - Martin Aumont
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-28 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/context.rb
40
+ - lib/phocus/shoulda.rb
41
+ - lib/phocus/contest.rb
42
+ - lib/phocus/minitest.rb
43
+ - lib/phocus/test_unit.rb
44
+ - lib/phocus.rb
45
+ - phocus.gemspec
46
+ - README
47
+ has_rdoc: true
48
+ homepage: ""
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.3
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Run focused tests on test/unit.
75
+ test_files: []
76
+
data/test/README ADDED
@@ -0,0 +1,6 @@
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
+ ...
@@ -0,0 +1,48 @@
1
+ require 'test/test_helper'
2
+ require 'lib/phocus/contest'
3
+
4
+ class Test::Unit::TestCase
5
+ def setup
6
+ reset_phocused_classes(TestContestA, TestContestB, TestContestC)
7
+ reset_phocus
8
+ end
9
+ end
10
+
11
+ # should focus a method
12
+ class TestContestA < Test::Unit::TestCase
13
+ test "foo" do
14
+ flunk "not focused"
15
+ end
16
+
17
+ focus
18
+ test "bar" do
19
+ assert true
20
+ end
21
+
22
+ test "baz" do
23
+ flunk "not focused"
24
+ end
25
+ end
26
+
27
+ # should focus methods across test classes
28
+ class TestContestB < Test::Unit::TestCase
29
+ test "abc" do
30
+ flunk "not focused"
31
+ end
32
+
33
+ focus
34
+ test "def" do
35
+ assert true
36
+ end
37
+
38
+ focus
39
+ test "ghi" do
40
+ assert true
41
+ end
42
+ end
43
+
44
+ # should not complain when no methods are left after focusing
45
+ class TestContestC < Test::Unit::TestCase
46
+ test "xyz" do
47
+ end
48
+ end
@@ -0,0 +1,41 @@
1
+ require 'test/test_helper'
2
+ require 'lib/phocus/context'
3
+
4
+ # should focus a method
5
+ class TestContextA < Test::Unit::TestCase
6
+ test "foo" do
7
+ flunk "not focused"
8
+ end
9
+
10
+ focus
11
+ test "bar" do
12
+ assert true
13
+ end
14
+
15
+ test "baz" do
16
+ flunk "not focused"
17
+ end
18
+ end
19
+
20
+ # should focus methods across test classes
21
+ class TestContextB < Test::Unit::TestCase
22
+ test "abc" do
23
+ flunk "not focused"
24
+ end
25
+
26
+ focus
27
+ test "def" do
28
+ assert true
29
+ end
30
+
31
+ focus
32
+ test "ghi" do
33
+ assert true
34
+ end
35
+ end
36
+
37
+ # should not complain when no methods are left after focusing
38
+ class TestContextC < Test::Unit::TestCase
39
+ test "xyz" do
40
+ end
41
+ end
@@ -0,0 +1,49 @@
1
+ require 'test/test_helper'
2
+ require 'lib/phocus/minitest'
3
+
4
+ class MiniTest::Unit::TestCase
5
+ def setup
6
+ reset_phocused_classes(TestMiniTestA, TestMiniTestB, TestMiniTestC)
7
+ reset_phocus
8
+ end
9
+ end
10
+
11
+ # should focus a method
12
+ class TestMiniTestA < MiniTest::Unit::TestCase
13
+ def test_foo
14
+ flunk "not focused"
15
+ end
16
+
17
+ focus
18
+ def test_bar
19
+ assert true
20
+ end
21
+
22
+ def test_baz
23
+ flunk "not focused"
24
+ end
25
+ end
26
+
27
+ # should focus methods across test classes
28
+ class TestMiniTestB < MiniTest::Unit::TestCase
29
+ def test_abc
30
+ flunk "not focused"
31
+ end
32
+
33
+ focus
34
+ def test_def
35
+ assert true
36
+ end
37
+
38
+ focus
39
+ def test_ghi
40
+ assert true
41
+ end
42
+ end
43
+
44
+ # should not complain when no methods are left after focusing
45
+ class TestMiniTestC < MiniTest::Unit::TestCase
46
+ def test_xyz
47
+ flunk "not focused"
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require 'test/test_helper'
2
+ require 'lib/phocus/shoulda' # testing shoulda/test_unit
3
+
4
+ class Test::Unit::TestCase
5
+ def setup
6
+ reset_phocused_classes(TestShouldaA, TestShouldaB, TestShouldaC)
7
+ reset_phocus
8
+ end
9
+ end
10
+
11
+ # should focus a method
12
+ class TestShouldaA < Test::Unit::TestCase
13
+ should "foo" do
14
+ flunk "not focused"
15
+ end
16
+
17
+ focus
18
+ should "bar" do
19
+ assert true
20
+ end
21
+
22
+ should "baz" do
23
+ flunk "not focused"
24
+ end
25
+ end
26
+
27
+ # should focus methods across test classes
28
+ class TestShouldaB < Test::Unit::TestCase
29
+ should "abc" do
30
+ flunk "not focused"
31
+ end
32
+
33
+ focus
34
+ should "def" do
35
+ assert true
36
+ end
37
+
38
+ focus
39
+ should "ghi" do
40
+ assert true
41
+ end
42
+ end
43
+
44
+ # should not complain when no methods are left after focusing
45
+ class TestShouldaC < Test::Unit::TestCase
46
+ should "xyz" do
47
+ flunk "not focused"
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require 'test/test_helper'
2
+ require 'lib/phocus/test_unit'
3
+
4
+ class Test::Unit::TestCase
5
+ def setup
6
+ reset_phocused_classes(TestTestUnitA, TestTestUnitB, TestTestUnitC)
7
+ reset_phocus
8
+ end
9
+ end
10
+
11
+ # should focus a method
12
+ class TestTestUnitA < Test::Unit::TestCase
13
+ def test_foo
14
+ flunk "not focused"
15
+ end
16
+
17
+ focus
18
+ def test_bar
19
+ assert true
20
+ end
21
+
22
+ def test_baz
23
+ flunk "not focused"
24
+ end
25
+ end
26
+
27
+ # should focus methods across test classes
28
+ class TestTestUnitB < Test::Unit::TestCase
29
+ def test_abc
30
+ flunk "not focused"
31
+ end
32
+
33
+ focus
34
+ def test_def
35
+ assert true
36
+ end
37
+
38
+ focus
39
+ def test_ghi
40
+ assert true
41
+ end
42
+ end
43
+
44
+ # should not complain when no methods are left after focusing
45
+ class TestTestUnitC < Test::Unit::TestCase
46
+ def test_xyz
47
+ flunk "not focused"
48
+ end
49
+ end
data/test/test_helper.rb CHANGED
@@ -6,9 +6,6 @@ begin
6
6
  rescue LoadError, RuntimeError
7
7
  end
8
8
 
9
- root = Pathname(__FILE__).dirname.parent.expand_path
10
- require root.join('lib/phocus')
11
-
12
9
  class Object
13
10
  def self.metaclass
14
11
  (class << self; self; end)
@@ -22,8 +19,9 @@ def reset_phocused_classes(*classes)
22
19
  class_variable_set(:@@__focus_next, false )
23
20
  class_variable_set(:@@__test_methods, {} )
24
21
  end
25
- klass.class_eval do
26
- instance_methods(false).each {|name| remove_method(name) }
27
- end
28
22
  end
29
23
  end
24
+
25
+ def reset_phocus
26
+ Phocus.method_pattern = nil
27
+ end
data/test/test_phocus.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'test/test_helper'
2
2
  require 'expectations'
3
+ require 'lib/phocus'
3
4
 
4
5
  class TestCase
5
6
  include Phocus
@@ -8,7 +9,14 @@ class TestA < TestCase; end
8
9
  class TestB < TestCase; end
9
10
 
10
11
  def reset
11
- reset_phocused_classes(TestA, TestB)
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
12
20
  end
13
21
 
14
22
  Expectations do
@@ -22,10 +30,28 @@ Expectations do
22
30
  TestA.respond_to?(:phocus)
23
31
  end
24
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
+
25
51
  ## focused tests
26
52
 
27
53
  # only keeps focused method
28
- expect %w( test_foo ) do
54
+ expect %w( test_foo ).to_set do
29
55
  reset
30
56
  class TestA
31
57
  focus
@@ -33,7 +59,7 @@ Expectations do
33
59
  def test_bar() end
34
60
  end
35
61
 
36
- TestA.instance_methods(false)
62
+ TestA.instance_methods(false).to_set
37
63
  end
38
64
 
39
65
  # keeps more than one focused methods
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.5"
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Aumont
@@ -25,10 +25,24 @@ files:
25
25
  - Rakefile
26
26
  - test
27
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
28
35
  - test/test_helper.rb
29
36
  - TODO
30
37
  - lib
38
+ - lib/phocus
39
+ - lib/phocus/context.rb
40
+ - lib/phocus/shoulda.rb
41
+ - lib/phocus/contest.rb
42
+ - lib/phocus/minitest.rb
43
+ - lib/phocus/test_unit.rb
31
44
  - lib/phocus.rb
45
+ - phocus.gemspec
32
46
  - README
33
47
  has_rdoc: true
34
48
  homepage: ""