Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2cd23c6
Showing
6 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
== 1.0.0 / 2008-12-29 | ||
|
||
* 1 major enhancement | ||
* Birthday! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
History.txt | ||
Manifest.txt | ||
README.txt | ||
Rakefile | ||
lib/pending.rb | ||
test/test_pending.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
pending | ||
by Jeremy McAnally | ||
http://jeremymcanally.com | ||
|
||
== DESCRIPTION: | ||
|
||
pending lets you define a block of test code that is currently "pending" functionality, | ||
similar to RSpec's pending method. | ||
|
||
== FEATURES/PROBLEMS: | ||
|
||
* A pending method to let you define pending test code | ||
|
||
== SYNOPSIS: | ||
|
||
The pending method lets you define a block of test code that is currently "pending" | ||
functionality. | ||
|
||
You can use it two ways. One is simply put a string as the parameter: | ||
|
||
def test_web_service_integration | ||
pending "This is not done yet..." | ||
end | ||
|
||
This will output a "P" in the test output alerting there is pending functionality. | ||
|
||
You can also supply a block of code: | ||
|
||
def test_new_helpers | ||
pending "New helpers for database display" do | ||
output = render_record(User.first) | ||
assert_equal "Jerry User (jerry@users.com)", output | ||
end | ||
end | ||
|
||
If the block doesn't fail, then the test will flunk with output like: | ||
|
||
<New helpers for database display> did not fail. | ||
|
||
If the test fails (i.e., the functionality isn't implemented), then it will | ||
not fail the surrounding test. | ||
|
||
== REQUIREMENTS: | ||
|
||
* Test::Unit | ||
|
||
== INSTALL: | ||
|
||
sudo gem install pending | ||
|
||
== LICENSE: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2008 FIXME (different license?) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Look in the tasks/setup.rb file for the various options that can be | ||
# configured in this Rakefile. The .rake files in the tasks directory | ||
# are where the options are used. | ||
|
||
begin | ||
require 'bones' | ||
Bones.setup | ||
rescue LoadError | ||
load 'tasks/setup.rb' | ||
end | ||
|
||
ensure_in_path 'lib' | ||
require 'pending' | ||
|
||
task :default => 'spec:run' | ||
|
||
PROJ.name = 'pending' | ||
PROJ.authors = 'FIXME (who is writing this software)' | ||
PROJ.email = 'FIXME (your e-mail)' | ||
PROJ.url = 'FIXME (project homepage)' | ||
PROJ.version = '0.1' | ||
PROJ.rubyforge.name = 'pending' | ||
|
||
PROJ.spec.opts << '--color' | ||
|
||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Test | ||
module Unit | ||
class TestCase | ||
# The pending method lets you define a block of test code that is currently "pending" | ||
# functionality. | ||
# | ||
# You can use it two ways. One is simply put a string as the parameter: | ||
# | ||
# def test_web_service_integration | ||
# pending "This is not done yet..." | ||
# end | ||
# | ||
# This will output a "P" in the test output alerting there is pending functionality. | ||
# | ||
# You can also supply a block of code: | ||
# | ||
# def test_new_helpers | ||
# pending "New helpers for database display" do | ||
# output = render_record(User.first) | ||
# assert_equal "Jerry User (jerry@users.com)", output | ||
# end | ||
# end | ||
# | ||
# If the block doesn't fail, then the test will flunk with output like: | ||
# | ||
# <New helpers for database display> did not fail. | ||
# | ||
# If the test fails (i.e., the functionality isn't implemented), then it will | ||
# not fail the surrounding test. | ||
# | ||
def pending(description = "", &block) | ||
if block_given? | ||
failed = false | ||
|
||
begin | ||
block.call | ||
rescue | ||
failed = true | ||
end | ||
|
||
flunk("<#{description}> did not fail.") unless failed | ||
end | ||
|
||
print "P" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'test/unit' | ||
require File.dirname(__FILE__) + "/../lib/pending.rb" | ||
|
||
# Quick and dirty way to test our output | ||
class StdoutStub | ||
attr_accessor :text | ||
|
||
def write(text) | ||
@text = text | ||
end | ||
end | ||
|
||
class TestPending < Test::Unit::TestCase | ||
def test_output | ||
old = $stdout | ||
$> = StdoutStub.new | ||
pending("poop") | ||
|
||
assert_equal "P", $>.text | ||
$> = $stdout | ||
end | ||
|
||
def test_does_not_require_block | ||
assert_nothing_raised do | ||
pending("hello there") | ||
end | ||
end | ||
|
||
def test_block_allows_fail | ||
assert_nothing_raised do | ||
pending("this is awesome") do | ||
assert false | ||
end | ||
end | ||
end | ||
|
||
def test_flunk_when_no_flunk | ||
assert_raises(Test::Unit::AssertionFailedError) do | ||
pending("this is fail") do | ||
assert true | ||
end | ||
end | ||
end | ||
|
||
def test_output_of_flunk_when_no_flunk | ||
begin | ||
pending("this is fail") do | ||
assert true | ||
end | ||
rescue StandardError => e | ||
assert_equal "<this is fail> did not fail.", e.message | ||
end | ||
end | ||
end |