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
data/test/core/{chained_context_middleware_test.rb → middleware/chained_context_middleware_test.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "A negative assertion test" do
|
4
|
+
|
5
|
+
helper(:negative_assertion) do |&definition|
|
6
|
+
Riot::Assertion.new("foo", true, &definition)
|
7
|
+
end
|
8
|
+
|
9
|
+
asserts("response when evaluated with false result") do
|
10
|
+
negative_assertion { false }.run(Riot::Situation.new)
|
11
|
+
end.equals([:pass, ""])
|
12
|
+
|
13
|
+
asserts("response when evaluated with nil result") do
|
14
|
+
negative_assertion { false }.run(Riot::Situation.new)
|
15
|
+
end.equals([:pass, ""])
|
16
|
+
|
17
|
+
asserts("response when evaluated with true result") do
|
18
|
+
negative_assertion { true }.run(Riot::Situation.new)
|
19
|
+
end.equals([:fail, "Expected non-true but got true instead", nil, nil])
|
20
|
+
|
21
|
+
asserts("response when evaluated with \"bar\" result") do
|
22
|
+
negative_assertion { "bar" }.run(Riot::Situation.new)
|
23
|
+
end.equals([:fail, "Expected non-true but got \"bar\" instead", nil, nil])
|
24
|
+
|
25
|
+
asserts("response when evaluated with 0 result") do
|
26
|
+
negative_assertion { 0 }.run(Riot::Situation.new)
|
27
|
+
end.equals([:fail, "Expected non-true but got 0 instead", nil, nil])
|
28
|
+
|
29
|
+
helper(:big_exception) { @exception ||= Exception.new("blah") }
|
30
|
+
|
31
|
+
asserts("response when evaluation errors") do
|
32
|
+
exception = big_exception # :\
|
33
|
+
negative_assertion { raise exception }.run(Riot::Situation.new)
|
34
|
+
end.equals { [:error, big_exception] }
|
35
|
+
|
36
|
+
end # A negative assertion test
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
7
|
+
- 12
|
8
|
+
- 0
|
9
|
+
- pre
|
10
|
+
version: 0.12.0.pre
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Justin 'Gus' Knowlden
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-14 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -76,6 +77,8 @@ files:
|
|
76
77
|
- lib/riot/assertion_macros/same_elements.rb
|
77
78
|
- lib/riot/assertion_macros/size.rb
|
78
79
|
- lib/riot/context.rb
|
80
|
+
- lib/riot/context_helpers.rb
|
81
|
+
- lib/riot/context_options.rb
|
79
82
|
- lib/riot/message.rb
|
80
83
|
- lib/riot/middleware.rb
|
81
84
|
- lib/riot/reporter.rb
|
@@ -83,12 +86,12 @@ files:
|
|
83
86
|
- lib/riot/runnable.rb
|
84
87
|
- lib/riot/situation.rb
|
85
88
|
- riot.gemspec
|
89
|
+
- test.watchr
|
86
90
|
- test/benchmark/colorize.rb
|
87
91
|
- test/benchmark/message_concatenation.rb
|
88
92
|
- test/benchmark/riot_vs_minitest.rb
|
89
93
|
- test/benchmark/same_elements_vs_set.rb
|
90
94
|
- test/benchmark/simple_context_and_assertions.rb
|
91
|
-
- test/core/assertion_macro_test.rb
|
92
95
|
- test/core/assertion_macros/any_test.rb
|
93
96
|
- test/core/assertion_macros/assigns_test.rb
|
94
97
|
- test/core/assertion_macros/empty_test.rb
|
@@ -97,24 +100,33 @@ files:
|
|
97
100
|
- test/core/assertion_macros/exists_test.rb
|
98
101
|
- test/core/assertion_macros/includes_test.rb
|
99
102
|
- test/core/assertion_macros/kind_of_test.rb
|
100
|
-
- test/core/assertion_macros/
|
103
|
+
- test/core/assertion_macros/matches_test.rb
|
101
104
|
- test/core/assertion_macros/nil_test.rb
|
102
105
|
- test/core/assertion_macros/not_borat_test.rb
|
103
106
|
- test/core/assertion_macros/raises_test.rb
|
104
107
|
- test/core/assertion_macros/respond_to_test.rb
|
105
108
|
- test/core/assertion_macros/same_elements_test.rb
|
106
109
|
- test/core/assertion_macros/size_test.rb
|
107
|
-
- test/core/
|
108
|
-
- test/core/
|
109
|
-
- test/core/
|
110
|
-
- test/core/
|
111
|
-
- test/core/
|
112
|
-
- test/core/
|
110
|
+
- test/core/context/asserts_topic_test.rb
|
111
|
+
- test/core/context/context_test.rb
|
112
|
+
- test/core/context/context_with_options_test.rb
|
113
|
+
- test/core/context/deny_test.rb
|
114
|
+
- test/core/context/helper_test.rb
|
115
|
+
- test/core/context/hookup_test.rb
|
116
|
+
- test/core/context/nested_contexts_test.rb
|
117
|
+
- test/core/context/premium_setup_test.rb
|
118
|
+
- test/core/context/should_test.rb
|
119
|
+
- test/core/context/using_describe_in_a_test.rb
|
120
|
+
- test/core/middleware/chained_context_middleware_test.rb
|
121
|
+
- test/core/middleware/context_middleware_test.rb
|
113
122
|
- test/core/report_test.rb
|
114
|
-
- test/core/
|
115
|
-
- test/core/
|
116
|
-
- test/core/
|
117
|
-
- test/core/
|
123
|
+
- test/core/runnable/assertion_macro_test.rb
|
124
|
+
- test/core/runnable/assertion_test.rb
|
125
|
+
- test/core/runnable/message_test.rb
|
126
|
+
- test/core/runnable/negative_assertion_test.rb
|
127
|
+
- test/core/runnable/setup_test.rb
|
128
|
+
- test/core/runnable/situation_test.rb
|
129
|
+
- test/core/runnable/teardown_test.rb
|
118
130
|
- test/extensions/rrriot_test.rb
|
119
131
|
- test/teststrap.rb
|
120
132
|
has_rdoc: true
|
@@ -135,11 +147,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
147
|
version: "0"
|
136
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
149
|
requirements:
|
138
|
-
- - "
|
150
|
+
- - ">"
|
139
151
|
- !ruby/object:Gem::Version
|
140
152
|
segments:
|
141
|
-
-
|
142
|
-
|
153
|
+
- 1
|
154
|
+
- 3
|
155
|
+
- 1
|
156
|
+
version: 1.3.1
|
143
157
|
requirements: []
|
144
158
|
|
145
159
|
rubyforge_project:
|
@@ -153,7 +167,6 @@ test_files:
|
|
153
167
|
- test/benchmark/riot_vs_minitest.rb
|
154
168
|
- test/benchmark/same_elements_vs_set.rb
|
155
169
|
- test/benchmark/simple_context_and_assertions.rb
|
156
|
-
- test/core/assertion_macro_test.rb
|
157
170
|
- test/core/assertion_macros/any_test.rb
|
158
171
|
- test/core/assertion_macros/assigns_test.rb
|
159
172
|
- test/core/assertion_macros/empty_test.rb
|
@@ -162,23 +175,32 @@ test_files:
|
|
162
175
|
- test/core/assertion_macros/exists_test.rb
|
163
176
|
- test/core/assertion_macros/includes_test.rb
|
164
177
|
- test/core/assertion_macros/kind_of_test.rb
|
165
|
-
- test/core/assertion_macros/
|
178
|
+
- test/core/assertion_macros/matches_test.rb
|
166
179
|
- test/core/assertion_macros/nil_test.rb
|
167
180
|
- test/core/assertion_macros/not_borat_test.rb
|
168
181
|
- test/core/assertion_macros/raises_test.rb
|
169
182
|
- test/core/assertion_macros/respond_to_test.rb
|
170
183
|
- test/core/assertion_macros/same_elements_test.rb
|
171
184
|
- test/core/assertion_macros/size_test.rb
|
172
|
-
- test/core/
|
173
|
-
- test/core/
|
174
|
-
- test/core/
|
175
|
-
- test/core/
|
176
|
-
- test/core/
|
177
|
-
- test/core/
|
185
|
+
- test/core/context/asserts_topic_test.rb
|
186
|
+
- test/core/context/context_test.rb
|
187
|
+
- test/core/context/context_with_options_test.rb
|
188
|
+
- test/core/context/deny_test.rb
|
189
|
+
- test/core/context/helper_test.rb
|
190
|
+
- test/core/context/hookup_test.rb
|
191
|
+
- test/core/context/nested_contexts_test.rb
|
192
|
+
- test/core/context/premium_setup_test.rb
|
193
|
+
- test/core/context/should_test.rb
|
194
|
+
- test/core/context/using_describe_in_a_test.rb
|
195
|
+
- test/core/middleware/chained_context_middleware_test.rb
|
196
|
+
- test/core/middleware/context_middleware_test.rb
|
178
197
|
- test/core/report_test.rb
|
179
|
-
- test/core/
|
180
|
-
- test/core/
|
181
|
-
- test/core/
|
182
|
-
- test/core/
|
198
|
+
- test/core/runnable/assertion_macro_test.rb
|
199
|
+
- test/core/runnable/assertion_test.rb
|
200
|
+
- test/core/runnable/message_test.rb
|
201
|
+
- test/core/runnable/negative_assertion_test.rb
|
202
|
+
- test/core/runnable/setup_test.rb
|
203
|
+
- test/core/runnable/situation_test.rb
|
204
|
+
- test/core/runnable/teardown_test.rb
|
183
205
|
- test/extensions/rrriot_test.rb
|
184
206
|
- test/teststrap.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'teststrap'
|
2
|
-
|
3
|
-
context "A matching assertion macro" do
|
4
|
-
setup { Riot::Assertion.new("foo") { "abc" } }
|
5
|
-
|
6
|
-
assertion_test_passes("when expression matches actual", %Q{matches /abc/}) { topic.matches(/abc/) }
|
7
|
-
|
8
|
-
assertion_test_fails("when expression fails to match", "expected /abcd/ to match \"abc\"") do
|
9
|
-
topic.matches(/abcd/)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "with integer based topic" do
|
13
|
-
setup { Riot::Assertion.new("foo") { 42 } }
|
14
|
-
|
15
|
-
assertion_test_passes("actual value converted to string", %Q{matches /^42$/}) do
|
16
|
-
topic.matches(/^42$/)
|
17
|
-
end
|
18
|
-
|
19
|
-
assertion_test_fails("actual value converted to string", %Q{expected /^52$/ to match 42}) do
|
20
|
-
topic.matches(/^52$/)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end # A matching assertion macro
|
data/test/core/context_test.rb
DELETED
@@ -1,157 +0,0 @@
|
|
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 "Nesting a context" do
|
32
|
-
setup do
|
33
|
-
a_context = Riot::Context.new("foobar") do
|
34
|
-
asserts("passing") { true }
|
35
|
-
context "bazboo" do
|
36
|
-
asserts("passing") { true }
|
37
|
-
asserts("failing") { false }
|
38
|
-
asserts("erroring") { raise Exception }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
a_context.run(MockReporter.new)
|
42
|
-
end
|
43
|
-
|
44
|
-
asserts("one passed test") { topic.passes == 2 }
|
45
|
-
asserts("one failed test") { topic.failures == 1 }
|
46
|
-
asserts("one errored test") { topic.errors == 1 }
|
47
|
-
|
48
|
-
context "with setups" do
|
49
|
-
setup do
|
50
|
-
a_context = Riot::Context.new("foobar") do
|
51
|
-
setup { "foo" }
|
52
|
-
context "bazboo" do
|
53
|
-
setup { topic + "bar" }
|
54
|
-
asserts("passing") { topic == "foobar" }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
a_context.run(MockReporter.new)
|
58
|
-
end
|
59
|
-
|
60
|
-
asserts("parent setups are called") { topic.passes == 1 }
|
61
|
-
end # with setups
|
62
|
-
end # Nesting a context
|
63
|
-
|
64
|
-
context "Using should" do
|
65
|
-
setup do
|
66
|
-
a_context = Riot::Context.new("foobar") do
|
67
|
-
should("pass") { true }
|
68
|
-
should("fail") { false }
|
69
|
-
should("error") { raise Exception }
|
70
|
-
end
|
71
|
-
a_context.run(MockReporter.new)
|
72
|
-
end
|
73
|
-
|
74
|
-
asserts("one passed test") { topic.passes == 1 }
|
75
|
-
asserts("one failed test") { topic.failures == 1 }
|
76
|
-
asserts("one errored test") { topic.errors == 1 }
|
77
|
-
end # Using should
|
78
|
-
|
79
|
-
context "The asserts_topic shortcut" do
|
80
|
-
setup do
|
81
|
-
Riot::Context.new("foo") {}.asserts_topic
|
82
|
-
end
|
83
|
-
|
84
|
-
should("return an Assertion") { topic }.kind_of(Riot::Assertion)
|
85
|
-
|
86
|
-
should("return the actual topic as the result of evaling the assertion") do
|
87
|
-
(situation = Riot::Situation.new).instance_variable_set(:@_topic, "bar")
|
88
|
-
topic.equals("bar").run(situation)
|
89
|
-
end.equals([:pass, %Q{is equal to "bar"}])
|
90
|
-
|
91
|
-
asserts(:to_s).equals("asserts that it")
|
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
|
-
end # The asserts_topic shortcut
|
98
|
-
|
99
|
-
context "Using a hookup" do
|
100
|
-
setup do
|
101
|
-
situation = Riot::Situation.new
|
102
|
-
a_context = Riot::Context.new("foobar") {}
|
103
|
-
a_context.setup { "I'm a string" }.run(situation)
|
104
|
-
a_context.hookup { topic.size }.run(situation)
|
105
|
-
situation.topic
|
106
|
-
end
|
107
|
-
|
108
|
-
asserts_topic.equals("I'm a string")
|
109
|
-
end # Using a hookup
|
110
|
-
|
111
|
-
context "Making a new context" do
|
112
|
-
asserts("RootContext is used if nil parent is provided") do
|
113
|
-
Riot::Context.new("hello", nil) {}.parent
|
114
|
-
end.kind_of(Riot::RootContext)
|
115
|
-
end # Making a context
|
116
|
-
|
117
|
-
context "A context with a helper" do
|
118
|
-
setup { "foo" }
|
119
|
-
|
120
|
-
helper(:upcase) { topic.upcase }
|
121
|
-
helper(:append) {|str| topic + str }
|
122
|
-
|
123
|
-
asserts("executing the helper") { upcase }.equals("FOO")
|
124
|
-
asserts("calling a helper with an argument") { append("bar") }.equals("foobar")
|
125
|
-
end
|
126
|
-
|
127
|
-
context "A context with nested descriptions as classes" do
|
128
|
-
setup { Riot::Context.new(String) {}.context(Hash) {} }
|
129
|
-
asserts(:description).equals { Hash }
|
130
|
-
asserts(:detailed_description).equals("String Hash")
|
131
|
-
end
|
132
|
-
|
133
|
-
class SingletonArray
|
134
|
-
def self.<<(value); values << value; end
|
135
|
-
def self.values; @@values ||= []; end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "A context with premium_setup" do
|
139
|
-
setup do
|
140
|
-
Riot::Context.new("Foo") do
|
141
|
-
setup { SingletonArray << "baz" }
|
142
|
-
setup(true) { SingletonArray << "bar" }
|
143
|
-
setup(true) { SingletonArray << "foo" }
|
144
|
-
end.run(MockReporter.new)
|
145
|
-
end
|
146
|
-
|
147
|
-
asserts("order of setups ensures topic") { SingletonArray.values }.equals(%w[foo bar baz])
|
148
|
-
end
|
149
|
-
|
150
|
-
context "The describe alias" do
|
151
|
-
setup do
|
152
|
-
Riot::Context.new("Foo") {}
|
153
|
-
end
|
154
|
-
|
155
|
-
asserts("any ol' object") { Object.new }.responds_to(:describe)
|
156
|
-
asserts_topic.responds_to :describe
|
157
|
-
end # The describe alias
|