pending 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +6 -0
- data/README.txt +74 -0
- data/Rakefile +34 -0
- data/lib/pending.rb +86 -0
- data/pending.gemspec +46 -0
- data/test/test_pending.rb +66 -0
- metadata +61 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
pending
|
2
|
+
by Jeremy McAnally
|
3
|
+
http://jeremymcanally.com
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
pending lets you define a block of test code that is currently "pending" functionality,
|
8
|
+
similar to RSpec's pending method.
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* A pending method to let you define pending test code
|
13
|
+
|
14
|
+
== SYNOPSIS:
|
15
|
+
|
16
|
+
The pending method lets you define a block of test code that is currently "pending"
|
17
|
+
functionality.
|
18
|
+
|
19
|
+
You can use it two ways. One is simply put a string as the parameter:
|
20
|
+
|
21
|
+
def test_web_service_integration
|
22
|
+
pending "This is not done yet..."
|
23
|
+
end
|
24
|
+
|
25
|
+
This will output a "P" in the test output alerting there is pending functionality.
|
26
|
+
|
27
|
+
You can also supply a block of code:
|
28
|
+
|
29
|
+
def test_new_helpers
|
30
|
+
pending "New helpers for database display" do
|
31
|
+
output = render_record(User.first)
|
32
|
+
assert_equal "Jerry User (jerry@users.com)", output
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
If the block doesn't fail, then the test will flunk with output like:
|
37
|
+
|
38
|
+
<New helpers for database display> did not fail.
|
39
|
+
|
40
|
+
If the test fails (i.e., the functionality isn't implemented), then it will
|
41
|
+
not fail the surrounding test.
|
42
|
+
|
43
|
+
== REQUIREMENTS:
|
44
|
+
|
45
|
+
* Test::Unit
|
46
|
+
|
47
|
+
== INSTALL:
|
48
|
+
|
49
|
+
sudo gem install pending
|
50
|
+
|
51
|
+
== LICENSE:
|
52
|
+
|
53
|
+
(The MIT License)
|
54
|
+
|
55
|
+
Copyright (c) 2008 FIXME (different license?)
|
56
|
+
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
58
|
+
a copy of this software and associated documentation files (the
|
59
|
+
'Software'), to deal in the Software without restriction, including
|
60
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
61
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
62
|
+
permit persons to whom the Software is furnished to do so, subject to
|
63
|
+
the following conditions:
|
64
|
+
|
65
|
+
The above copyright notice and this permission notice shall be
|
66
|
+
included in all copies or substantial portions of the Software.
|
67
|
+
|
68
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
69
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
70
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
71
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
72
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
73
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
74
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
|
6
|
+
# Test::Unit::UI::VERBOSE
|
7
|
+
test_files_pattern = 'test/**/*_test.rb'
|
8
|
+
src_files_pattern = 'src/**/*.rb'
|
9
|
+
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
src_files = Dir[src_files_pattern]
|
12
|
+
src_files.each { |f| puts f; require f[0...-3] }
|
13
|
+
t.pattern = test_files_pattern
|
14
|
+
t.verbose = false
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'jeweler'
|
19
|
+
Jeweler::Tasks.new do |s|
|
20
|
+
s.name = "pending"
|
21
|
+
s.version = "0.1.1"
|
22
|
+
s.authors = ["Jeremy McAnally"]
|
23
|
+
s.email = "jeremymcanally@gmail.com"
|
24
|
+
s.summary = %q{pending lets you define a block of test code that is currently "pending" functionality, similar to RSpec's pending method}
|
25
|
+
s.homepage = %q{http://jeremymcanally.com}
|
26
|
+
s.description = %q{pending lets you define a block of test code that is currently "pending" functionality, similar to RSpec's pending method.}
|
27
|
+
end
|
28
|
+
rescue LoadError
|
29
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
desc 'Default: run tests.'
|
34
|
+
task :default => 'test'
|
data/lib/pending.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
class TestCase
|
4
|
+
@@pending_cases = []
|
5
|
+
@@at_exit = false
|
6
|
+
|
7
|
+
# The pending method lets you define a block of test code that is currently "pending"
|
8
|
+
# functionality.
|
9
|
+
#
|
10
|
+
# You can use it two ways. One is simply put a string as the parameter:
|
11
|
+
#
|
12
|
+
# def test_web_service_integration
|
13
|
+
# pending "This is not done yet..."
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# This will output a "P" in the test output alerting there is pending functionality.
|
17
|
+
#
|
18
|
+
# You can also supply a block of code:
|
19
|
+
#
|
20
|
+
# def test_new_helpers
|
21
|
+
# pending "New helpers for database display" do
|
22
|
+
# output = render_record(User.first)
|
23
|
+
# assert_equal "Jerry User (jerry@users.com)", output
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# If the block doesn't fail, then the test will flunk with output like:
|
28
|
+
#
|
29
|
+
# <New helpers for database display> did not fail.
|
30
|
+
#
|
31
|
+
# If the test fails (i.e., the functionality isn't implemented), then it will
|
32
|
+
# not fail the surrounding test.
|
33
|
+
#
|
34
|
+
def pending(description = "", &block)
|
35
|
+
if block_given?
|
36
|
+
failed = false
|
37
|
+
|
38
|
+
begin
|
39
|
+
block.call
|
40
|
+
rescue
|
41
|
+
failed = true
|
42
|
+
end
|
43
|
+
|
44
|
+
flunk("<#{description}> did not fail.") unless failed
|
45
|
+
end
|
46
|
+
|
47
|
+
caller[0] =~ (/(.*):(.*):in `(.*)'/)
|
48
|
+
@@pending_cases << "#{$3} at #{$1}, line #{$2}"
|
49
|
+
print "P"
|
50
|
+
|
51
|
+
@@at_exit ||= begin
|
52
|
+
at_exit do
|
53
|
+
puts "\nPending Cases:"
|
54
|
+
@@pending_cases.each do |test_case|
|
55
|
+
puts test_case
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# This method will define a test method using the description as the test name
|
62
|
+
# ("pending function" => "test_pending_function")
|
63
|
+
#
|
64
|
+
# Instead of doing this:
|
65
|
+
#
|
66
|
+
# def test_function_is_pending
|
67
|
+
# pending "this test is pending"
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# You can just do this:
|
71
|
+
#
|
72
|
+
# pending "function is pending"
|
73
|
+
#
|
74
|
+
# This method can be called with a block passed, the same as the instance method
|
75
|
+
#
|
76
|
+
def self.pending(description, &block)
|
77
|
+
test_name = "test_#{description.gsub(/\s+/,'_')}".to_sym
|
78
|
+
defined = instance_method(test_name) rescue false
|
79
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
80
|
+
define_method(test_name) do
|
81
|
+
pending(description) {self.instance_eval(&block)}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/pending.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pending}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jeremy McAnally"]
|
12
|
+
s.date = %q{2009-11-23}
|
13
|
+
s.description = %q{pending lets you define a block of test code that is currently "pending" functionality, similar to RSpec's pending method.}
|
14
|
+
s.email = %q{jeremymcanally@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"History.txt",
|
20
|
+
"Manifest.txt",
|
21
|
+
"README.txt",
|
22
|
+
"Rakefile",
|
23
|
+
"lib/pending.rb",
|
24
|
+
"pending.gemspec",
|
25
|
+
"test/test_pending.rb"
|
26
|
+
]
|
27
|
+
s.homepage = %q{http://jeremymcanally.com}
|
28
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
29
|
+
s.require_paths = ["lib"]
|
30
|
+
s.rubygems_version = %q{1.3.5}
|
31
|
+
s.summary = %q{pending lets you define a block of test code that is currently "pending" functionality, similar to RSpec's pending method}
|
32
|
+
s.test_files = [
|
33
|
+
"test/test_pending.rb"
|
34
|
+
]
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
41
|
+
else
|
42
|
+
end
|
43
|
+
else
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/pending.rb"
|
3
|
+
|
4
|
+
# Quick and dirty way to test our output
|
5
|
+
class StdoutStub
|
6
|
+
attr_accessor :text
|
7
|
+
|
8
|
+
def write(text)
|
9
|
+
@text = text
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestPending < Test::Unit::TestCase
|
14
|
+
def test_output
|
15
|
+
old = $stdout
|
16
|
+
$> = StdoutStub.new
|
17
|
+
pending("poop")
|
18
|
+
|
19
|
+
assert_equal "P", $>.text
|
20
|
+
$> = $stdout
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_does_not_require_block
|
24
|
+
assert_nothing_raised do
|
25
|
+
pending("hello there")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_block_allows_fail
|
30
|
+
assert_nothing_raised do
|
31
|
+
pending("this is awesome") do
|
32
|
+
assert false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_flunk_when_no_flunk
|
38
|
+
assert_raises(Test::Unit::AssertionFailedError) do
|
39
|
+
pending("this is fail") do
|
40
|
+
assert true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_output_of_flunk_when_no_flunk
|
46
|
+
begin
|
47
|
+
pending("this is fail") do
|
48
|
+
assert true
|
49
|
+
end
|
50
|
+
rescue StandardError => e
|
51
|
+
assert_equal "<this is fail> did not fail.", e.message
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_creates_test_method_when_called_on_self
|
56
|
+
TestPending.pending("this test is pending") do
|
57
|
+
assert true
|
58
|
+
end
|
59
|
+
|
60
|
+
assert TestPending.instance_methods.include?('test_this_test_is_pending')
|
61
|
+
assert_raises(Test::Unit::AssertionFailedError) do
|
62
|
+
send(:test_this_test_is_pending)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pending
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy McAnally
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-23 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: pending lets you define a block of test code that is currently "pending" functionality, similar to RSpec's pending method.
|
17
|
+
email: jeremymcanally@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
24
|
+
files:
|
25
|
+
- History.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- README.txt
|
28
|
+
- Rakefile
|
29
|
+
- lib/pending.rb
|
30
|
+
- pending.gemspec
|
31
|
+
- test/test_pending.rb
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://jeremymcanally.com
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options:
|
38
|
+
- --charset=UTF-8
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.3.5
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: pending lets you define a block of test code that is currently "pending" functionality, similar to RSpec's pending method
|
60
|
+
test_files:
|
61
|
+
- test/test_pending.rb
|