riot-fancydots 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in riot-fancydots.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ riot-fancydots (0.0.1)
5
+ riot
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ riot (0.12.0)
11
+ rr
12
+ term-ansicolor
13
+ rr (1.0.2)
14
+ term-ansicolor (1.0.5)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ riot
21
+ riot-fancydots!
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ task :test do
8
+ puts `ruby test/fancy_dot_reporter_test.rb`
9
+ end
10
+
11
+ task :fancytest do
12
+ puts `ruby test/test_run.rb`
13
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path('../riot-fancydots/fancy_dot_reporter.rb', __FILE__)
@@ -0,0 +1,47 @@
1
+ module Riot
2
+ class FancyDotReporter < IOReporter
3
+ def initialize(writer=STDOUT)
4
+ super
5
+ @details = []
6
+ end
7
+
8
+ def pass(description, message)
9
+ print green(".")
10
+ end
11
+
12
+ def fail(description, message, line, file)
13
+ print yellow("F")
14
+ @details << "#{yellow bold('FAILURE')} #{green dark(line_info(line, file))} #{test_detail(description, message)}".strip
15
+ end
16
+
17
+ def error(description, e)
18
+ print red("E")
19
+ location = filter_backtrace(e.backtrace).last
20
+ @details << "#{red bold('ERROR')} #{green dark(line_info(*location.split(':').reverse))} #{test_detail(description, white(dark(format_error e)))}"
21
+ end
22
+
23
+ def results(time_taken)
24
+ puts "\n#{@details.join("\n\n")}" unless @details.empty?
25
+ super
26
+ end
27
+ private
28
+ def test_detail(description, message)
29
+ "#{current_context.detailed_description} #{description}\n#{white bold("=>")} #{message}"
30
+ end
31
+ #need to make this protected
32
+ def filter_backtrace(backtrace)
33
+ cleansed = []
34
+ bad = true
35
+
36
+ # goal is to filter all the riot stuff/rake before the first non riot thing
37
+ backtrace.reverse_each do |bt|
38
+ # make sure we are still in the bad part
39
+ bad = (bt =~ /\/lib\/riot/ || bt =~ /rake_test_loader/) if bad
40
+
41
+ cleansed.unshift bt unless bad
42
+ end
43
+
44
+ cleansed.empty?? backtrace : cleansed
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ module Riot
2
+ module Fancydots
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "riot-fancydots/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "riot-fancydots"
7
+ s.version = Riot::Fancydots::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Matt Briggs"]
10
+ s.email = ["matt@mattbriggs.net"]
11
+ s.homepage = "http://rubygems.org/gems/riot-fancydots"
12
+ s.summary = %q{another take on the Riot::DotMatrixReporter}
13
+
14
+ s.add_dependency 'riot'
15
+ s.rubyforge_project = "riot-fancydots"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'riot'
3
+ require 'stringio'
4
+ require File.expand_path('../../lib/riot-fancydots', __FILE__)
5
+ Riot.dots
6
+
7
+ context "FancyDotReporter" do
8
+ setup do
9
+ @out = StringIO.new
10
+ Riot::FancyDotReporter.new(@out)
11
+ end
12
+
13
+ context "with a passing test" do
14
+ setup do
15
+ context = Riot::Context.new('whatever') do
16
+ asserts('true') { true }
17
+ end
18
+ context.run(topic)
19
+ @out.string
20
+ end
21
+ asserts_topic('puts a dot').matches('.')
22
+ end
23
+
24
+ context 'with a failing test' do
25
+ setup do
26
+ Riot::Context.new('whatever') do
27
+ asserts('nope!') { false }
28
+ end.run(topic)
29
+ topic.results(100)
30
+ @out.string
31
+ end
32
+
33
+ asserts_topic('puts an F').matches('F')
34
+ asserts_topic("puts the full context + assertion name").matches('whatever asserts nope!')
35
+ asserts_topic("puts the failure reason").matches(/Expected .* but got false instead/)
36
+ end
37
+
38
+ context 'with an error test' do
39
+ setup do
40
+ Riot::Context.new('whatever') do
41
+ asserts('bang') { raise "BOOM" }
42
+ end.run(topic)
43
+ topic.results(100)
44
+ @out.string
45
+ end
46
+
47
+ asserts_topic('puts an E').matches('E')
48
+ asserts_topic('puts the full context + assertion name').matches('whatever asserts bang')
49
+ asserts_topic('puts the exception message').matches('BOOM')
50
+ # <file path>:<one or more number><two newlines><anything till end of line><newline> is the last thing in the stack trace
51
+ asserts_topic('puts the filtered exception backtrace').matches(/#{__FILE__}:\d+\n\n.*$\n\z/)
52
+ end
53
+ end
data/test/test_run.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'riot'
3
+ require 'stringio'
4
+ require File.expand_path('../../lib/riot-fancydots', __FILE__)
5
+ Riot.reporter = Riot::FancyDotReporter
6
+
7
+ context 'FancyDotReporter' do
8
+ context 'pass' do
9
+ asserts('looks like') {true}
10
+ end
11
+ context 'fail' do
12
+ asserts('looks like') {'foo'}.matches('bar')
13
+ end
14
+ context 'error' do
15
+ asserts('looks like') {raise 'boom'}
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riot-fancydots
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Matt Briggs
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-02 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: riot
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description:
36
+ email:
37
+ - matt@mattbriggs.net
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - Gemfile.lock
48
+ - Rakefile
49
+ - lib/riot-fancydots.rb
50
+ - lib/riot-fancydots/fancy_dot_reporter.rb
51
+ - lib/riot-fancydots/version.rb
52
+ - riot-fancydots.gemspec
53
+ - test/fancy_dot_reporter_test.rb
54
+ - test/test_run.rb
55
+ has_rdoc: true
56
+ homepage: http://rubygems.org/gems/riot-fancydots
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project: riot-fancydots
85
+ rubygems_version: 1.3.7
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: another take on the Riot::DotMatrixReporter
89
+ test_files: []
90
+