riot 0.10.11 → 0.10.12.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/CHANGELOG +34 -0
- data/README.markdown +81 -456
- data/Rakefile +31 -28
- data/VERSION +1 -1
- data/lib/riot.rb +2 -1
- data/lib/riot/assertion.rb +1 -1
- data/lib/riot/assertion_macro.rb +51 -5
- data/lib/riot/assertion_macros/any.rb +1 -1
- data/lib/riot/assertion_macros/assigns.rb +2 -2
- data/lib/riot/assertion_macros/empty.rb +1 -1
- data/lib/riot/assertion_macros/equals.rb +4 -4
- data/lib/riot/assertion_macros/equivalent_to.rb +22 -0
- data/lib/riot/assertion_macros/includes.rb +2 -2
- data/lib/riot/assertion_macros/kind_of.rb +2 -2
- data/lib/riot/assertion_macros/matches.rb +2 -2
- data/lib/riot/assertion_macros/nil.rb +1 -1
- data/lib/riot/assertion_macros/raises.rb +7 -10
- data/lib/riot/assertion_macros/respond_to.rb +3 -2
- data/lib/riot/assertion_macros/same_elements.rb +1 -1
- data/lib/riot/assertion_macros/size.rb +2 -2
- data/lib/riot/context.rb +104 -19
- data/lib/riot/message.rb +23 -0
- data/lib/riot/rr.rb +35 -0
- data/lib/riot/runnable.rb +12 -0
- data/lib/riot/situation.rb +4 -0
- data/riot.gemspec +20 -4
- data/test/assertion_macro_test.rb +30 -0
- data/test/assertion_macros/assigns_test.rb +3 -3
- data/test/assertion_macros/equals_test.rb +2 -9
- data/test/assertion_macros/equivalent_to_test.rb +36 -0
- data/test/assertion_macros/respond_to_test.rb +1 -0
- data/test/assertion_macros/size_test.rb +6 -6
- data/test/assertion_test.rb +1 -1
- data/test/benchmark/message_concatenation.rb +82 -0
- data/test/context_test.rb +17 -2
- data/test/extensions/rrriot_test.rb +69 -0
- data/test/message_test.rb +35 -0
- data/test/teststrap.rb +1 -1
- metadata +27 -4
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
require 'riot/rr'
|
3
|
+
|
4
|
+
context "Riot with RR support" do
|
5
|
+
asserts("RR methods are available to an RR::Situation") do
|
6
|
+
Riot::RR::Situation.ancestors
|
7
|
+
end.includes(::RR::Adapters::RRMethods)
|
8
|
+
|
9
|
+
asserts("assertion passes when RR is satisfied") do
|
10
|
+
situation = Riot::RR::Situation.new
|
11
|
+
Riot::RR::Assertion.new("Satisfied") { true }.run(situation)
|
12
|
+
end.equals([:pass, ""])
|
13
|
+
|
14
|
+
asserts("assertion fails when RR is displeased") do
|
15
|
+
situation = Riot::RR::Situation.new
|
16
|
+
Riot::RR::Assertion.new("Displeased") { mock!.hello }.run(situation)
|
17
|
+
end.equals([:fail, "hello() Called 0 times. Expected 1 times."])
|
18
|
+
|
19
|
+
asserts("RR verification is reset between assertion runs") do
|
20
|
+
situation = Riot::RR::Situation.new
|
21
|
+
Riot::RR::Assertion.new("Displeased") { mock!.hello; mock!.what }.run(situation)
|
22
|
+
Riot::RR::Assertion.new("Displeased differently") { mock!.goodbye }.run(situation)
|
23
|
+
end.equals([:fail, "goodbye() Called 0 times. Expected 1 times."])
|
24
|
+
|
25
|
+
context "when using the RR context" do
|
26
|
+
setup { Riot::Context.new("foo") {} }
|
27
|
+
|
28
|
+
asserts("new assertions") do
|
29
|
+
topic.asserts("nothing really") { true }
|
30
|
+
end.kind_of(Riot::RR::Assertion)
|
31
|
+
|
32
|
+
asserts("situation class") { topic.__send__(:situation_class) }.equals(Riot::RR::Situation)
|
33
|
+
end # when using the RR context
|
34
|
+
|
35
|
+
context "does not carry expectations between assertions" do
|
36
|
+
setup do
|
37
|
+
Riot::Context.new("foo") {}
|
38
|
+
end
|
39
|
+
|
40
|
+
helper(:situation) { Riot::RR::Situation.new }
|
41
|
+
helper(:failing_assertion) { topic.asserts("I will fail") { mock!.a; mock!.b } }
|
42
|
+
helper(:passing_assertion) { topic.asserts("I should not fail") { true } }
|
43
|
+
|
44
|
+
asserts("first assertion fails") do
|
45
|
+
failing_assertion.run(situation).first
|
46
|
+
end.equals(:fail)
|
47
|
+
|
48
|
+
asserts("second assertion passes") do
|
49
|
+
passing_assertion.run(situation)
|
50
|
+
end.equals([:pass, ""])
|
51
|
+
end # when using the RR context
|
52
|
+
|
53
|
+
context "with RR doubles defined in setup" do
|
54
|
+
setup do
|
55
|
+
situation = Riot::RR::Situation.new
|
56
|
+
situation.setup { mock!.hello }
|
57
|
+
situation
|
58
|
+
end
|
59
|
+
|
60
|
+
asserts("an assertion") do
|
61
|
+
Riot::RR::Assertion.new("test") { "foo" }.run(topic)
|
62
|
+
end.equals([:fail, "hello() Called 0 times. Expected 1 times."])
|
63
|
+
|
64
|
+
asserts("another assertion won't use the expectations") do
|
65
|
+
Riot::RR::Assertion.new("test") { "bar" }.run(topic)
|
66
|
+
end.equals([:pass, ""])
|
67
|
+
|
68
|
+
end # with RR doubles defined in setup
|
69
|
+
end # Riot with RR support
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "A message object" do
|
4
|
+
asserts("blank message on initialization") { Riot::Message.new.to_s }.equals("")
|
5
|
+
|
6
|
+
asserts("opening phrase has inspected values") do
|
7
|
+
Riot::Message.new("bar", nil, {:a => 2}).to_s
|
8
|
+
end.equals(%q["bar" nil {:a=>2}])
|
9
|
+
|
10
|
+
asserts("+ pushes phrase onto string") do
|
11
|
+
Riot::Message.new.mommy.push("dearest").to_s
|
12
|
+
end.equals(%q[mommy dearest])
|
13
|
+
|
14
|
+
context "receiving calls for unbound methods" do
|
15
|
+
asserts("message") do
|
16
|
+
Riot::Message.new.bar.to_s
|
17
|
+
end.equals(%q[bar])
|
18
|
+
|
19
|
+
asserts("message with args") do
|
20
|
+
Riot::Message.new("Foo").bar("baz").to_s
|
21
|
+
end.equals(%q["Foo" bar "baz"])
|
22
|
+
|
23
|
+
asserts("in a long chain with underscored words") do
|
24
|
+
Riot::Message.new.bar.baz.your_mom.to_s
|
25
|
+
end.equals(%q[bar baz your mom])
|
26
|
+
end # unbound methods
|
27
|
+
|
28
|
+
asserts("#comma with a message") { Riot::Message.new.comma("and").to_s }.equals(", and")
|
29
|
+
|
30
|
+
asserts("#but") { Riot::Message.new.but.to_s }.equals(", but")
|
31
|
+
asserts("#but with message") { Riot::Message.new("Foo").but("a").to_s }.equals(%q["Foo", but "a"])
|
32
|
+
|
33
|
+
asserts("#not") { Riot::Message.new.not.to_s }.equals(", not")
|
34
|
+
asserts("#not with message") { Riot::Message.new("Foo").not("a").to_s }.equals(%q["Foo", not "a"])
|
35
|
+
end # A message object
|
data/test/teststrap.rb
CHANGED
@@ -7,7 +7,7 @@ Riot.dots if ENV["TM_MODE"]
|
|
7
7
|
module Riot
|
8
8
|
module AssertionTestContextMacros
|
9
9
|
|
10
|
-
def assertion_test_passes(description, success_message=
|
10
|
+
def assertion_test_passes(description, success_message="", &block)
|
11
11
|
context(description) do
|
12
12
|
setup(&block)
|
13
13
|
setup { topic.run(Riot::Situation.new) }
|
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.12.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin 'Gus' Knowlden
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-09 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rr
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: term-ansicolor
|
17
27
|
type: :runtime
|
@@ -45,6 +55,7 @@ files:
|
|
45
55
|
- lib/riot/assertion_macros/assigns.rb
|
46
56
|
- lib/riot/assertion_macros/empty.rb
|
47
57
|
- lib/riot/assertion_macros/equals.rb
|
58
|
+
- lib/riot/assertion_macros/equivalent_to.rb
|
48
59
|
- lib/riot/assertion_macros/exists.rb
|
49
60
|
- lib/riot/assertion_macros/includes.rb
|
50
61
|
- lib/riot/assertion_macros/kind_of.rb
|
@@ -56,14 +67,18 @@ files:
|
|
56
67
|
- lib/riot/assertion_macros/same_elements.rb
|
57
68
|
- lib/riot/assertion_macros/size.rb
|
58
69
|
- lib/riot/context.rb
|
70
|
+
- lib/riot/message.rb
|
59
71
|
- lib/riot/reporter.rb
|
72
|
+
- lib/riot/rr.rb
|
60
73
|
- lib/riot/runnable.rb
|
61
74
|
- lib/riot/situation.rb
|
62
75
|
- riot.gemspec
|
76
|
+
- test/assertion_macro_test.rb
|
63
77
|
- test/assertion_macros/any_test.rb
|
64
78
|
- test/assertion_macros/assigns_test.rb
|
65
79
|
- test/assertion_macros/empty_test.rb
|
66
80
|
- test/assertion_macros/equals_test.rb
|
81
|
+
- test/assertion_macros/equivalent_to_test.rb
|
67
82
|
- test/assertion_macros/exists_test.rb
|
68
83
|
- test/assertion_macros/includes_test.rb
|
69
84
|
- test/assertion_macros/kind_of_test.rb
|
@@ -76,10 +91,13 @@ files:
|
|
76
91
|
- test/assertion_macros/size_test.rb
|
77
92
|
- test/assertion_test.rb
|
78
93
|
- test/benchmark/colorize.rb
|
94
|
+
- test/benchmark/message_concatenation.rb
|
79
95
|
- test/benchmark/riot_vs_minitest.rb
|
80
96
|
- test/benchmark/same_elements_vs_set.rb
|
81
97
|
- test/benchmark/simple_context_and_assertions.rb
|
82
98
|
- test/context_test.rb
|
99
|
+
- test/extensions/rrriot_test.rb
|
100
|
+
- test/message_test.rb
|
83
101
|
- test/report_test.rb
|
84
102
|
- test/setup_test.rb
|
85
103
|
- test/situation_test.rb
|
@@ -102,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
120
|
version:
|
103
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
122
|
requirements:
|
105
|
-
- - "
|
123
|
+
- - ">"
|
106
124
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
125
|
+
version: 1.3.1
|
108
126
|
version:
|
109
127
|
requirements: []
|
110
128
|
|
@@ -114,10 +132,12 @@ signing_key:
|
|
114
132
|
specification_version: 3
|
115
133
|
summary: An extremely fast, expressive, and context-driven unit-testing framework. Protest the slow test.
|
116
134
|
test_files:
|
135
|
+
- test/assertion_macro_test.rb
|
117
136
|
- test/assertion_macros/any_test.rb
|
118
137
|
- test/assertion_macros/assigns_test.rb
|
119
138
|
- test/assertion_macros/empty_test.rb
|
120
139
|
- test/assertion_macros/equals_test.rb
|
140
|
+
- test/assertion_macros/equivalent_to_test.rb
|
121
141
|
- test/assertion_macros/exists_test.rb
|
122
142
|
- test/assertion_macros/includes_test.rb
|
123
143
|
- test/assertion_macros/kind_of_test.rb
|
@@ -130,10 +150,13 @@ test_files:
|
|
130
150
|
- test/assertion_macros/size_test.rb
|
131
151
|
- test/assertion_test.rb
|
132
152
|
- test/benchmark/colorize.rb
|
153
|
+
- test/benchmark/message_concatenation.rb
|
133
154
|
- test/benchmark/riot_vs_minitest.rb
|
134
155
|
- test/benchmark/same_elements_vs_set.rb
|
135
156
|
- test/benchmark/simple_context_and_assertions.rb
|
136
157
|
- test/context_test.rb
|
158
|
+
- test/extensions/rrriot_test.rb
|
159
|
+
- test/message_test.rb
|
137
160
|
- test/report_test.rb
|
138
161
|
- test/setup_test.rb
|
139
162
|
- test/situation_test.rb
|