riot 0.10.12 → 0.10.13.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 +20 -0
- data/README.markdown +12 -0
- data/VERSION +1 -1
- data/lib/riot/context.rb +8 -3
- data/lib/riot/reporter.rb +2 -2
- data/lib/riot/runnable.rb +1 -1
- data/lib/riot/situation.rb +5 -2
- data/riot.gemspec +3 -3
- data/test/core/assertion_test.rb +9 -9
- data/test/core/context_test.rb +12 -1
- data/test/core/report_test.rb +8 -8
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
*0.10.13.pre*
|
2
|
+
|
3
|
+
* Recording description as is. Providing #detailed_description for proper behavior [jaknowlden]
|
4
|
+
|
5
|
+
foo_context = context(Foo) {}
|
6
|
+
bar_context = foo_context.context(Bar) {}
|
7
|
+
bar_context.description
|
8
|
+
=> Bar
|
9
|
+
bar_context.detailed_description
|
10
|
+
=> "Foo Bar"
|
11
|
+
|
12
|
+
* No longer assuming topic when no block provided to an assertion. Instead, assuming block fails by default. Use `asserts_topic` only now. [jaknowlden]
|
13
|
+
|
14
|
+
context "foo" do
|
15
|
+
setup { "bar" }
|
16
|
+
asserts_topic.kind_of(String)
|
17
|
+
asserts("topic").kind_of(String) # Will fail since block returns `false`
|
18
|
+
asserts("topic").equals(false) # Will actually pass :)
|
19
|
+
end
|
20
|
+
|
1
21
|
*0.10.12*
|
2
22
|
|
3
23
|
* Recognizing file and line number of an assertion declaration on failure [vandrijevik]
|
data/README.markdown
CHANGED
@@ -69,6 +69,18 @@ give a Symbol as the first argument to `asserts` and leave out the block.
|
|
69
69
|
asserts(:first).equals("foo")
|
70
70
|
|
71
71
|
|
72
|
+
If you're like me, you like to write a bunch of failing tests for a context and then make
|
73
|
+
them pass. This can easily be done by simply calling an `asserts` or `should` command with
|
74
|
+
no block returning the actual value.
|
75
|
+
|
76
|
+
asserts("something special")
|
77
|
+
should("do something special")
|
78
|
+
|
79
|
+
Both of the above tests will fail. You can use this similar to a `should_eventually`. The
|
80
|
+
difference is that `should_eventually` is not technically a failure and will therefore be
|
81
|
+
ignored in time by (based on my experience). The above two blocks will actually show up as
|
82
|
+
failures and should hopefully drive you to making them pass.
|
83
|
+
|
72
84
|
### Reading Riot's output
|
73
85
|
|
74
86
|
Riot can output the test results in several ways, the default being *story reporting*. With
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.13.pre
|
data/lib/riot/context.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Riot
|
2
|
-
RootContext = Struct.new(:setups, :teardowns)
|
2
|
+
RootContext = Struct.new(:setups, :teardowns, :detailed_description)
|
3
3
|
|
4
4
|
module ContextHelpers
|
5
5
|
def assertion_class; Assertion; end
|
@@ -21,7 +21,7 @@ module Riot
|
|
21
21
|
attr_reader :parent
|
22
22
|
|
23
23
|
def initialize(description, parent=nil, &definition)
|
24
|
-
@parent = parent || RootContext.new([],[])
|
24
|
+
@parent = parent || RootContext.new([],[], "")
|
25
25
|
@description = description
|
26
26
|
@contexts, @helpers, @setups, @assertions, @teardowns = [], [], [], [], []
|
27
27
|
self.instance_eval(&definition)
|
@@ -129,6 +129,10 @@ module Riot
|
|
129
129
|
runnables.each { |runnable| reporter.report(runnable.to_s, runnable.run(situation)) }
|
130
130
|
end
|
131
131
|
|
132
|
+
def detailed_description
|
133
|
+
"#{parent.detailed_description} #{description}".strip
|
134
|
+
end
|
135
|
+
|
132
136
|
private
|
133
137
|
|
134
138
|
def runnables
|
@@ -138,7 +142,8 @@ module Riot
|
|
138
142
|
def run_sub_contexts(reporter) @contexts.each { |ctx| ctx.run(reporter) }; end
|
139
143
|
|
140
144
|
def new_context(description, klass, &definition)
|
141
|
-
(@contexts << klass.new("#{@description} #{description}", self, &definition)).last
|
145
|
+
# (@contexts << klass.new("#{@description} #{description}", self, &definition)).last
|
146
|
+
(@contexts << klass.new(description, self, &definition)).last
|
142
147
|
end
|
143
148
|
|
144
149
|
def new_assertion(scope, what, &definition)
|
data/lib/riot/reporter.rb
CHANGED
@@ -78,7 +78,7 @@ module Riot
|
|
78
78
|
class StoryReporter < IOReporter
|
79
79
|
def describe_context(context)
|
80
80
|
super
|
81
|
-
puts context.
|
81
|
+
puts context.detailed_description
|
82
82
|
end
|
83
83
|
def pass(description, message) puts " + " + green("#{description} #{message}".strip); end
|
84
84
|
|
@@ -122,7 +122,7 @@ module Riot
|
|
122
122
|
end
|
123
123
|
private
|
124
124
|
def test_detail(description, message)
|
125
|
-
"#{current_context.
|
125
|
+
"#{current_context.detailed_description} #{description} => #{message}"
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
data/lib/riot/runnable.rb
CHANGED
@@ -2,7 +2,7 @@ module Riot
|
|
2
2
|
class RunnableBlock
|
3
3
|
attr_reader :definition
|
4
4
|
def initialize(description, &definition)
|
5
|
-
@description, @definition = description, definition || lambda {
|
5
|
+
@description, @definition = description, definition || lambda { false }
|
6
6
|
end
|
7
7
|
|
8
8
|
def to_s; @description; end
|
data/lib/riot/situation.rb
CHANGED
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.10.
|
8
|
+
s.version = "0.10.13.pre"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin 'Gus' Knowlden"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-20}
|
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/core/assertion_test.rb
CHANGED
@@ -35,29 +35,29 @@ context "An assertion" do
|
|
35
35
|
context "with no block to provide the actual value" do
|
36
36
|
setup do
|
37
37
|
@situation = Riot::Situation.new
|
38
|
-
@situation.
|
38
|
+
@situation.instance_variable_set(:@_topic, "hello")
|
39
39
|
Riot::Assertion.new("test")
|
40
40
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end.equals([:
|
41
|
+
|
42
|
+
should("return a block that returns false") do
|
43
|
+
topic.run(@situation)
|
44
|
+
end.equals([:fail, "Expected non-false but got false instead", nil, nil])
|
45
45
|
end # with no block to provide the actual value
|
46
46
|
|
47
47
|
context "with block expectation" do
|
48
48
|
setup do
|
49
49
|
@situation = Riot::Situation.new
|
50
|
-
@situation.
|
51
|
-
Riot::Assertion.new("test")
|
50
|
+
@situation.instance_variable_set(:@_topic, "hello")
|
51
|
+
Riot::Assertion.new("test") { topic }
|
52
52
|
end
|
53
53
|
|
54
54
|
should("use block returning topic as default") do
|
55
55
|
topic.equals { "hello" }
|
56
|
-
|
56
|
+
topic.run(@situation)
|
57
57
|
end.equals([:pass, %Q{is equal to "hello"}])
|
58
58
|
|
59
59
|
asserts("block expectation has access to the situation items") do
|
60
|
-
topic.equals { @
|
60
|
+
topic.equals { @_topic }
|
61
61
|
topic.run(@situation)
|
62
62
|
end.equals([:pass, %Q{is equal to "hello"}])
|
63
63
|
end # with block expectation
|
data/test/core/context_test.rb
CHANGED
@@ -84,7 +84,7 @@ context "The asserts_topic shortcut" do
|
|
84
84
|
should("return an Assertion") { topic }.kind_of(Riot::Assertion)
|
85
85
|
|
86
86
|
should("return the actual topic as the result of evaling the assertion") do
|
87
|
-
(situation = Riot::Situation.new).
|
87
|
+
(situation = Riot::Situation.new).instance_variable_set(:@_topic, "bar")
|
88
88
|
topic.equals("bar").run(situation)
|
89
89
|
end.equals([:pass, %Q{is equal to "bar"}])
|
90
90
|
|
@@ -123,3 +123,14 @@ context "A context with a helper" do
|
|
123
123
|
asserts("executing the helper") { upcase }.equals("FOO")
|
124
124
|
asserts("calling a helper with an argument") { append("bar") }.equals("foobar")
|
125
125
|
end
|
126
|
+
|
127
|
+
|
128
|
+
context "A context with a description" do
|
129
|
+
Foo, Bar = Class.new {}, Class.new {}
|
130
|
+
setup do
|
131
|
+
Riot::Context.new(Foo) {}.context(Bar) {}
|
132
|
+
end
|
133
|
+
|
134
|
+
asserts(:description).equals(Bar)
|
135
|
+
asserts(:detailed_description).equals("Foo Bar")
|
136
|
+
end
|
data/test/core/report_test.rb
CHANGED
@@ -119,7 +119,7 @@ context "DotMatrixReporter" do
|
|
119
119
|
context.run(topic)
|
120
120
|
@out.string
|
121
121
|
end
|
122
|
-
|
122
|
+
asserts_topic('puts a dot').matches('.')
|
123
123
|
end
|
124
124
|
|
125
125
|
context 'with a failing test' do
|
@@ -131,9 +131,9 @@ context "DotMatrixReporter" do
|
|
131
131
|
@out.string
|
132
132
|
end
|
133
133
|
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
asserts_topic('puts an F').matches('F')
|
135
|
+
asserts_topic("puts the full context + assertion name").matches('whatever asserts nope!')
|
136
|
+
asserts_topic("puts the failure reason").matches(/Expected .* but got false instead/)
|
137
137
|
end
|
138
138
|
|
139
139
|
context 'with an error test' do
|
@@ -145,9 +145,9 @@ context "DotMatrixReporter" do
|
|
145
145
|
@out.string
|
146
146
|
end
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
asserts_topic('puts an E').matches('E')
|
149
|
+
asserts_topic('puts the full context + assertion name').matches('whatever asserts bang')
|
150
|
+
asserts_topic('puts the exception message').matches('BOOM')
|
151
|
+
asserts_topic('puts the exception backtrace').matches(__FILE__)
|
152
152
|
end
|
153
153
|
end
|
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.13.pre
|
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: 2010-02-
|
12
|
+
date: 2010-02-20 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -120,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version:
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 1.3.1
|
126
126
|
version:
|
127
127
|
requirements: []
|
128
128
|
|