riot 0.10.10 → 0.10.11
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 +32 -0
- data/VERSION +1 -1
- data/lib/riot.rb +6 -1
- data/lib/riot/assertion_macro.rb +1 -0
- data/lib/riot/assertion_macros/not_borat.rb +16 -0
- data/lib/riot/context.rb +17 -1
- data/lib/riot/reporter.rb +1 -0
- data/riot.gemspec +4 -1
- data/test/assertion_macros/not_borat_test.rb +15 -0
- data/test/benchmark/riot_vs_minitest.rb +2 -1
- data/test/benchmark/simple_context_and_assertions.rb +2 -1
- data/test/context_test.rb +20 -0
- data/test/report_test.rb +16 -1
- data/test/teststrap.rb +3 -1
- metadata +4 -1
data/CHANGELOG
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
*0.10.11*
|
2
|
+
|
3
|
+
* Context#asserts_topic now takes an optional description [gabrielg, jaknowlden]
|
4
|
+
|
5
|
+
asserts_topic.exists
|
6
|
+
asserts_topic("some kind of description").exists
|
7
|
+
|
8
|
+
* Added not! assertion macro [gabrielg, jaknowlden]
|
9
|
+
|
10
|
+
setup { User.new(:funny? => false) }
|
11
|
+
asserts(:funny?).not!
|
12
|
+
|
13
|
+
* Added Context#hookup to add some setup code to an already defined topic [jaknowlden]
|
14
|
+
|
15
|
+
context "yo mama" do
|
16
|
+
setup { YoMama.new }
|
17
|
+
# ...
|
18
|
+
context "is cool" do
|
19
|
+
hookup { topic.do_something_involving_state }
|
20
|
+
asserts_topic.kind_of?(YoMama)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
* Added Riot.alone! mode to ensure Riot.run is not run at-exit [jaknowlden]
|
25
|
+
|
26
|
+
Riot.alone!
|
27
|
+
Riot.run
|
28
|
+
|
29
|
+
This will still print output unless you also Riot.silently!
|
30
|
+
|
31
|
+
* Returning non-zero status at-exit when tests don't pass [gabrielg, jaknowlden]
|
32
|
+
|
1
33
|
*0.10.10*
|
2
34
|
|
3
35
|
* Passing assertion macros can now return a custom message [dasch, jaknowlden]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.11
|
data/lib/riot.rb
CHANGED
@@ -17,11 +17,16 @@ module Riot
|
|
17
17
|
the_reporter.summarize do
|
18
18
|
root_contexts.each { |ctx| ctx.run(the_reporter) }
|
19
19
|
end
|
20
|
+
the_reporter
|
20
21
|
end
|
21
22
|
|
22
23
|
def self.silently!; @silent = true; end
|
23
24
|
def self.silently?; defined?(@silent) && @silent == true end
|
24
25
|
|
26
|
+
# This means you don't want Riot to run tests for you. You will execute Riot.run manually.
|
27
|
+
def self.alone!; @alone = true; end
|
28
|
+
def self.alone?; defined?(@alone) && @alone == true end
|
29
|
+
|
25
30
|
def self.reporter=(reporter_class) @reporter_class = reporter_class; end
|
26
31
|
|
27
32
|
def self.reporter
|
@@ -36,7 +41,7 @@ module Riot
|
|
36
41
|
def self.verbose; Riot.reporter = Riot::VerboseStoryReporter; end
|
37
42
|
def self.dots; Riot.reporter = Riot::DotMatrixReporter; end
|
38
43
|
|
39
|
-
at_exit { run unless Riot.
|
44
|
+
at_exit { exit(run.success?) unless Riot.alone? }
|
40
45
|
end # Riot
|
41
46
|
|
42
47
|
class Object
|
data/lib/riot/assertion_macro.rb
CHANGED
@@ -29,6 +29,7 @@ require 'riot/assertion_macros/includes'
|
|
29
29
|
require 'riot/assertion_macros/kind_of'
|
30
30
|
require 'riot/assertion_macros/matches'
|
31
31
|
require 'riot/assertion_macros/nil'
|
32
|
+
require 'riot/assertion_macros/not_borat'
|
32
33
|
require 'riot/assertion_macros/raises'
|
33
34
|
require 'riot/assertion_macros/respond_to'
|
34
35
|
require 'riot/assertion_macros/same_elements'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Riot
|
2
|
+
# Asserts the result of the test is a non-truthy value. Read the following assertions in the way Borat
|
3
|
+
# learned about humor:
|
4
|
+
# asserts("you are funny") { false }.not!
|
5
|
+
# should("be funny") { nil }.not!
|
6
|
+
#
|
7
|
+
# Thusly, Borat would say "You are funny ... not!" The above two assertions would pass because the values
|
8
|
+
# are non-truthy.
|
9
|
+
class NotMacro < AssertionMacro
|
10
|
+
register :not!
|
11
|
+
|
12
|
+
def evaluate(actual)
|
13
|
+
actual ? fail("expected to exist ... not!") : pass("does exist ... not!")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/riot/context.rb
CHANGED
@@ -14,11 +14,27 @@ module Riot
|
|
14
14
|
def teardowns; @parent.teardowns + @teardowns; end
|
15
15
|
|
16
16
|
def setup(&definition) (@setups << Setup.new(&definition)).last; end
|
17
|
+
|
18
|
+
# A setup shortcut that returns the original topic so you don't have to. Good for nested setups. Instead
|
19
|
+
# of doing this in your context:
|
20
|
+
#
|
21
|
+
# setup do
|
22
|
+
# topic.do_something
|
23
|
+
# topic
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# You would do this:
|
27
|
+
#
|
28
|
+
# hookup { topic.do_something } # Yay!
|
29
|
+
def hookup(&definition)
|
30
|
+
setup { self.instance_eval(&definition); topic }
|
31
|
+
end
|
32
|
+
|
17
33
|
def teardown(&definition) (@teardowns << Setup.new(&definition)).last; end
|
18
34
|
|
19
35
|
def asserts(what, &definition) new_assertion("asserts", what, &definition); end
|
20
36
|
def should(what, &definition) new_assertion("should", what, &definition); end
|
21
|
-
def asserts_topic
|
37
|
+
def asserts_topic(what="topic"); asserts(what) { topic }; end
|
22
38
|
|
23
39
|
def context(description, &definition)
|
24
40
|
@contexts << self.class.new("#{@description} #{description}", self, &definition)
|
data/lib/riot/reporter.rb
CHANGED
data/riot.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{riot}
|
8
|
-
s.version = "0.10.
|
8
|
+
s.version = "0.10.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin 'Gus' Knowlden"]
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/riot/assertion_macros/kind_of.rb",
|
36
36
|
"lib/riot/assertion_macros/matches.rb",
|
37
37
|
"lib/riot/assertion_macros/nil.rb",
|
38
|
+
"lib/riot/assertion_macros/not_borat.rb",
|
38
39
|
"lib/riot/assertion_macros/raises.rb",
|
39
40
|
"lib/riot/assertion_macros/respond_to.rb",
|
40
41
|
"lib/riot/assertion_macros/same_elements.rb",
|
@@ -53,6 +54,7 @@ Gem::Specification.new do |s|
|
|
53
54
|
"test/assertion_macros/kind_of_test.rb",
|
54
55
|
"test/assertion_macros/matching_test.rb",
|
55
56
|
"test/assertion_macros/nil_test.rb",
|
57
|
+
"test/assertion_macros/not_borat_test.rb",
|
56
58
|
"test/assertion_macros/raises_test.rb",
|
57
59
|
"test/assertion_macros/respond_to_test.rb",
|
58
60
|
"test/assertion_macros/same_elements_test.rb",
|
@@ -84,6 +86,7 @@ Gem::Specification.new do |s|
|
|
84
86
|
"test/assertion_macros/kind_of_test.rb",
|
85
87
|
"test/assertion_macros/matching_test.rb",
|
86
88
|
"test/assertion_macros/nil_test.rb",
|
89
|
+
"test/assertion_macros/not_borat_test.rb",
|
87
90
|
"test/assertion_macros/raises_test.rb",
|
88
91
|
"test/assertion_macros/respond_to_test.rb",
|
89
92
|
"test/assertion_macros/same_elements_test.rb",
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "A not! assertion macro" do
|
4
|
+
setup do
|
5
|
+
def assert_not(value)
|
6
|
+
Riot::Assertion.new("test") { value }.not!
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
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!") { assert_not(nil) }
|
12
|
+
assertion_test_fails("when value is not nil or false", "expected to exist ... not!") do
|
13
|
+
assert_not("funny")
|
14
|
+
end
|
15
|
+
end # A not! assertion macro
|
@@ -1,4 +1,4 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__)+"/../../lib")
|
1
|
+
$:.unshift(File.dirname(__FILE__) + "/../../lib")
|
2
2
|
require 'benchmark'
|
3
3
|
|
4
4
|
#
|
@@ -46,6 +46,7 @@ n = 100 * 100
|
|
46
46
|
Benchmark.bmbm do |x|
|
47
47
|
x.report("Riot") do
|
48
48
|
Riot.silently!
|
49
|
+
Riot.alone!
|
49
50
|
n.times { Riot.run }
|
50
51
|
end
|
51
52
|
|
data/test/context_test.rb
CHANGED
@@ -87,4 +87,24 @@ context "The asserts_topic shortcut" do
|
|
87
87
|
(situation = Riot::Situation.new).topic = "bar"
|
88
88
|
topic.equals("bar").run(situation)
|
89
89
|
end.equals([:pass, %Q{is equal to "bar"}])
|
90
|
+
|
91
|
+
asserts(:to_s).equals("asserts topic")
|
92
|
+
|
93
|
+
context "with an explicit description" do
|
94
|
+
setup { Riot::Context.new("foo") {}.asserts_topic("get some") }
|
95
|
+
asserts(:to_s).equals("asserts get some")
|
96
|
+
end
|
97
|
+
|
90
98
|
end # The asserts_topic shortcut
|
99
|
+
|
100
|
+
context "Using a hookup" do
|
101
|
+
setup do
|
102
|
+
situation = Riot::Situation.new
|
103
|
+
a_context = Riot::Context.new("foobar") {}
|
104
|
+
a_context.setup { "I'm a string" }.run(situation)
|
105
|
+
a_context.hookup { topic.size }.run(situation)
|
106
|
+
situation.topic
|
107
|
+
end
|
108
|
+
|
109
|
+
asserts_topic.equals("I'm a string")
|
110
|
+
end # Using a hookup
|
data/test/report_test.rb
CHANGED
@@ -6,6 +6,7 @@ context "A reporter" do
|
|
6
6
|
def pass(d, message) "passed(#{d}, #{message.inspect})"; end
|
7
7
|
def fail(d, message) "failed(#{d}, #{message})"; end
|
8
8
|
def error(d, e) "errored(#{d}, #{e})"; end
|
9
|
+
def results(time); end
|
9
10
|
end.new
|
10
11
|
end
|
11
12
|
|
@@ -44,9 +45,23 @@ context "A reporter" do
|
|
44
45
|
|
45
46
|
context "instance" do
|
46
47
|
setup { Riot::Reporter.new }
|
47
|
-
|
48
48
|
should("return self invoking new") { topic.new }.equals { topic }
|
49
49
|
end
|
50
|
+
|
51
|
+
context "with no errors or failures" do
|
52
|
+
hookup { topic.report("foo", [:pass, nil]) }
|
53
|
+
asserts(:success?)
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with failures and no errors" do
|
57
|
+
hookup { topic.report("foo", [:fail, "blah"]) }
|
58
|
+
asserts(:success?).equals(false)
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with errors and no failures" do
|
62
|
+
hookup { topic.report("foo", [:error, Exception.new("boogers")]) }
|
63
|
+
asserts(:success?).equals(false)
|
64
|
+
end
|
50
65
|
end # A reporter
|
51
66
|
|
52
67
|
require 'stringio'
|
data/test/teststrap.rb
CHANGED
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.10.
|
4
|
+
version: 0.10.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin 'Gus' Knowlden
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/riot/assertion_macros/kind_of.rb
|
51
51
|
- lib/riot/assertion_macros/matches.rb
|
52
52
|
- lib/riot/assertion_macros/nil.rb
|
53
|
+
- lib/riot/assertion_macros/not_borat.rb
|
53
54
|
- lib/riot/assertion_macros/raises.rb
|
54
55
|
- lib/riot/assertion_macros/respond_to.rb
|
55
56
|
- lib/riot/assertion_macros/same_elements.rb
|
@@ -68,6 +69,7 @@ files:
|
|
68
69
|
- test/assertion_macros/kind_of_test.rb
|
69
70
|
- test/assertion_macros/matching_test.rb
|
70
71
|
- test/assertion_macros/nil_test.rb
|
72
|
+
- test/assertion_macros/not_borat_test.rb
|
71
73
|
- test/assertion_macros/raises_test.rb
|
72
74
|
- test/assertion_macros/respond_to_test.rb
|
73
75
|
- test/assertion_macros/same_elements_test.rb
|
@@ -121,6 +123,7 @@ test_files:
|
|
121
123
|
- test/assertion_macros/kind_of_test.rb
|
122
124
|
- test/assertion_macros/matching_test.rb
|
123
125
|
- test/assertion_macros/nil_test.rb
|
126
|
+
- test/assertion_macros/not_borat_test.rb
|
124
127
|
- test/assertion_macros/raises_test.rb
|
125
128
|
- test/assertion_macros/respond_to_test.rb
|
126
129
|
- test/assertion_macros/same_elements_test.rb
|