1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/lib/active_support/testing/pending.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2009-02-02 15:03:35 -05:00
# Some code from jeremymcanally's "pending"
# http://github.com/jeremymcanally/pending/tree/master
module ActiveSupport
module Testing
module Pending
unless defined?(Spec)
2009-02-02 15:03:35 -05:00
@@pending_cases = []
@@at_exit = false
2009-02-02 15:03:35 -05:00
def pending(description = "", &block)
if description.is_a?(Symbol)
is_pending = $tags[description]
return block.call unless is_pending
end
if block_given?
failed = false
2009-02-02 15:03:35 -05:00
begin
block.call
2009-04-13 19:56:04 -04:00
rescue Exception
failed = true
end
2009-02-02 15:03:35 -05:00
flunk("<#{description}> did not fail.") unless failed
end
caller[0] =~ (/(.*):(.*):in `(.*)'/)
@@pending_cases << "#{$3} at #{$1}, line #{$2}"
print "P"
@@at_exit ||= begin
at_exit do
puts "\nPending Cases:"
@@pending_cases.each do |test_case|
puts test_case
end
2009-02-02 15:03:35 -05:00
end
end
end
end
end
end
end