relevance-test-spec 0.4.0.5
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/CHANGELOG +1 -0
- data/Manifest +29 -0
- data/README.rdoc +394 -0
- data/ROADMAP +1 -0
- data/Rakefile +62 -0
- data/TODO +3 -0
- data/bin/specrb +107 -0
- data/examples/stack.rb +38 -0
- data/examples/stack_spec.rb +119 -0
- data/lib/test/spec.rb +731 -0
- data/lib/test/spec/dox.rb +148 -0
- data/lib/test/spec/focused/collector-extensions.rb +22 -0
- data/lib/test/spec/focused/focused.rb +30 -0
- data/lib/test/spec/rails_helper.rb +26 -0
- data/lib/test/spec/rdox.rb +25 -0
- data/lib/test/spec/should-output.rb +49 -0
- data/lib/test/spec/version.rb +8 -0
- data/test-spec.gemspec +130 -0
- data/test/helper.rb +5 -0
- data/test/spec_dox.rb +39 -0
- data/test/spec_flexmock.rb +214 -0
- data/test/spec_focused.rb +75 -0
- data/test/spec_mocha.rb +118 -0
- data/test/spec_nestedcontexts.rb +26 -0
- data/test/spec_new_style.rb +82 -0
- data/test/spec_should-output.rb +26 -0
- data/test/spec_testspec.rb +575 -0
- data/test/spec_testspec_order.rb +26 -0
- data/test/test_testunit.rb +22 -0
- metadata +127 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'test/unit/ui/console/testrunner'
|
2
|
+
|
3
|
+
module Test::Unit::UI # :nodoc:
|
4
|
+
module SpecDox # :nodoc:
|
5
|
+
class TestRunner < Test::Unit::UI::Console::TestRunner
|
6
|
+
protected
|
7
|
+
def setup_mediator
|
8
|
+
@mediator = create_mediator(@suite)
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_fault(fault)
|
12
|
+
if fault.kind_of? Test::Spec::Disabled
|
13
|
+
@disabled += 1
|
14
|
+
output_no_nl " (disabled)"
|
15
|
+
elsif fault.kind_of? Test::Spec::Empty
|
16
|
+
@empty += 1
|
17
|
+
output_no_nl " (empty)"
|
18
|
+
else
|
19
|
+
@faults << fault
|
20
|
+
word = fault.class.name[/(.*::)?(.*)/, 2].upcase
|
21
|
+
output_no_nl " (#{word} - #{@faults.size})"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def started(result)
|
26
|
+
@result = result
|
27
|
+
@context = nil
|
28
|
+
@contexts = []
|
29
|
+
@disabled = 0
|
30
|
+
@empty = 0
|
31
|
+
indent 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def finished(elapsed_time)
|
35
|
+
nl
|
36
|
+
output "Finished in #{elapsed_time} seconds."
|
37
|
+
@faults.each_with_index do |fault, index|
|
38
|
+
nl
|
39
|
+
output("%3d) %s" % [index + 1, fault.long_display])
|
40
|
+
end
|
41
|
+
nl
|
42
|
+
output_result
|
43
|
+
end
|
44
|
+
|
45
|
+
def output_result
|
46
|
+
if @disabled > 0
|
47
|
+
disabled = ", #{@disabled} disabled"
|
48
|
+
else
|
49
|
+
disabled = ""
|
50
|
+
end
|
51
|
+
|
52
|
+
if @empty > 0
|
53
|
+
empty = ", #{@empty} empty"
|
54
|
+
else
|
55
|
+
empty = ""
|
56
|
+
end
|
57
|
+
|
58
|
+
r = ("%d specifications#{disabled}#{empty} " +
|
59
|
+
"(%d requirements), %d failures") % [
|
60
|
+
@result.run_count, @result.assertion_count, @result.failure_count]
|
61
|
+
r << ", #{@result.error_count} errors" if @result.error_count > 0
|
62
|
+
output r
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_started(name)
|
66
|
+
return if special_test? name
|
67
|
+
|
68
|
+
contextname, @specname = unmangle name
|
69
|
+
return if contextname.nil? || @specname.nil?
|
70
|
+
|
71
|
+
if @context != contextname
|
72
|
+
@context = contextname
|
73
|
+
|
74
|
+
@old_contexts = @contexts
|
75
|
+
@contexts = @context.split("\t")
|
76
|
+
|
77
|
+
common = 0
|
78
|
+
@contexts.zip(@old_contexts) { |a, b|
|
79
|
+
break if a != b
|
80
|
+
common += 1
|
81
|
+
}
|
82
|
+
|
83
|
+
nl if common == 0
|
84
|
+
|
85
|
+
@contexts[common..-1].each_with_index { |head, i|
|
86
|
+
indent common + i
|
87
|
+
output_heading head
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
@assertions = @result.assertion_count
|
92
|
+
@prevdisabled = @disabled
|
93
|
+
output_item @specname
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_finished(name)
|
97
|
+
return if special_test? name
|
98
|
+
|
99
|
+
# Did any assertion run?
|
100
|
+
if @assertions == @result.assertion_count && @prevdisabled == @disabled
|
101
|
+
add_fault Test::Spec::Empty.new(@specname)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Don't let empty contexts clutter up the output.
|
105
|
+
nl unless name =~ /\Adefault_test\(/
|
106
|
+
end
|
107
|
+
|
108
|
+
def output_no_nl(something, level=NORMAL)
|
109
|
+
@io.write(something) if (output?(level))
|
110
|
+
@io.flush
|
111
|
+
end
|
112
|
+
|
113
|
+
def output_item(item)
|
114
|
+
output_no_nl "#{@prefix}- #{item}"
|
115
|
+
end
|
116
|
+
|
117
|
+
def output_heading(heading)
|
118
|
+
output "#{@prefix}#{heading}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def unmangle(name)
|
122
|
+
if name =~ /\Atest_spec \{(.*?)\} \d+ \[(.*)\]/
|
123
|
+
contextname = $1
|
124
|
+
specname = $2
|
125
|
+
elsif name =~ /test_(.*?)\((.*)\)$/
|
126
|
+
specname = $1
|
127
|
+
contextname = $2
|
128
|
+
|
129
|
+
contextname.gsub!(/^Test\B|\BTest$/, '')
|
130
|
+
specname.gsub!(/_/, ' ')
|
131
|
+
else
|
132
|
+
contextname = specname = nil
|
133
|
+
end
|
134
|
+
|
135
|
+
[contextname, specname]
|
136
|
+
end
|
137
|
+
|
138
|
+
def indent(depth)
|
139
|
+
@indent = depth
|
140
|
+
@prefix = " " * depth
|
141
|
+
end
|
142
|
+
|
143
|
+
def special_test?(name)
|
144
|
+
name =~ /\Atest_spec \{.*?\} (-1 BEFORE|AFTER) ALL\(/
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
module Collector
|
4
|
+
class ObjectSpace
|
5
|
+
|
6
|
+
# Open up the ObjectSpace Collector to check to see if we have set an ignore flag.
|
7
|
+
def collect(name=NAME)
|
8
|
+
suite = TestSuite.new(name)
|
9
|
+
sub_suites = []
|
10
|
+
@source.each_object(Class) do |klass|
|
11
|
+
if (Test::Unit::TestCase > klass) && !klass.instance_variable_get(:@__ignore)
|
12
|
+
add_suite(sub_suites, klass.suite)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
sub_suites.each {|s| suite << s }
|
16
|
+
suite
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Test::Spec::Focused
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
base.class_eval {
|
6
|
+
@focused_mode = false
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def focused_mode?
|
12
|
+
@focused_mode
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_focused_mode(bool, focused_context = nil)
|
16
|
+
@focused_mode = bool
|
17
|
+
ignore_previous_specs(focused_context) if bool
|
18
|
+
end
|
19
|
+
|
20
|
+
def ignore_previous_specs(exclude = nil)
|
21
|
+
Test::Spec::CONTEXTS.each do |name, context|
|
22
|
+
if name.to_s != exclude.to_s # ignore every spec except the focused one
|
23
|
+
context.ignore = true
|
24
|
+
context.testcase.instance_variable_set(:@__ignore, true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Test::Spec::RailsHelper
|
2
|
+
|
3
|
+
def infer_controller_class(name)
|
4
|
+
cleaned_name = name[0..name.index("\t")] rescue name
|
5
|
+
cleaned_name.strip!
|
6
|
+
cleaned_name.constantize
|
7
|
+
rescue NameError => e
|
8
|
+
nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def figure_out_superclass_from_name(name_or_class, default_superclass)
|
12
|
+
if name_or_class.is_a?(Class)
|
13
|
+
if name_or_class < ActionController::Base
|
14
|
+
return ActionController::TestCase
|
15
|
+
elsif name_or_class < ActiveRecord::Base
|
16
|
+
return ActiveSupport::TestCase
|
17
|
+
elsif name_or_class < ActionMailer::Base
|
18
|
+
return ActionMailer::TestCase
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
default_superclass
|
23
|
+
end
|
24
|
+
|
25
|
+
extend self
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test/spec/dox'
|
2
|
+
|
3
|
+
module Test::Unit::UI # :nodoc:
|
4
|
+
module RDox # :nodoc:
|
5
|
+
class TestRunner < Test::Unit::UI::SpecDox::TestRunner
|
6
|
+
def output_heading(heading)
|
7
|
+
output "#{@headprefix} #{heading}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def output_item(item)
|
11
|
+
output_no_nl "* #{item}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def finished(elapsed_time)
|
15
|
+
nl
|
16
|
+
output_result
|
17
|
+
end
|
18
|
+
|
19
|
+
def indent(depth)
|
20
|
+
@prefix = ""
|
21
|
+
@headprefix = "==" + "=" * depth
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Code adapted from rs, written by Eero Saynatkari.
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
class Test::Spec::Should
|
6
|
+
# Captures output from the IO given as
|
7
|
+
# the second argument (STDIN by default)
|
8
|
+
# and matches it against a String or
|
9
|
+
# Regexp given as the first argument.
|
10
|
+
def output(expected, to = STDOUT)
|
11
|
+
# Store the old stream
|
12
|
+
old_to = to.dup
|
13
|
+
|
14
|
+
# Obtain a filehandle to replace (works with Readline)
|
15
|
+
to.reopen File.open(File.join(Dir.tmpdir, "should_output_#{$$}"), "w+")
|
16
|
+
|
17
|
+
# Execute
|
18
|
+
@object.call
|
19
|
+
|
20
|
+
# Restore
|
21
|
+
out = to.dup
|
22
|
+
to.reopen old_to
|
23
|
+
|
24
|
+
# Grab the data
|
25
|
+
out.rewind
|
26
|
+
output = out.read
|
27
|
+
|
28
|
+
# Match up
|
29
|
+
case expected
|
30
|
+
when Regexp
|
31
|
+
output.should.match expected
|
32
|
+
else
|
33
|
+
output.should.equal expected
|
34
|
+
end # case expected
|
35
|
+
|
36
|
+
# Clean up
|
37
|
+
ensure
|
38
|
+
out.close
|
39
|
+
|
40
|
+
# STDIO redirection will break else
|
41
|
+
begin
|
42
|
+
to.seek 0, IO::SEEK_END
|
43
|
+
rescue Errno::ESPIPE
|
44
|
+
rescue Errno::EPIPE
|
45
|
+
end
|
46
|
+
|
47
|
+
FileUtils.rm_f out.path
|
48
|
+
end # output
|
49
|
+
end # Test::Spec::Should
|
data/test-spec.gemspec
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Test-spec-0.4.0.5
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
--- !ruby/object:Gem::Specification
|
6
|
+
name: test-spec
|
7
|
+
version: !ruby/object:Gem::Version
|
8
|
+
version: 0.4.0.5
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Christian Neukirchen
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
|
15
|
+
date: 2008-10-22 00:00:00 -04:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: echoe
|
20
|
+
type: :development
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: "0"
|
27
|
+
version:
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: allison
|
30
|
+
type: :development
|
31
|
+
version_requirement:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "0"
|
37
|
+
version:
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: markaby
|
40
|
+
type: :development
|
41
|
+
version_requirement:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
description: test/spec layers an RSpec-inspired interface on top of Test::Unit, so you can mix TDD and BDD (Behavior-Driven Development). test/spec is a clean-room implementation that maps most kinds of Test::Unit assertions to a `should'-like syntax. This is a fork of the main version to add some features and make thigns a bit easier for developers.
|
49
|
+
email: chneukirchen@gmail.com
|
50
|
+
executables:
|
51
|
+
- specrb
|
52
|
+
- specrb
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- bin/specrb
|
57
|
+
- CHANGELOG
|
58
|
+
- lib/test/spec/dox.rb
|
59
|
+
- lib/test/spec/focused/collector-extensions.rb
|
60
|
+
- lib/test/spec/focused/focused.rb
|
61
|
+
- lib/test/spec/rails_helper.rb
|
62
|
+
- lib/test/spec/rdox.rb
|
63
|
+
- lib/test/spec/should-output.rb
|
64
|
+
- lib/test/spec/version.rb
|
65
|
+
- lib/test/spec.rb
|
66
|
+
- README.rdoc
|
67
|
+
- SPECS
|
68
|
+
files:
|
69
|
+
- bin/specrb
|
70
|
+
- CHANGELOG
|
71
|
+
- examples/stack.rb
|
72
|
+
- examples/stack_spec.rb
|
73
|
+
- lib/test/spec/dox.rb
|
74
|
+
- lib/test/spec/focused/collector-extensions.rb
|
75
|
+
- lib/test/spec/focused/focused.rb
|
76
|
+
- lib/test/spec/rails_helper.rb
|
77
|
+
- lib/test/spec/rdox.rb
|
78
|
+
- lib/test/spec/should-output.rb
|
79
|
+
- lib/test/spec/version.rb
|
80
|
+
- lib/test/spec.rb
|
81
|
+
- Rakefile
|
82
|
+
- README.rdoc
|
83
|
+
- ROADMAP
|
84
|
+
- SPECS
|
85
|
+
- test/helper.rb
|
86
|
+
- test/spec_dox.rb
|
87
|
+
- test/spec_flexmock.rb
|
88
|
+
- test/spec_focused.rb
|
89
|
+
- test/spec_mocha.rb
|
90
|
+
- test/spec_nestedcontexts.rb
|
91
|
+
- test/spec_new_style.rb
|
92
|
+
- test/spec_should-output.rb
|
93
|
+
- test/spec_testspec.rb
|
94
|
+
- test/spec_testspec_order.rb
|
95
|
+
- test/test_testunit.rb
|
96
|
+
- TODO
|
97
|
+
- Manifest
|
98
|
+
- test-spec.gemspec
|
99
|
+
has_rdoc: true
|
100
|
+
homepage: http://github.com/relevance/test-spec
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- --line-numbers
|
104
|
+
- --inline-source
|
105
|
+
- --title
|
106
|
+
- Test-spec
|
107
|
+
- --main
|
108
|
+
- README.rdoc
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: "0"
|
116
|
+
version:
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: "1.2"
|
122
|
+
version:
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project: test-spec
|
126
|
+
rubygems_version: 1.2.0
|
127
|
+
specification_version: 2
|
128
|
+
summary: Relevance fork of Behaviour Driven Development interface for Test::Unit
|
129
|
+
test_files:
|
130
|
+
- test/test_testunit.rb
|