test/report_test.rb in riot-0.10.4 vs test/report_test.rb in riot-0.10.5
- old
+ new
@@ -49,34 +49,79 @@
end
end # A reporter
require 'stringio'
context "StoryReporter" do
- setup {
+ setup do
@out = StringIO.new
Riot::StoryReporter.new(@out)
- }
+ emd
context 'reporting on an empty context' do
setup do
context = Riot::Context.new('empty context') do
- context "a nested empty context" do
- end
+ context("a nested empty context") {}
end
context.run(topic)
end
should("not output context name") { @out.string }.empty
end
-
+
context "reporting on a non-empty context" do
setup do
context = Riot::Context.new('supercontext') do
asserts("truth") { true }
end
context.run(topic)
end
-
+
should('output context name') { @out.string }.matches(/supercontext/)
should('output name of passed assertion') { @out.string }.matches(/truth/)
end
+end
+context "DotMatrixReporter" do
+ setup do
+ @out = StringIO.new
+ Riot::DotMatrixReporter.new(@out)
+ end
+
+ context "with a passing test" do
+ setup do
+ context = Riot::Context.new('whatever') do
+ asserts('true') { true }
+ end
+ context.run(topic)
+ @out.string
+ end
+ asserts('puts a dot').matches('.')
+ end
+
+ context 'with a failing test' do
+ setup do
+ Riot::Context.new('whatever') do
+ asserts('nope!') { false }
+ end.run(topic)
+ topic.results(100)
+ @out.string
+ end
+
+ asserts('puts an F').matches('F')
+ asserts("puts the full context + assertion name").matches('whatever asserts nope!')
+ asserts("puts the failure reason").matches(/Expected .* but got false instead/)
+ end
+
+ context 'with an error test' do
+ setup do
+ Riot::Context.new('whatever') do
+ asserts('bang') { raise "BOOM" }
+ end.run(topic)
+ topic.results(100)
+ @out.string
+ end
+
+ asserts('puts an E').matches('E')
+ asserts('puts the full context + assertion name').matches('whatever asserts bang')
+ asserts('puts the exception message').matches('BOOM')
+ asserts('puts the exception backtrace').matches(__FILE__)
+ end
end