riot 0.11.4 → 0.12.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +6 -0
- data/VERSION +1 -1
- data/lib/riot/assertion.rb +10 -5
- data/lib/riot/assertion_macro.rb +10 -0
- data/lib/riot/assertion_macros/any.rb +16 -2
- data/lib/riot/assertion_macros/assigns.rb +42 -16
- data/lib/riot/assertion_macros/empty.rb +13 -2
- data/lib/riot/assertion_macros/equals.rb +17 -2
- data/lib/riot/assertion_macros/equivalent_to.rb +15 -1
- data/lib/riot/assertion_macros/exists.rb +13 -1
- data/lib/riot/assertion_macros/includes.rb +16 -0
- data/lib/riot/assertion_macros/kind_of.rb +13 -0
- data/lib/riot/assertion_macros/matches.rb +14 -0
- data/lib/riot/assertion_macros/nil.rb +10 -0
- data/lib/riot/assertion_macros/not_borat.rb +10 -0
- data/lib/riot/assertion_macros/raises.rb +28 -0
- data/lib/riot/assertion_macros/respond_to.rb +14 -0
- data/lib/riot/assertion_macros/same_elements.rb +13 -2
- data/lib/riot/assertion_macros/size.rb +12 -0
- data/lib/riot/context.rb +4 -126
- data/lib/riot/context_helpers.rb +132 -0
- data/lib/riot/context_options.rb +24 -0
- data/riot.gemspec +46 -27
- data/test.watchr +70 -0
- data/test/core/assertion_macros/any_test.rb +36 -4
- data/test/core/assertion_macros/assigns_test.rb +28 -0
- data/test/core/assertion_macros/empty_test.rb +35 -7
- data/test/core/assertion_macros/equals_test.rb +29 -0
- data/test/core/assertion_macros/equivalent_to_test.rb +36 -17
- data/test/core/assertion_macros/exists_test.rb +25 -4
- data/test/core/assertion_macros/includes_test.rb +12 -0
- data/test/core/assertion_macros/kind_of_test.rb +15 -0
- data/test/core/assertion_macros/matches_test.rb +49 -0
- data/test/core/assertion_macros/nil_test.rb +10 -8
- data/test/core/assertion_macros/not_borat_test.rb +14 -8
- data/test/core/assertion_macros/raises_test.rb +39 -6
- data/test/core/assertion_macros/respond_to_test.rb +18 -1
- data/test/core/assertion_macros/same_elements_test.rb +17 -0
- data/test/core/assertion_macros/size_test.rb +45 -5
- data/test/core/context/asserts_topic_test.rb +21 -0
- data/test/core/context/context_test.rb +35 -0
- data/test/core/{context_with_options_test.rb → context/context_with_options_test.rb} +0 -0
- data/test/core/context/deny_test.rb +25 -0
- data/test/core/context/helper_test.rb +11 -0
- data/test/core/context/hookup_test.rb +13 -0
- data/test/core/context/nested_contexts_test.rb +40 -0
- data/test/core/context/premium_setup_test.rb +19 -0
- data/test/core/context/should_test.rb +17 -0
- data/test/core/{using_describe_in_a_test.rb → context/using_describe_in_a_test.rb} +9 -0
- data/test/core/{chained_context_middleware_test.rb → middleware/chained_context_middleware_test.rb} +0 -0
- data/test/core/{context_middleware_test.rb → middleware/context_middleware_test.rb} +0 -0
- data/test/core/{assertion_macro_test.rb → runnable/assertion_macro_test.rb} +0 -0
- data/test/core/{assertion_test.rb → runnable/assertion_test.rb} +0 -0
- data/test/core/{message_test.rb → runnable/message_test.rb} +0 -0
- data/test/core/runnable/negative_assertion_test.rb +36 -0
- data/test/core/{setup_test.rb → runnable/setup_test.rb} +0 -0
- data/test/core/{situation_test.rb → runnable/situation_test.rb} +0 -0
- data/test/core/{teardown_test.rb → runnable/teardown_test.rb} +0 -0
- metadata +54 -32
- data/test/core/assertion_macros/matching_test.rb +0 -24
- data/test/core/context_test.rb +0 -157
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
3
|
context "A nil assertion macro" do
|
4
|
-
|
4
|
+
helper(:assert_nil) { |o| Riot::Assertion.new("foo") { o }.nil.run(Riot::Situation.new) }
|
5
5
|
|
6
|
-
asserts(":pass when result is nil")
|
7
|
-
|
8
|
-
end.equals([:pass, "is nil"])
|
9
|
-
|
10
|
-
asserts(":fail with message") do
|
11
|
-
Riot::Assertion.new("foo") { "a" }.nil.run(topic)[0..1]
|
12
|
-
end.equals([:fail, %Q{expected nil, not "a"}])
|
6
|
+
asserts(":pass when result is nil") { assert_nil(nil) }.equals([:pass, "is nil"])
|
7
|
+
asserts(":fail with message") { assert_nil("a")[0..1] }.equals([:fail, %Q{expected nil, not "a"}])
|
13
8
|
end # A nil assertion macro
|
9
|
+
|
10
|
+
context "A negative nil assertion macro" do
|
11
|
+
helper(:assert_not_nil) { |o| Riot::Assertion.new("foo", true) { o }.nil.run(Riot::Situation.new) }
|
12
|
+
|
13
|
+
asserts(":pass when result is not nil") { assert_not_nil(1) }.equals([:pass, "is not nil"])
|
14
|
+
asserts(":fail with message") { assert_not_nil(nil)[0..1] }.equals([:fail, %Q{expected is nil, not "non-nil"}])
|
15
|
+
end # A negative nil assertion macro
|
@@ -1,15 +1,21 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
3
|
context "A not! assertion macro" do
|
4
|
-
|
5
|
-
def assert_not(value)
|
6
|
-
Riot::Assertion.new("test") { value }.not!
|
7
|
-
end
|
8
|
-
end
|
4
|
+
helper(:assert_not!) { |o| Riot::Assertion.new("foo") { o }.not! }
|
9
5
|
|
10
|
-
assertion_test_passes("when value is false", "does exist ... not!") { assert_not(false) }
|
11
|
-
assertion_test_passes("when value is nil", "does exist ... not!")
|
6
|
+
assertion_test_passes("when value is false", "does exist ... not!") { assert_not!(false) }
|
7
|
+
assertion_test_passes("when value is nil", "does exist ... not!") { assert_not!(nil) }
|
12
8
|
assertion_test_fails("when value is not nil or false", "expected to exist ... not!") do
|
13
|
-
assert_not("funny")
|
9
|
+
assert_not!("funny")
|
14
10
|
end
|
15
11
|
end # A not! assertion macro
|
12
|
+
|
13
|
+
context "A negative not! assertion macro" do
|
14
|
+
helper(:assert_not_not!) { |o| Riot::Assertion.new("foo", true) { o }.not! }
|
15
|
+
|
16
|
+
assertion_test_fails("when value is false", "expected to not exist ... not!") { assert_not_not!(false) }
|
17
|
+
assertion_test_fails("when value is nil", "expected to not exist ... not!") { assert_not_not!(nil) }
|
18
|
+
assertion_test_passes("when value is not nil or false", "does not exist ... not!") do
|
19
|
+
assert_not_not!('borat')
|
20
|
+
end
|
21
|
+
end # A negative not! assertion macro
|
@@ -3,12 +3,13 @@ require 'teststrap'
|
|
3
3
|
class Whoops < Exception; end
|
4
4
|
|
5
5
|
context "A raises assertion macro" do
|
6
|
+
helper(:asserts_raises) { |o| Riot::Assertion.new("foo") { raise Whoops, o } }
|
6
7
|
assertion_test_passes("when expected exception is raised", "raises Whoops") do
|
7
|
-
|
8
|
+
asserts_raises(nil).raises(Whoops)
|
8
9
|
end
|
9
10
|
|
10
11
|
assertion_test_fails("when unexpected exception is raised", "should have raised Exception, not Whoops") do
|
11
|
-
|
12
|
+
asserts_raises(nil).raises(Exception)
|
12
13
|
end
|
13
14
|
|
14
15
|
assertion_test_fails("when nothing was raised", "should have raised Whoops, but raised nothing") do
|
@@ -16,18 +17,50 @@ context "A raises assertion macro" do
|
|
16
17
|
end
|
17
18
|
|
18
19
|
assertion_test_passes("when provided message equals expected message", %Q{raises Whoops with message "Mom"}) do
|
19
|
-
|
20
|
+
asserts_raises('Mom').raises(Whoops, 'Mom')
|
20
21
|
end
|
21
22
|
|
22
23
|
assertion_test_fails("when messages aren't equal", %Q{expected "Mom" for message, not "Dad"}) do
|
23
|
-
|
24
|
+
asserts_raises('Dad').raises(Whoops, 'Mom')
|
24
25
|
end
|
25
26
|
|
26
27
|
assertion_test_passes("when provided message matches expected message", %Q{raises Whoops with message /Mom/}) do
|
27
|
-
|
28
|
+
asserts_raises('Mom').raises(Whoops, /Mom/)
|
28
29
|
end
|
29
30
|
|
30
31
|
assertion_test_fails("when messages don't match", %Q{expected /Mom/ for message, not "Dad"}) do
|
31
|
-
|
32
|
+
asserts_raises('Dad').raises(Whoops, /Mom/)
|
33
|
+
end
|
34
|
+
end # A raises assertion macro
|
35
|
+
|
36
|
+
context "A negative raises assertion macro" do
|
37
|
+
helper(:deny_raises) { |o| Riot::Assertion.new("foo", true) { raise Whoops, o } }
|
38
|
+
|
39
|
+
assertion_test_fails("when expected exception is raised", "should have not raised Whoops, but raised Whoops") do
|
40
|
+
deny_raises(nil).raises(Whoops)
|
41
|
+
end
|
42
|
+
|
43
|
+
assertion_test_passes("when unexpected exception is raised", "not raised Exception") do
|
44
|
+
deny_raises(nil).raises(Exception)
|
45
|
+
end
|
46
|
+
|
47
|
+
assertion_test_passes("when nothing was raised", "raised nothing") do
|
48
|
+
Riot::Assertion.new("foo", true) { "barf" }.raises(Whoops)
|
49
|
+
end
|
50
|
+
|
51
|
+
assertion_test_fails("when provided message equals expected message", 'should have not raised Whoops with message "Mom", but raised Whoops with message "Mom"') do
|
52
|
+
deny_raises('Mom').raises(Whoops, 'Mom')
|
53
|
+
end
|
54
|
+
|
55
|
+
assertion_test_passes("when messages and exception aren't equal", 'not raised Exception with message "Dad"') do
|
56
|
+
deny_raises('Mom').raises(Exception, 'Dad')
|
57
|
+
end
|
58
|
+
|
59
|
+
assertion_test_fails("when provided message matches expected message", 'should have not raised Whoops with message /Mom/, but raised Whoops with message "Mom"') do
|
60
|
+
deny_raises('Mom').raises(Whoops, /Mom/)
|
61
|
+
end
|
62
|
+
|
63
|
+
assertion_test_fails("when messages don't match", "should have not raised Whoops with message /Mom/, but raised Whoops with message \"Dad\"") do
|
64
|
+
deny_raises('Dad').raises(Whoops,/Mom/)
|
32
65
|
end
|
33
66
|
end # A raises assertion macro
|
@@ -4,10 +4,27 @@ context "A respond_to assertion macro" do
|
|
4
4
|
setup { Riot::Assertion.new("foo") { "bar" } }
|
5
5
|
|
6
6
|
assertion_test_passes("when method is defined", "responds to :each_byte") { topic.respond_to(:each_byte) }
|
7
|
-
assertion_test_passes("using responds_to alias", "responds to :length")
|
7
|
+
assertion_test_passes("using responds_to alias", "responds to :length") { topic.responds_to(:length) }
|
8
8
|
|
9
9
|
assertion_test_fails("when method not defined", "expected method :goofballs is not defined") do
|
10
10
|
topic.respond_to(:goofballs)
|
11
11
|
end
|
12
12
|
|
13
13
|
end # A respond_to assertion macro
|
14
|
+
|
15
|
+
context "A negative respond_to assertion macro" do
|
16
|
+
setup { Riot::Assertion.new("foo", true) { "bar" } }
|
17
|
+
|
18
|
+
assertion_test_fails("when method is defined", "expected method :each_byte is defined") do
|
19
|
+
topic.respond_to(:each_byte)
|
20
|
+
end
|
21
|
+
|
22
|
+
assertion_test_fails("using responds_to alias", "expected method :length is defined") do
|
23
|
+
topic.responds_to(:length)
|
24
|
+
end
|
25
|
+
|
26
|
+
assertion_test_passes("when method is not defined", "does not respond to :goofballs") do
|
27
|
+
topic.respond_to(:goofballs)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -15,3 +15,20 @@ context "A same_elements assertion macro" do
|
|
15
15
|
topic.same_elements(["foo", "bar", 96])
|
16
16
|
end
|
17
17
|
end # A same_elements assertion macro
|
18
|
+
|
19
|
+
context "A negative same_elements assertion macro" do
|
20
|
+
setup { Riot::Assertion.new("test", true) { ["foo","bar", 69] } }
|
21
|
+
|
22
|
+
assertion_test_fails("when elements match", %Q{expected elements [69, "foo", "bar"] not to match ["foo", "bar", 69]}) do
|
23
|
+
topic.same_elements([69, "foo", "bar"])
|
24
|
+
end
|
25
|
+
|
26
|
+
assertion_test_fails("when any elements match", %Q{expected elements ["foo", "bar", 69] not to match ["foo", "bar", 69]}) do
|
27
|
+
topic.same_elements(["foo", "bar", 69])
|
28
|
+
end
|
29
|
+
|
30
|
+
assertion_test_passes("when elements do not match") do
|
31
|
+
topic.same_elements(["foo", "bar", 96])
|
32
|
+
end
|
33
|
+
|
34
|
+
end # A negative same_elements macro
|
@@ -1,11 +1,7 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
3
|
context "A size assertion macro" do
|
4
|
-
|
5
|
-
def assert_size(sizable, expected_size)
|
6
|
-
Riot::Assertion.new("test") { sizable }.size(expected_size)
|
7
|
-
end
|
8
|
-
end
|
4
|
+
helper(:assert_size) { |sizable, expected_size| Riot::Assertion.new("test") { sizable }.size(expected_size) }
|
9
5
|
|
10
6
|
assertion_test_passes("when string's size is as expected", "is of size 10") do
|
11
7
|
assert_size("washington", 10)
|
@@ -45,3 +41,47 @@ context "A size assertion macro" do
|
|
45
41
|
assert_size({}, 2...4)
|
46
42
|
end
|
47
43
|
end
|
44
|
+
|
45
|
+
context "A negative size assertion macro" do
|
46
|
+
helper(:deny_size) { |sizable, expected_size| Riot::Assertion.new("test", true) { sizable }.size(expected_size) }
|
47
|
+
|
48
|
+
assertion_test_fails("when string's size is as expected", 'expected size of "washington" to not be 10, not 10') do
|
49
|
+
deny_size("washington", 10)
|
50
|
+
end
|
51
|
+
assertion_test_fails("when string's size is in given range", 'expected size of "washington" to not be 9..12, not 10') do
|
52
|
+
deny_size("washington", 9..12)
|
53
|
+
end
|
54
|
+
|
55
|
+
assertion_test_passes("when string's size is not as expected", 'is not size 11') do
|
56
|
+
deny_size("washington", 11)
|
57
|
+
end
|
58
|
+
assertion_test_passes("when string's size is out of range", 'is not size 11..13') do
|
59
|
+
deny_size("washington", 11..13)
|
60
|
+
end
|
61
|
+
|
62
|
+
assertion_test_fails("when an array's size is as expected", 'expected size of [1, 2, 3] to not be 3, not 3') do
|
63
|
+
deny_size([1, 2, 3], 3)
|
64
|
+
end
|
65
|
+
assertion_test_fails("when an array's size is in given range", 'expected size of [1, 2, 3] to not be 3..4, not 3') do
|
66
|
+
deny_size([1, 2, 3], 3..4)
|
67
|
+
end
|
68
|
+
assertion_test_passes("when an array's size is not as expected", "is not size 2") do
|
69
|
+
deny_size([1, 2, 3], 2)
|
70
|
+
end
|
71
|
+
assertion_test_passes("when an array's size is out of range", "is not size 4..6") do
|
72
|
+
deny_size([1, 2, 3], 4..6)
|
73
|
+
end
|
74
|
+
|
75
|
+
assertion_test_fails("when a hash size is as expected", 'expected size of {:a=>"b"} to not be 1, not 1') do
|
76
|
+
deny_size({:a => 'b'}, 1)
|
77
|
+
end
|
78
|
+
assertion_test_fails("when a hash size is in range", 'expected size of {:a=>"b"} to not be 1...3, not 1') do
|
79
|
+
deny_size({:a => 'b'}, 1...3)
|
80
|
+
end
|
81
|
+
assertion_test_passes("when a hash size is not as expected", "is not size 2") do
|
82
|
+
deny_size({}, 2)
|
83
|
+
end
|
84
|
+
assertion_test_passes("when a hash size is out of range", "is not size 2...4") do
|
85
|
+
deny_size({}, 2...4)
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "The asserts_topic shortcut" do
|
4
|
+
setup do
|
5
|
+
Riot::Context.new("foo") {}.asserts_topic
|
6
|
+
end
|
7
|
+
|
8
|
+
should("return an Assertion") { topic }.kind_of(Riot::Assertion)
|
9
|
+
|
10
|
+
should("return the actual topic as the result of evaling the assertion") do
|
11
|
+
(situation = Riot::Situation.new).instance_variable_set(:@_topic, "bar")
|
12
|
+
topic.equals("bar").run(situation)
|
13
|
+
end.equals([:pass, %Q{is equal to "bar"}])
|
14
|
+
|
15
|
+
asserts(:to_s).equals("asserts that it")
|
16
|
+
|
17
|
+
context "with an explicit description" do
|
18
|
+
setup { Riot::Context.new("foo") {}.asserts_topic("get some") }
|
19
|
+
asserts(:to_s).equals("asserts get some")
|
20
|
+
end
|
21
|
+
end # The asserts_topic shortcut
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Reporting a context" do
|
4
|
+
setup do
|
5
|
+
a_context = Riot::Context.new("foobar") do
|
6
|
+
asserts("passing") { true }
|
7
|
+
asserts("failing") { false }
|
8
|
+
asserts("erroring") { raise Exception }
|
9
|
+
end
|
10
|
+
a_context.run(MockReporter.new)
|
11
|
+
end
|
12
|
+
|
13
|
+
asserts("one passed test") { topic.passes == 1 }
|
14
|
+
asserts("one failed test") { topic.failures == 1 }
|
15
|
+
asserts("one errored test") { topic.errors == 1 }
|
16
|
+
end # Reporting a context
|
17
|
+
|
18
|
+
context "Defining a context with multiple setups" do
|
19
|
+
setup do
|
20
|
+
@a_context = Riot::Context.new("foobar") do
|
21
|
+
setup { "foo" }
|
22
|
+
setup { topic + "bar" }
|
23
|
+
asserts("blah") { topic == "foobar" }
|
24
|
+
end
|
25
|
+
@a_context.run(MockReporter.new)
|
26
|
+
end
|
27
|
+
asserts("has setups") { @a_context.setups.size }.equals(2)
|
28
|
+
asserts("all tests pass") { topic.passes == 1 }
|
29
|
+
end # Defining a context with multiple setups
|
30
|
+
|
31
|
+
context "Making a new context" do
|
32
|
+
asserts("RootContext is used if nil parent is provided") do
|
33
|
+
Riot::Context.new("hello", nil) {}.parent
|
34
|
+
end.kind_of(Riot::RootContext)
|
35
|
+
end # Making a context
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Using denies" do
|
4
|
+
|
5
|
+
helper(:denial_context) do |&assertion_block|
|
6
|
+
report = Riot::Context.new("Apple Jackie") do
|
7
|
+
denies("with false", &assertion_block)
|
8
|
+
end.run(MockReporter.new)
|
9
|
+
|
10
|
+
[report.passes, report.failures, report.errors]
|
11
|
+
end # denial_context
|
12
|
+
|
13
|
+
asserts("result when returning false from the assertion block") do
|
14
|
+
denial_context { false }
|
15
|
+
end.equals([1,0,0])
|
16
|
+
|
17
|
+
asserts("result when returning true from the assertion block") do
|
18
|
+
denial_context { true }
|
19
|
+
end.equals([0,1,0])
|
20
|
+
|
21
|
+
asserts("result when assertion block has an exception") do
|
22
|
+
denial_context { raise Exception }
|
23
|
+
end.equals([0,0,1])
|
24
|
+
|
25
|
+
end # Using denies
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "A context with a helper" do
|
4
|
+
setup { "foo" }
|
5
|
+
|
6
|
+
helper(:upcase) { topic.upcase }
|
7
|
+
helper(:append) {|str| topic + str }
|
8
|
+
|
9
|
+
asserts("executing the helper") { upcase }.equals("FOO")
|
10
|
+
asserts("calling a helper with an argument") { append("bar") }.equals("foobar")
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Using a hookup" do
|
4
|
+
setup do
|
5
|
+
situation = Riot::Situation.new
|
6
|
+
a_context = Riot::Context.new("foobar") {}
|
7
|
+
a_context.setup { "I'm a string" }.run(situation)
|
8
|
+
a_context.hookup { topic.size }.run(situation)
|
9
|
+
situation.topic
|
10
|
+
end
|
11
|
+
|
12
|
+
asserts_topic.equals("I'm a string")
|
13
|
+
end # Using a hookup
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Nesting a context" do
|
4
|
+
setup do
|
5
|
+
a_context = Riot::Context.new("foobar") do
|
6
|
+
asserts("passing") { true }
|
7
|
+
context "bazboo" do
|
8
|
+
asserts("passing") { true }
|
9
|
+
asserts("failing") { false }
|
10
|
+
asserts("erroring") { raise Exception }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
a_context.run(MockReporter.new)
|
14
|
+
end
|
15
|
+
|
16
|
+
asserts("one passed test") { topic.passes == 2 }
|
17
|
+
asserts("one failed test") { topic.failures == 1 }
|
18
|
+
asserts("one errored test") { topic.errors == 1 }
|
19
|
+
|
20
|
+
context "with setups" do
|
21
|
+
setup do
|
22
|
+
a_context = Riot::Context.new("foobar") do
|
23
|
+
setup { "foo" }
|
24
|
+
context "bazboo" do
|
25
|
+
setup { topic + "bar" }
|
26
|
+
asserts("passing") { topic == "foobar" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
a_context.run(MockReporter.new)
|
30
|
+
end
|
31
|
+
|
32
|
+
asserts("parent setups are called") { topic.passes == 1 }
|
33
|
+
end # with setups
|
34
|
+
end # Nesting a context
|
35
|
+
|
36
|
+
context "A context with nested descriptions as classes" do
|
37
|
+
setup { Riot::Context.new(String) {}.context(Hash) {} }
|
38
|
+
asserts(:description).equals { Hash }
|
39
|
+
asserts(:detailed_description).equals("String Hash")
|
40
|
+
end # A context with nested descriptions as classes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
class SingletonArray
|
4
|
+
def self.<<(value); values << value; end
|
5
|
+
def self.values; @@values ||= []; end
|
6
|
+
end
|
7
|
+
|
8
|
+
context "A context with premium_setup" do
|
9
|
+
setup do
|
10
|
+
Riot::Context.new("Foo") do
|
11
|
+
setup { SingletonArray << "baz" }
|
12
|
+
setup(true) { SingletonArray << "bar" }
|
13
|
+
setup(true) { SingletonArray << "foo" }
|
14
|
+
end.run(MockReporter.new)
|
15
|
+
end
|
16
|
+
|
17
|
+
asserts("order of setups ensures topic") { SingletonArray.values }.equals(%w[foo bar baz])
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Using should" do
|
4
|
+
setup do
|
5
|
+
a_context = Riot::Context.new("foobar") do
|
6
|
+
should("pass") { true }
|
7
|
+
should("fail") { false }
|
8
|
+
should("error") { raise Exception }
|
9
|
+
end
|
10
|
+
a_context.run(MockReporter.new)
|
11
|
+
end
|
12
|
+
|
13
|
+
asserts("one passed test") { topic.passes == 1 }
|
14
|
+
asserts("one failed test") { topic.failures == 1 }
|
15
|
+
asserts("one errored test") { topic.errors == 1 }
|
16
|
+
end # Using should
|
17
|
+
|
@@ -1,5 +1,14 @@
|
|
1
1
|
require 'teststrap'
|
2
2
|
|
3
|
+
context "The describe alias" do
|
4
|
+
setup do
|
5
|
+
Riot::Context.new("Foo") {}
|
6
|
+
end
|
7
|
+
|
8
|
+
asserts("any ol' object") { Object.new }.responds_to(:describe)
|
9
|
+
asserts_topic.responds_to :describe
|
10
|
+
end # The describe alias
|
11
|
+
|
3
12
|
describe "This describe context" do
|
4
13
|
setup { "another thing is my" }
|
5
14
|
asserts_topic.kind_of(String)
|