nanotest_extensions 0.6.1 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README_FOCUS.rdoc +2 -7
- data/README_STATS.rdoc +1 -1
- data/Rakefile +5 -3
- data/lib/nanotest/focus.rb +3 -3
- data/lib/nanotest/stats.rb +1 -1
- data/nanotest_extensions.gemspec +1 -1
- data/test/test_contexts.rb +27 -0
- data/test/test_focus.rb +10 -1
- data/test/test_helper.rb +12 -0
- metadata +2 -2
data/README_FOCUS.rdoc
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
=== Summary
|
2
2
|
|
3
|
-
Easily focus assertions
|
4
|
-
|
5
|
-
Simply call #focus, and the subsequent assertion will be run. Can be called
|
6
|
-
multiple times. Any assertion that is not focused will never run (unless focus
|
7
|
-
is never called, in which case nanotest will run normally). Will also work
|
8
|
-
across all test files.
|
3
|
+
Easily focus assertions
|
9
4
|
|
10
5
|
=== Examples
|
11
6
|
|
@@ -23,4 +18,4 @@ across all test files.
|
|
23
18
|
assert { true }
|
24
19
|
|
25
20
|
This will only run the two tests following the #focus calls, and the "suite"
|
26
|
-
will pass.
|
21
|
+
will pass. Will also work across test files.
|
data/README_STATS.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -12,13 +12,15 @@ namespace(:test) do
|
|
12
12
|
|
13
13
|
desc "Run all tests"
|
14
14
|
task(:all) do
|
15
|
-
# test files must be run separately, or else focus kicks in and stats resets nanotest
|
16
|
-
%w(
|
15
|
+
# test files must be run separately, or else focus kicks in, and stats resets nanotest
|
16
|
+
paths = %w(
|
17
17
|
test/test_contexts.rb
|
18
18
|
test/test_focus.rb
|
19
19
|
test/test_spec.rb
|
20
20
|
test/test_stats.rb
|
21
|
-
)
|
21
|
+
)
|
22
|
+
statuses = paths.map {|test| run("ruby -rubygems -I.:lib #{test}") }
|
23
|
+
exit statuses.all?
|
22
24
|
end
|
23
25
|
|
24
26
|
desc "Run all tests on multiple ruby versions (requires rvm)"
|
data/lib/nanotest/focus.rb
CHANGED
@@ -16,14 +16,14 @@ module Nanotest
|
|
16
16
|
|
17
17
|
alias :focus__orig_assert :assert
|
18
18
|
|
19
|
-
def assert(
|
19
|
+
def assert(msg=nil,file=nil,line=nil,stack=caller,&block)
|
20
20
|
if @@focused
|
21
21
|
if @@focus_next
|
22
22
|
@@focus_next = false
|
23
|
-
focus__orig_assert(
|
23
|
+
focus__orig_assert(msg,file,line,stack,&block)
|
24
24
|
end
|
25
25
|
else
|
26
|
-
focus__orig_assert(
|
26
|
+
focus__orig_assert(msg,file,line,stack,&block)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/nanotest/stats.rb
CHANGED
@@ -8,7 +8,7 @@ module Nanotest
|
|
8
8
|
stats = "\n(%f seconds) %d assertions, %d failures" % [Time.now-$nanotest_time, @@dots.size, @@failures.size]
|
9
9
|
|
10
10
|
# insert stats after failure message if any, or dots otherwise
|
11
|
-
lines, pos = stats__orig_results.split(/\n/),
|
11
|
+
lines, pos = stats__orig_results.split(/\n/), 0
|
12
12
|
lines.each_with_index {|line, i| pos = i if line =~ /\((.*):\d+\).*$/ || line =~ /(\.|F)+/ }
|
13
13
|
lines.insert(pos + 1, stats).join("\n")
|
14
14
|
end
|
data/nanotest_extensions.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "nanotest_extensions"
|
3
|
+
s.version = "0.6.3"
|
3
4
|
s.summary = "Nano extensions for nanotest"
|
4
5
|
s.description = "Nano extensions for nanotest."
|
5
6
|
s.author = "Martin Aumont"
|
@@ -7,7 +8,6 @@ Gem::Specification.new do |s|
|
|
7
8
|
s.homepage = "http://github.com/mynyml/nanotest_extensions"
|
8
9
|
s.rubyforge_project = "nanotest_extensions"
|
9
10
|
s.require_path = "lib"
|
10
|
-
s.version = "0.6.1"
|
11
11
|
s.files = File.read("Manifest").strip.split("\n")
|
12
12
|
|
13
13
|
s.add_development_dependency 'nanotest'
|
data/test/test_contexts.rb
CHANGED
@@ -53,3 +53,30 @@ context do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
__END__
|
57
|
+
module Foo
|
58
|
+
def foo
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# test: sibling contexts don't share their state
|
63
|
+
context do
|
64
|
+
include Foo
|
65
|
+
def bar() end
|
66
|
+
context do
|
67
|
+
def baz() end
|
68
|
+
assert { respond_to?(:foo) }
|
69
|
+
assert { respond_to?(:bar) }
|
70
|
+
context do
|
71
|
+
assert { respond_to?(:baz) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
context do
|
75
|
+
assert { not respond_to?(:baz) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
context do
|
79
|
+
assert { not respond_to?(:foo) }
|
80
|
+
assert { not respond_to?(:bar) }
|
81
|
+
end
|
82
|
+
|
data/test/test_focus.rb
CHANGED
@@ -17,4 +17,13 @@ assert("should not be run") { false }
|
|
17
17
|
|
18
18
|
# ensure focused assertions were run
|
19
19
|
focus
|
20
|
-
assert { Nanotest.
|
20
|
+
assert { Nanotest.dots.size == 2 }
|
21
|
+
|
22
|
+
# test: correctly references origin of assertion
|
23
|
+
focus; assert('') { false }; line = __LINE__
|
24
|
+
|
25
|
+
actual, expected = Nanotest.failures.last, "(%s:%0.3d) " % [__FILE__,line]
|
26
|
+
Nanotest.pop
|
27
|
+
focus
|
28
|
+
assert("expected: #{expected.inspect}, got: #{actual.inspect}") { actual == expected }
|
29
|
+
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
require 'nanotest'
|
2
2
|
begin
|
3
|
+
require 'ruby-debug'
|
3
4
|
require 'redgreen'#gem install mynyml-redgreen
|
4
5
|
rescue LoadError, RuntimeError
|
5
6
|
end
|
7
|
+
|
8
|
+
module Nanotest
|
9
|
+
class << self
|
10
|
+
def failures() @@failures end
|
11
|
+
def dots() @@dots end
|
12
|
+
def pop
|
13
|
+
failures.pop
|
14
|
+
dots.pop
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanotest_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
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:
|
12
|
+
date: 2010-01-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|