riot 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -1
- data/lib/riot/macros.rb +10 -0
- data/riot.gemspec +10 -3
- data/test/assertion_macro_assigns_test.rb +40 -0
- data/test/assertion_macro_equals_test.rb +13 -0
- data/test/assertion_macro_exists_test.rb +17 -0
- data/test/assertion_macro_kind_of_test.rb +13 -0
- data/test/assertion_macro_matching_test.rb +17 -0
- data/test/assertion_macro_nil_test.rb +13 -0
- data/test/assertion_macro_raises_test.rb +23 -0
- data/test/assertion_test.rb +7 -113
- metadata +10 -3
data/Rakefile
CHANGED
data/lib/riot/macros.rb
CHANGED
@@ -14,6 +14,16 @@ module Riot
|
|
14
14
|
actual.nil? || fail("expected nil, not #{actual.inspect}")
|
15
15
|
end
|
16
16
|
|
17
|
+
# Asserts that the result of the test is a non-nil value. This is useful in the case where you don't want
|
18
|
+
# to translate the result of the test into a boolean value
|
19
|
+
# asserts("test") { "foo" }.exists
|
20
|
+
# should("test") { 123 }.exists
|
21
|
+
# asserts("test") { "" }.exists
|
22
|
+
# asserts("test") { nil }.exists # This would fail
|
23
|
+
def exists
|
24
|
+
!actual.nil? || fail("expected a non-nil value")
|
25
|
+
end
|
26
|
+
|
17
27
|
# Asserts that the test raises the expected Exception
|
18
28
|
# asserts("test") { raise My::Exception }.raises(My::Exception)
|
19
29
|
# should("test") { raise My::Exception }.raises(My::Exception)
|
data/riot.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
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.3"
|
4
|
+
s.date = "2009-10-06"
|
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"
|
8
|
-
s.description = "An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks"
|
8
|
+
s.description = "An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks. Protest the slow test."
|
9
9
|
s.authors = %w[Justin\ Knowlden]
|
10
10
|
|
11
11
|
s.has_rdoc = false
|
@@ -26,6 +26,13 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.test_files = %w[
|
28
28
|
Rakefile
|
29
|
+
test/assertion_macro_assigns_test.rb
|
30
|
+
test/assertion_macro_equals_test.rb
|
31
|
+
test/assertion_macro_exists_test.rb
|
32
|
+
test/assertion_macro_kind_of_test.rb
|
33
|
+
test/assertion_macro_matching_test.rb
|
34
|
+
test/assertion_macro_nil_test.rb
|
35
|
+
test/assertion_macro_raises_test.rb
|
29
36
|
test/assertion_test.rb
|
30
37
|
test/benchmark/simple_context_and_assertions.rb
|
31
38
|
test/context_test.rb
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "assigns assertion:" do
|
4
|
+
setup do
|
5
|
+
@fake_situation = Riot::Situation.new
|
6
|
+
object_with_instance_variables = Riot::Situation.new
|
7
|
+
object_with_instance_variables.instance_eval { @foo = "bar"; @bar = nil}
|
8
|
+
object_with_instance_variables
|
9
|
+
end
|
10
|
+
|
11
|
+
asserts("an instance variable was assigned") do
|
12
|
+
test_object = topic
|
13
|
+
Riot::Assertion.new("duh", @fake_situation) { test_object }.assigns(:foo)
|
14
|
+
end
|
15
|
+
|
16
|
+
asserts("an instance variable was never assigned") do
|
17
|
+
test_object = topic
|
18
|
+
Riot::Assertion.new("foo", @fake_situation) { test_object }.assigns(:baz)
|
19
|
+
end.kind_of(Riot::Failure)
|
20
|
+
|
21
|
+
asserts "an instance variable was defined with nil value" do
|
22
|
+
test_object = topic
|
23
|
+
Riot::Assertion.new("foo", @fake_situation) { test_object }.assigns(:bar).message
|
24
|
+
end.equals("expected @bar to be assigned a value")
|
25
|
+
|
26
|
+
asserts("an instance variable was assigned a specific value") do
|
27
|
+
test_object = topic
|
28
|
+
Riot::Assertion.new("duh", @fake_situation) { test_object }.assigns(:foo, "bar")
|
29
|
+
end
|
30
|
+
|
31
|
+
asserts("failure when instance never assigned even when a value is expected") do
|
32
|
+
test_object = topic
|
33
|
+
Riot::Assertion.new("duh", @fake_situation) { test_object }.assigns(:bar, "bar").message
|
34
|
+
end.equals("expected @bar to be assigned a value")
|
35
|
+
|
36
|
+
asserts("failure when expected value is not assigned to variable with a value") do
|
37
|
+
test_object = topic
|
38
|
+
Riot::Assertion.new("duh", @fake_situation) { test_object }.assigns(:foo, "baz").message
|
39
|
+
end.equals("expected @foo to be equal to 'baz', not 'bar'")
|
40
|
+
end # assigns assertion
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "equals assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
|
+
asserts "result equals expectation" do
|
7
|
+
Riot::Assertion.new("i will pass", topic) { "foo bar" }.equals("foo bar")
|
8
|
+
end
|
9
|
+
|
10
|
+
should "raise a Failure if results don't equal each other" do
|
11
|
+
Riot::Assertion.new("failure", topic) { "bar" }.equals("foo")
|
12
|
+
end.kind_of(Riot::Failure)
|
13
|
+
end # equals assertion
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "nil assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
|
+
asserts("result has a value") do
|
7
|
+
Riot::Assertion.new("foo", topic) { "foo" }.exists
|
8
|
+
end
|
9
|
+
|
10
|
+
asserts("empty string is considered a value") do
|
11
|
+
Riot::Assertion.new("foo", topic) { "" }.exists
|
12
|
+
end
|
13
|
+
|
14
|
+
should "raise a Failure if value is nil" do
|
15
|
+
Riot::Assertion.new("foo", topic) { nil }.exists
|
16
|
+
end.kind_of(Riot::Failure)
|
17
|
+
end # nil assertion
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "kind_of assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
|
+
asserts "specific result is a kind of String" do
|
7
|
+
Riot::Assertion.new("foo", topic) { "a" }.kind_of(String)
|
8
|
+
end
|
9
|
+
|
10
|
+
should "raise a Failure if not a kind of String" do
|
11
|
+
Riot::Assertion.new("foo", topic) { 0 }.kind_of(String)
|
12
|
+
end.kind_of(Riot::Failure)
|
13
|
+
end # kind_of assertion
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "matching assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
|
+
asserts "result matches expression" do
|
7
|
+
Riot::Assertion.new("foo", topic) { "a" }.matches(%r[.])
|
8
|
+
end.equals(0)
|
9
|
+
|
10
|
+
should "raise a Failure if result does not match" do
|
11
|
+
Riot::Assertion.new("foo", topic) { "" }.matches(%r[.])
|
12
|
+
end.kind_of(Riot::Failure)
|
13
|
+
|
14
|
+
should "return the result of a matching operation" do
|
15
|
+
Riot::Assertion.new("foo", topic) { "a" }.matches("a")
|
16
|
+
end.equals(0)
|
17
|
+
end # maching assertion
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "nil assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
|
+
asserts("result is nil") do
|
7
|
+
Riot::Assertion.new("foo", topic) { nil }.nil
|
8
|
+
end
|
9
|
+
|
10
|
+
should "raise a Failure if not nil" do
|
11
|
+
Riot::Assertion.new("foo", topic) { "a" }.nil
|
12
|
+
end.kind_of(Riot::Failure)
|
13
|
+
end # nil assertion
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "raises assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
|
+
should("raise an Exception") { raise Exception }.raises(Exception)
|
7
|
+
|
8
|
+
should "pass if provided message equals expectation" do
|
9
|
+
Riot::Assertion.new("foo", topic) { raise Exception, "I'm a nerd" }.raises(Exception, "I'm a nerd")
|
10
|
+
end.equals(true)
|
11
|
+
|
12
|
+
should "fail if provided message does not equal expectation" do
|
13
|
+
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception, "But I'm not")
|
14
|
+
end.kind_of(Riot::Failure)
|
15
|
+
|
16
|
+
should "pass if provided message matches expectation" do
|
17
|
+
Riot::Assertion.new("foo", topic) { raise(Exception, "I'm a nerd") }.raises(Exception, %r[nerd])
|
18
|
+
end.equals(true)
|
19
|
+
|
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, %r[foo])
|
22
|
+
end.kind_of(Riot::Failure)
|
23
|
+
end # raises assertion
|
data/test/assertion_test.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
-
fake_situation = Riot::Situation.new
|
4
|
-
|
5
3
|
context "basic assertion:" do
|
4
|
+
setup { Riot::Situation.new }
|
5
|
+
|
6
6
|
should "have a description" do
|
7
|
-
Riot::Assertion.new("i will pass",
|
7
|
+
Riot::Assertion.new("i will pass", topic).to_s
|
8
8
|
end.equals("i will pass")
|
9
9
|
|
10
10
|
asserts "pass? is true when assertion passed" do
|
11
|
-
Riot::Assertion.new("i will pass",
|
11
|
+
Riot::Assertion.new("i will pass", topic) { true }.passed?
|
12
12
|
end
|
13
13
|
|
14
14
|
asserts "failure? is true when assertion does not pass" do
|
15
|
-
Riot::Assertion.new("i will pass",
|
15
|
+
Riot::Assertion.new("i will pass", topic) { false }.failed?
|
16
16
|
end
|
17
17
|
|
18
18
|
asserts "error? is true when an unexpected Exception is raised" do
|
19
|
-
Riot::Assertion.new("error",
|
19
|
+
Riot::Assertion.new("error", topic) { raise Exception, "blah" }.errored?
|
20
20
|
end
|
21
21
|
|
22
22
|
context "that fails while executing test" do
|
23
23
|
setup do
|
24
|
+
fake_situation = Riot::Situation.new
|
24
25
|
Riot::Assertion.new("error", fake_situation) { fail("I'm a bum") }
|
25
26
|
end
|
26
27
|
|
@@ -29,110 +30,3 @@ context "basic assertion:" do
|
|
29
30
|
should("assign assertion to failure") { topic.result }.assigns(:assertion)
|
30
31
|
end # that fails while executing test
|
31
32
|
end # basic assertion
|
32
|
-
|
33
|
-
context "equals assertion:" do
|
34
|
-
asserts "result equals expectation" do
|
35
|
-
Riot::Assertion.new("i will pass", fake_situation) { "foo bar" }.equals("foo bar")
|
36
|
-
end
|
37
|
-
|
38
|
-
should "raise a Failure if results don't equal each other" do
|
39
|
-
Riot::Assertion.new("failure", fake_situation) { "bar" }.equals("foo")
|
40
|
-
end.kind_of(Riot::Failure)
|
41
|
-
end # equals assertion
|
42
|
-
|
43
|
-
context "nil assertion:" do
|
44
|
-
asserts("result is nil") { Riot::Assertion.new("foo", fake_situation) { nil }.nil }
|
45
|
-
should "raise a Failure if not nil" do
|
46
|
-
Riot::Assertion.new("foo", fake_situation) { "a" }.nil
|
47
|
-
end.kind_of(Riot::Failure)
|
48
|
-
end # nil assertion
|
49
|
-
|
50
|
-
context "raises assertion:" do
|
51
|
-
should("raise an Exception") { raise Exception }.raises(Exception)
|
52
|
-
|
53
|
-
should "pass if provided message equals expectation" do
|
54
|
-
Riot::Assertion.new("foo", fake_situation) do
|
55
|
-
raise Exception, "I'm a nerd"
|
56
|
-
end.raises(Exception, "I'm a nerd")
|
57
|
-
end.equals(true)
|
58
|
-
|
59
|
-
should "fail if provided message does not equal expectation" do
|
60
|
-
Riot::Assertion.new("foo", fake_situation) do
|
61
|
-
raise(Exception, "I'm a nerd")
|
62
|
-
end.raises(Exception, "But I'm not")
|
63
|
-
end.kind_of(Riot::Failure)
|
64
|
-
|
65
|
-
should "pass if provided message matches expectation" do
|
66
|
-
Riot::Assertion.new("foo", fake_situation) do
|
67
|
-
raise(Exception, "I'm a nerd")
|
68
|
-
end.raises(Exception, %r[nerd])
|
69
|
-
end.equals(true)
|
70
|
-
|
71
|
-
should "fail if provided message does not match expectation" do
|
72
|
-
Riot::Assertion.new("foo", fake_situation) do
|
73
|
-
raise(Exception, "I'm a nerd")
|
74
|
-
end.raises(Exception, %r[foo])
|
75
|
-
end.kind_of(Riot::Failure)
|
76
|
-
end # raises assertion
|
77
|
-
|
78
|
-
context "matching assertion:" do
|
79
|
-
asserts "result matches expression" do
|
80
|
-
Riot::Assertion.new("foo", fake_situation) { "a" }.matches(%r[.])
|
81
|
-
end.equals(0)
|
82
|
-
|
83
|
-
should "raise a Failure if result does not match" do
|
84
|
-
Riot::Assertion.new("foo", fake_situation) { "" }.matches(%r[.])
|
85
|
-
end.kind_of(Riot::Failure)
|
86
|
-
|
87
|
-
should "return the result of a matching operation" do
|
88
|
-
Riot::Assertion.new("foo", fake_situation) { "a" }.matches("a")
|
89
|
-
end.equals(0)
|
90
|
-
end # maching assertion
|
91
|
-
|
92
|
-
context "kind_of assertion:" do
|
93
|
-
asserts "specific result is a kind of String" do
|
94
|
-
Riot::Assertion.new("foo", fake_situation) { "a" }.kind_of(String)
|
95
|
-
end
|
96
|
-
|
97
|
-
should "raise a Failure if not a kind of String" do
|
98
|
-
Riot::Assertion.new("foo", fake_situation) { 0 }.kind_of(String)
|
99
|
-
end.kind_of(Riot::Failure)
|
100
|
-
end # kind_of assertion
|
101
|
-
|
102
|
-
context "assigns assertion:" do
|
103
|
-
setup do
|
104
|
-
situation = Riot::Situation.new
|
105
|
-
situation.instance_eval { @foo = "bar"; @bar = nil}
|
106
|
-
situation
|
107
|
-
end
|
108
|
-
|
109
|
-
asserts("an instance variable was assigned") do
|
110
|
-
test_object = topic
|
111
|
-
Riot::Assertion.new("duh", fake_situation) { test_object }.assigns(:foo)
|
112
|
-
end
|
113
|
-
|
114
|
-
asserts("an instance variable was never assigned") do
|
115
|
-
test_object = topic
|
116
|
-
Riot::Assertion.new("foo", fake_situation) { test_object }.assigns(:baz)
|
117
|
-
end.kind_of(Riot::Failure)
|
118
|
-
|
119
|
-
asserts "an instance variable was defined with nil value" do
|
120
|
-
test_object = topic
|
121
|
-
Riot::Assertion.new("foo", fake_situation) { test_object }.assigns(:bar).message
|
122
|
-
end.equals("expected @bar to be assigned a value")
|
123
|
-
|
124
|
-
asserts("an instance variable was assigned a specific value") do
|
125
|
-
test_object = topic
|
126
|
-
Riot::Assertion.new("duh", fake_situation) { test_object }.assigns(:foo, "bar")
|
127
|
-
end
|
128
|
-
|
129
|
-
asserts("failure when instance never assigned even when a value is expected") do
|
130
|
-
test_object = topic
|
131
|
-
Riot::Assertion.new("duh", fake_situation) { test_object }.assigns(:bar, "bar").message
|
132
|
-
end.equals("expected @bar to be assigned a value")
|
133
|
-
|
134
|
-
asserts("failure when expected value is not assigned to variable with a value") do
|
135
|
-
test_object = topic
|
136
|
-
Riot::Assertion.new("duh", fake_situation) { test_object }.assigns(:foo, "baz").message
|
137
|
-
end.equals("expected @foo to be equal to 'baz', not 'bar'")
|
138
|
-
end # assigns 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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Knowlden
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-06 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks
|
16
|
+
description: An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks. Protest the slow test.
|
17
17
|
email:
|
18
18
|
- gus@gusg.us
|
19
19
|
executables: []
|
@@ -62,6 +62,13 @@ specification_version: 3
|
|
62
62
|
summary: An extremely fast, expressive, and context-driven unit-testing framework
|
63
63
|
test_files:
|
64
64
|
- Rakefile
|
65
|
+
- test/assertion_macro_assigns_test.rb
|
66
|
+
- test/assertion_macro_equals_test.rb
|
67
|
+
- test/assertion_macro_exists_test.rb
|
68
|
+
- test/assertion_macro_kind_of_test.rb
|
69
|
+
- test/assertion_macro_matching_test.rb
|
70
|
+
- test/assertion_macro_nil_test.rb
|
71
|
+
- test/assertion_macro_raises_test.rb
|
65
72
|
- test/assertion_test.rb
|
66
73
|
- test/benchmark/simple_context_and_assertions.rb
|
67
74
|
- test/context_test.rb
|