Permalink
Browse files

Updates to support Ruby 1.9.2

  • Loading branch information...
1 parent f3afe19 commit 346551ec2ede9cfa6988ffd31d39bc84210b2c98 @glv committed Sep 16, 2010
Showing with 8 additions and 7 deletions.
  1. +6 −5 lib/rspec/unit/assertions.rb
  2. +1 −1 lib/rspec/unit/test_case.rb
  3. +1 −1 spec/test_case_spec.rb
@@ -366,7 +366,8 @@ def assert_no_match(regexp, string, message="")
end
end
- UncaughtThrow = {NameError => /^uncaught throw \`(.+)\'$/,
+ UncaughtThrow = {ArgumentError => /^uncaught throw :?(.+)$/,
+ NameError => /^uncaught throw \`(.+)\'$/,
ThreadError => /^uncaught throw \`(.+)\' in thread /} #`
##
@@ -390,11 +391,11 @@ def assert_throws(expected_symbol, message="", &proc)
end
full_message = build_message(message, "<?> should have been thrown.", expected_symbol)
assert_block(full_message){caught}
- rescue NameError, ThreadError => error
+ rescue ArgumentError, NameError, ThreadError => error
if UncaughtThrow[error.class] !~ error.message
raise error
end
- full_message = build_message(message, "<?> expected to be thrown but\n<?> was thrown.", expected_symbol, $1.intern)
+ full_message = build_message(message, "<?> expected to be thrown but\n<?> was thrown.", expected_symbol, $1.to_sym)
flunk(full_message)
end
end
@@ -414,11 +415,11 @@ def assert_nothing_thrown(message="", &proc)
assert(block_given?, "Should have passed a block to assert_nothing_thrown")
begin
proc.call
- rescue NameError, ThreadError => error
+ rescue ArgumentError, NameError, ThreadError => error
if UncaughtThrow[error.class] !~ error.message
raise error
end
- full_message = build_message(message, "<?> was thrown when nothing was expected", $1.intern)
+ full_message = build_message(message, "<?> was thrown when nothing was expected", $1.to_sym)
flunk(full_message)
end
assert(true, "Expected nothing to be thrown")
@@ -85,7 +85,7 @@ def self.test_method?(method_name)
end
def self.test_methods
- public_instance_methods(true).select{|m| test_method?(m)}
+ public_instance_methods(true).select{|m| test_method?(m)}.map{|m| m.to_s}
end
def self.number_of_tests
View
@@ -309,7 +309,7 @@ def test_baz; end
@foo.class_eval do
def test_baz; end
end
- test_baz_metadata[:caller].first.should == @foo.examples.first.metadata[:location]
+ test_baz_metadata[:caller].first.should match(/^#{Regexp.escape(@foo.examples.first.metadata[:location])}/)
test_baz_metadata[:caller].size.should == caller.size + 3
end

0 comments on commit 346551e

Please sign in to comment.