fuubar 0.0.1

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/.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 fuubar.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fuubar (0.0.1)
5
+ progressbar (~> 0.9)
6
+ rspec (~> 2.0)
7
+ rspec-instafail (~> 0.1)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ diff-lcs (1.1.2)
13
+ progressbar (0.9.0)
14
+ rspec (2.1.0)
15
+ rspec-core (~> 2.1.0)
16
+ rspec-expectations (~> 2.1.0)
17
+ rspec-mocks (~> 2.1.0)
18
+ rspec-core (2.1.0)
19
+ rspec-expectations (2.1.0)
20
+ diff-lcs (~> 1.1.2)
21
+ rspec-instafail (0.1.2)
22
+ rspec-mocks (2.1.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ fuubar!
29
+ progressbar (~> 0.9)
30
+ rspec (~> 2.0)
31
+ rspec-instafail (~> 0.1)
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ Copyright 2010 Jeff Kreeftmeijer.
2
+ You may use this work without restrictions, as long as this notice is included.
3
+ The work is provided "as is" without warranty of any kind, neither express nor implied.
data/README.textile ADDED
@@ -0,0 +1,19 @@
1
+ h1. Fuubar
2
+
3
+ Fuubar is an instafailing "RSpec":http://github.com/rspec formatter that uses a progress bar instead of a string of letters and dots as feedback. Here's "a video of Fuubar in action":http://vimeo.com/16845253.
4
+
5
+ h2. Installation
6
+
7
+ Installing Fuubar is easy. Just put it in your @Gemfile@ and run your specs like this from now on:
8
+
9
+ bc. $ rspec --require fuubar --format Fuubar --color spec
10
+
11
+ If you want to use Fuubar as your default formatter, simply put the options in your @.rspec@ file:
12
+
13
+ bc. --require fuubar
14
+ --format Fuubar
15
+ --color
16
+
17
+ h2. Contributing
18
+
19
+ Found an issue? Have a great idea? Want to help? Great! Create an issue "issue":http://github.com/jeffkreeftmeijer/fuubar/issues for it, "ask":http://github.com/inbox/new/jeffkreeftmeijer, or even better; fork the project and fix the problem yourself. Pull requests are always welcome. :)
data/fuubar.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "fuubar"
5
+ s.version = '0.0.1'
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["Nicholas Evans", "Jeff Kreeftmeijer"]
8
+ s.email = ["jeff@kreeftmeijer.nl"]
9
+ s.homepage = "http://rubygems.org/gems/fuubar"
10
+ s.summary = %q{the instafailing RSpec progress bar formatter}
11
+ s.description = %q{the instafailing RSpec progress bar formatter}
12
+
13
+ s.rubyforge_project = "fuubar"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency('rspec', ["~> 2.0"])
21
+ s.add_dependency('progressbar', ["~> 0.9"])
22
+ s.add_dependency('rspec-instafail', ["~> 0.1"])
23
+ end
data/lib/fuubar.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'rspec/core/formatters/base_text_formatter'
2
+ require 'progressbar'
3
+ require 'rspec/instafail'
4
+
5
+ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
6
+
7
+ attr_reader :example_count, :finished_count
8
+ COLORS = { :green => "\e[32m", :yellow => "\e[33m", :red => "\e[31m" }
9
+
10
+ def start(example_count)
11
+ @example_count = example_count
12
+ @finished_count = 0
13
+ @progress_bar = ProgressBar.new("#{example_count} examples", example_count, output)
14
+ end
15
+
16
+ def increment
17
+ with_color do
18
+ @finished_count += 1
19
+ @progress_bar.inc
20
+ @progress_bar.instance_variable_set("@title", "#{finished_count}/#{example_count}")
21
+ end
22
+ end
23
+
24
+ def example_passed(example)
25
+ super
26
+ increment
27
+ end
28
+
29
+ def example_pending(example)
30
+ super
31
+ @state = :yellow unless @state == :red
32
+ increment
33
+ end
34
+
35
+ def example_failed(example)
36
+ super
37
+ @state = :red
38
+
39
+ output.print "\e[K"
40
+ instafail.example_failed(example)
41
+ output.puts
42
+
43
+ increment
44
+ end
45
+
46
+ def start_dump
47
+ with_color { @progress_bar.finish }
48
+ end
49
+
50
+ def dump_failures
51
+ # don't!
52
+ end
53
+
54
+ def instafail
55
+ @instafail ||= RSpec::Instafail.new(output)
56
+ end
57
+
58
+ def with_color
59
+ output.print COLORS[state] if color_enabled?
60
+ yield
61
+ output.print "\e[0m"
62
+ end
63
+
64
+ def state
65
+ @state ||= :green
66
+ end
67
+
68
+ end
@@ -0,0 +1,140 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fuubar do
4
+
5
+ before do
6
+ @output = StringIO.new
7
+ @formatter = Fuubar.new(@output)
8
+ @formatter.start(2)
9
+ @progress_bar = @formatter.instance_variable_get(:@progress_bar)
10
+ @example = RSpec::Core::ExampleGroup.describe.example
11
+ end
12
+
13
+ describe 'start' do
14
+
15
+ it 'should create a new ProgressBar' do
16
+ @progress_bar.should be_instance_of ProgressBar
17
+ end
18
+
19
+ it 'should set the title' do
20
+ @progress_bar.instance_variable_get(:@title).should == '2 examples'
21
+ end
22
+
23
+ it 'should set the total amount of specs' do
24
+ @progress_bar.instance_variable_get(:@total).should == 2
25
+ end
26
+
27
+ it 'should set the output' do
28
+ @progress_bar.instance_variable_get(:@out).should == @formatter.output
29
+ end
30
+
31
+ it 'should set the example_count' do
32
+ @formatter.instance_variable_get(:@example_count).should == 2
33
+ end
34
+
35
+ it 'should set the finished_count to 0' do
36
+ @formatter.instance_variable_get(:@finished_count).should == 0
37
+ end
38
+ end
39
+ describe 'passed, pending and failed' do
40
+ before do
41
+ @formatter.stub!(:increment)
42
+ end
43
+
44
+ describe 'example_passed' do
45
+
46
+ it 'should call the increment method' do
47
+ @formatter.should_receive :increment
48
+ @formatter.example_passed(@example)
49
+ end
50
+
51
+ end
52
+
53
+ describe 'example_pending' do
54
+
55
+ it 'should call the increment method' do
56
+ @formatter.should_receive :increment
57
+ @formatter.example_pending(@example)
58
+ end
59
+
60
+ it 'should set the state to :yellow' do
61
+ @formatter.example_pending(@example)
62
+ @formatter.state.should == :yellow
63
+ end
64
+
65
+ it 'should not set the state to :yellow when it is :red already' do
66
+ @formatter.instance_variable_set(:@state, :red)
67
+ @formatter.example_pending(@example)
68
+ @formatter.state.should == :red
69
+ end
70
+
71
+ end
72
+
73
+ describe 'example_failed' do
74
+
75
+ before do
76
+ @formatter.instafail.stub!(:example_failed)
77
+ end
78
+
79
+ it 'should call the increment method' do
80
+ @formatter.should_receive :increment
81
+ @formatter.example_failed(@example)
82
+ end
83
+
84
+ it 'should call instafail.example_failed' do
85
+ @formatter.instafail.should_receive(:example_failed).with(@example)
86
+ @formatter.example_failed(@example)
87
+ end
88
+
89
+ it 'should set the state to :red' do
90
+ @formatter.example_failed(@example)
91
+ @formatter.state.should == :red
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ describe 'increment' do
99
+
100
+ it 'should increment the progress bar' do
101
+ @progress_bar.should_receive(:inc)
102
+ @formatter.increment
103
+ end
104
+
105
+ it 'should change the progress bar title' do
106
+ @formatter.stub!(:finished_count).and_return(1)
107
+ @formatter.stub!(:example_count).and_return(2)
108
+ @formatter.increment
109
+ @progress_bar.instance_variable_get(:@title).should == '1/2'
110
+ end
111
+
112
+ it 'should increment the finished_count' do
113
+ lambda { @formatter.increment }.should change(@formatter, :finished_count).by(1)
114
+ end
115
+
116
+ end
117
+
118
+ describe 'instafail' do
119
+
120
+ it 'should be an instance of RSpec::Instafail' do
121
+ @formatter.instafail.should be_instance_of(RSpec::Instafail)
122
+ end
123
+
124
+ end
125
+
126
+ describe 'start_dump' do
127
+ it 'should finish the progress bar' do
128
+ @progress_bar.should_receive(:finish)
129
+ @formatter.start_dump
130
+ end
131
+ end
132
+
133
+ describe 'state' do
134
+ it 'should be :green by default' do
135
+ @formatter.state.should == :green
136
+ end
137
+
138
+ end
139
+
140
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'fuubar'
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuubar
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
+ - Nicholas Evans
14
+ - Jeff Kreeftmeijer
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-11-15 00:00:00 +01:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rspec
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 2
33
+ - 0
34
+ version: "2.0"
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: progressbar
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 25
46
+ segments:
47
+ - 0
48
+ - 9
49
+ version: "0.9"
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rspec-instafail
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 9
61
+ segments:
62
+ - 0
63
+ - 1
64
+ version: "0.1"
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ description: the instafailing RSpec progress bar formatter
68
+ email:
69
+ - jeff@kreeftmeijer.nl
70
+ executables: []
71
+
72
+ extensions: []
73
+
74
+ extra_rdoc_files: []
75
+
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE
81
+ - README.textile
82
+ - fuubar.gemspec
83
+ - lib/fuubar.rb
84
+ - spec/fuubar_spec.rb
85
+ - spec/spec_helper.rb
86
+ has_rdoc: true
87
+ homepage: http://rubygems.org/gems/fuubar
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options: []
92
+
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project: fuubar
116
+ rubygems_version: 1.3.7
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: the instafailing RSpec progress bar formatter
120
+ test_files:
121
+ - spec/fuubar_spec.rb
122
+ - spec/spec_helper.rb