Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jm committed Dec 30, 2008
0 parents commit 2cd23c6
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 0 deletions.
4 changes: 4 additions & 0 deletions History.txt
@@ -0,0 +1,4 @@
== 1.0.0 / 2008-12-29

* 1 major enhancement
* Birthday!
6 changes: 6 additions & 0 deletions Manifest.txt
@@ -0,0 +1,6 @@
History.txt
Manifest.txt
README.txt
Rakefile
lib/pending.rb
test/test_pending.rb
74 changes: 74 additions & 0 deletions README.txt
@@ -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.
26 changes: 26 additions & 0 deletions Rakefile
@@ -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
48 changes: 48 additions & 0 deletions lib/pending.rb
@@ -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
54 changes: 54 additions & 0 deletions test/test_pending.rb
@@ -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

0 comments on commit 2cd23c6

Please sign in to comment.