riot 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/riot/macros.rb +5 -1
- data/riot.gemspec +2 -2
- data/test/assertion_macros/assertion_macro_raises_test.rb +12 -4
- metadata +2 -2
data/lib/riot/macros.rb
CHANGED
@@ -27,14 +27,18 @@ module Riot
|
|
27
27
|
# Asserts that the test raises the expected Exception
|
28
28
|
# asserts("test") { raise My::Exception }.raises(My::Exception)
|
29
29
|
# should("test") { raise My::Exception }.raises(My::Exception)
|
30
|
+
#
|
31
|
+
# You can also check to see if the provided message equals or matches your expectations. The message from
|
32
|
+
# the actual raised exception will be converted to a string before any comparison is executed.
|
30
33
|
# asserts("test") { raise My::Exception, "Foo" }.raises(My::Exception, "Foo")
|
31
34
|
# asserts("test") { raise My::Exception, "Foo Bar" }.raises(My::Exception, /Bar/)
|
35
|
+
# asserts("test") { raise My::Exception, ["a", "b"] }.raises(My::Exception, "ab")
|
32
36
|
def raises(expected, expected_message=nil)
|
33
37
|
actual_error = raised
|
34
38
|
@raised = nil
|
35
39
|
return fail("should have raised #{expected}, but raised nothing") unless actual_error
|
36
40
|
return fail("should have raised #{expected}, not #{error.class}") unless expected == actual_error.class
|
37
|
-
if expected_message && !(actual_error.message =~ %r[#{expected_message}])
|
41
|
+
if expected_message && !(actual_error.message.to_s =~ %r[#{expected_message}])
|
38
42
|
return fail("expected #{expected_message} for message, not #{actual_error.message}")
|
39
43
|
end
|
40
44
|
true
|
data/riot.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "riot"
|
3
|
-
s.version = "0.9.
|
4
|
-
s.date = "2009-10-
|
3
|
+
s.version = "0.9.6"
|
4
|
+
s.date = "2009-10-07"
|
5
5
|
s.summary = "An extremely fast, expressive, and context-driven unit-testing framework"
|
6
6
|
s.email = %w[gus@gusg.us]
|
7
7
|
s.homepage = "http://github.com/thumblemonks/protest"
|
@@ -7,17 +7,25 @@ context "raises assertion:" do
|
|
7
7
|
|
8
8
|
should "pass if provided message equals expectation" do
|
9
9
|
Riot::Assertion.new("foo", topic) { raise Exception, "I'm a nerd" }.raises(Exception, "I'm a nerd")
|
10
|
-
end
|
10
|
+
end
|
11
11
|
|
12
12
|
should "fail if provided message does not equal expectation" do
|
13
13
|
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception, "But I'm not")
|
14
14
|
end.kind_of(Riot::Failure)
|
15
15
|
|
16
16
|
should "pass if provided message matches expectation" do
|
17
|
-
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception,
|
18
|
-
end
|
17
|
+
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception, /nerd/)
|
18
|
+
end
|
19
19
|
|
20
20
|
should "fail if provided message does not match expectation" do
|
21
|
-
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception,
|
21
|
+
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception, /foo/)
|
22
22
|
end.kind_of(Riot::Failure)
|
23
|
+
|
24
|
+
should "pass if provided message as array equals expectation" do
|
25
|
+
Riot::Assertion.new("foo", topic) { raise(Exception, ["foo", "bar"]) }.raises(Exception, "foobar")
|
26
|
+
end
|
27
|
+
|
28
|
+
should "pass if provided message as array matches expectation" do
|
29
|
+
Riot::Assertion.new("foo", topic) { raise(Exception, ["foo", "bar"]) }.raises(Exception, /oba/)
|
30
|
+
end
|
23
31
|
end # raises assertion
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Knowlden
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|