riot 0.9.8 → 0.9.9
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/README.markdown +20 -1
- data/VERSION +1 -1
- data/lib/riot/context.rb +1 -0
- data/riot.gemspec +2 -2
- data/test/context_test.rb +4 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -72,8 +72,27 @@ Notice that you do not define a class anywhere. That would be the entire content
|
|
72
72
|
|
73
73
|
Sometimes it's more clear to say "this **should** be that" and sometimes it's better to say "**asserts** this is that". I promise you that Riot will get no more redundant than this, but also that besides speed, Riot will aim at being expressive with a minimal amount of syntax.
|
74
74
|
|
75
|
+
The other important thing to note in the examples above is the use of the `topic`. Calling `topic` within any assertion will actually return the value of whatever was evaluated and returned from calling setup in the given context. In the examples above, `User.new` was returned, and is therefor accessible as the `topic`.
|
76
|
+
|
75
77
|
I'm going to use `asserts` for the rest of this introduction, but you should know that you can replace any instance of `asserts` with `should` and nothing would change.
|
76
78
|
|
79
|
+
#### Example: Shortcut - Asserting the topic itself
|
80
|
+
|
81
|
+
Over the course of developing Riot it became somewhat obvious to some of us that we were creating assertions that returned the `topic` just so we could assert things about the topic itself. For instance, were doing this:
|
82
|
+
|
83
|
+
context "a billionaire" do
|
84
|
+
setup { MoneyMaker.build(:billionaire) }
|
85
|
+
|
86
|
+
should("be a Billionaire") { topic }.kind_of(Billionaire)
|
87
|
+
end
|
88
|
+
|
89
|
+
This is awfully redundant - not to mention, contrived. So, we wrote a shortcut to generate an assertion that returns topic. This means we can now do this:
|
90
|
+
|
91
|
+
context "a billionaire" do
|
92
|
+
setup { MoneyMaker.build(:billionaire) }
|
93
|
+
topic.kind_of(Billionaire)
|
94
|
+
end
|
95
|
+
|
77
96
|
#### Example: Equality
|
78
97
|
|
79
98
|
One of the most common assertions you will (or do already) utilize is that of equality; is this equal to that? Riot supports this in a slightly different manner than most other frameworks. With Riot, you add the expectation to the assertion itself.
|
@@ -344,7 +363,7 @@ For instance, let's say you wanted to add a macro for verifying that the result
|
|
344
363
|
module Custom
|
345
364
|
module AssertionMacros
|
346
365
|
def kind_of(expected_class)
|
347
|
-
actual.kind_of?(expected) ||
|
366
|
+
actual.kind_of?(expected) || fail("expected kind of #{expected}, not #{actual.inspect}")
|
348
367
|
end
|
349
368
|
end # AssertionMacros
|
350
369
|
end # Custom
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.9
|
data/lib/riot/context.rb
CHANGED
@@ -32,6 +32,7 @@ module Riot
|
|
32
32
|
def context(description, &block) Context.new(description, @reporter, self, &block); end
|
33
33
|
def asserts(what, &block) add_assertion("asserts #{what}", &block); end
|
34
34
|
def should(what, &block) add_assertion("should #{what}", &block); end
|
35
|
+
def topic; asserts("topic") { topic }; end
|
35
36
|
private
|
36
37
|
def add_assertion(what, &block)
|
37
38
|
(assertions << Assertion.new("#{to_s} #{what}", @situation, &block)).last
|
data/riot.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{riot}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.9"
|
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"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-15}
|
13
13
|
s.description = %q{An extremely fast, expressive, and context-driven unit-testing framework. A replacement for all other testing frameworks. Protest the slow test.}
|
14
14
|
s.email = %q{gus@gusg.us}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/context_test.rb
CHANGED
@@ -25,6 +25,10 @@ context "any context" do
|
|
25
25
|
asserts "topic becomes available to test as result of setup" do
|
26
26
|
@context.should("bar") { topic }.actual
|
27
27
|
end.equals("foo")
|
28
|
+
|
29
|
+
asserts "calling topic in context will return assertion that returns topic as the actual" do
|
30
|
+
@context.topic.actual
|
31
|
+
end.equals("foo")
|
28
32
|
end # when running setup
|
29
33
|
end # any context
|
30
34
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin 'Gus' Knowlden
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-15 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|