riot 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/riot/assertion_macros.rb +5 -3
- data/riot.gemspec +1 -1
- data/test/assertion_macros/assertion_macro_raises_test.rb +6 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.10
|
@@ -36,9 +36,11 @@ module Riot
|
|
36
36
|
def raises(expected, expected_message=nil)
|
37
37
|
actual_error = raised.original_exception
|
38
38
|
@raised = nil
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
if actual_error.nil?
|
40
|
+
return fail("should have raised #{expected}, but raised nothing")
|
41
|
+
elsif expected != actual_error.class
|
42
|
+
return fail("should have raised #{expected}, not #{actual_error.class}")
|
43
|
+
elsif expected_message && !(actual_error.message.to_s =~ %r[#{expected_message}])
|
42
44
|
return fail("expected #{expected_message} for message, not #{actual_error.message}")
|
43
45
|
end
|
44
46
|
true
|
data/riot.gemspec
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
+
class MyException < Exception; end
|
4
|
+
|
3
5
|
context "raises assertion:" do
|
4
6
|
setup { Riot::Situation.new }
|
5
7
|
|
6
8
|
should("raise an Exception") { raise Exception }.raises(Exception)
|
7
9
|
|
10
|
+
should "fail if Exception classes do not match" do
|
11
|
+
Riot::Assertion.new("foo", topic) { raise MyException }.raises(Exception)
|
12
|
+
end.kind_of(Riot::Failure)
|
13
|
+
|
8
14
|
should "pass if provided message equals expectation" do
|
9
15
|
Riot::Assertion.new("foo", topic) { raise Exception, "I'm a nerd" }.raises(Exception, "I'm a nerd")
|
10
16
|
end
|