fuubar-legacy 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,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
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/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,26 @@
1
+ h1. Fuubar "!http://stillmaintained.com/jeffkreeftmeijer/fuubar.png!":http://stillmaintained.com/jeffkreeftmeijer/fuubar
2
+
3
+ Fuubar is an instafailing "RSpec":https://github.com/dchelimsky/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
+ You're on the legacy branch that supports RSpec ~> 1.3 right now. There's an "RSpec 2.x branch":https://github.com/jeffkreeftmeijer/fuubar too. :)
6
+
7
+ h2. Installation
8
+
9
+ Installing Fuubar is easy. Just put it in your @Gemfile@:
10
+
11
+ bc. gem 'fuubar', :git => 'git://github.com/jeffkreeftmeijer/fuubar.git', :branch => 'legacy'
12
+
13
+ And run your specs like this from now on:
14
+
15
+ bc. $ spec --format Fuubar --color spec
16
+
17
+ If you want to use Fuubar as your default formatter, simply put the options in your @spec/spec.opts@ file:
18
+
19
+ bc. --format Fuubar
20
+ --color
21
+
22
+ h2. Contributing
23
+
24
+ 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. :)
25
+
26
+ Yay for "Fuubar's awesome contributors":https://github.com/jeffkreeftmeijer/fuubar/wiki/Contributors!
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+
5
+ require 'spec/rake/spectask'
6
+ Spec::Rake::SpecTask.new
7
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "fuubar-legacy"
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 = "https://github.com/jeffkreeftmeijer/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_runtime_dependency('rspec', ["~> 1.3"])
21
+ s.add_runtime_dependency('chalofa_ruby-progressbar', ["~> 0.0.9"])
22
+ s.add_runtime_dependency('rspec-instafail', ["~> 0.1.4"])
23
+ s.add_development_dependency('rake')
24
+ end
data/lib/fuubar.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'spec/runner/formatter/base_formatter'
2
+ require 'progressbar'
3
+ require 'rspec/instafail'
4
+
5
+ class Fuubar < Spec::Runner::Formatter::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
+ @progress_bar.bar_mark = '='
15
+ end
16
+
17
+ def increment
18
+ with_color do
19
+ @finished_count += 1
20
+ @progress_bar.instance_variable_set("@title", " #{finished_count}/#{example_count}")
21
+ @progress_bar.inc
22
+ end
23
+ end
24
+
25
+ def example_passed(example)
26
+ super
27
+ increment
28
+ end
29
+
30
+ def example_pending(example, message)
31
+ super
32
+ @state = :yellow unless @state == :red
33
+ increment
34
+ end
35
+
36
+ def example_failed(example, counter, message)
37
+ super
38
+ @state = :red
39
+
40
+ output.print "\e[K"
41
+ instafail.example_failed(example, counter, message)
42
+ output.puts
43
+
44
+ increment
45
+ end
46
+
47
+ def start_dump
48
+ with_color { @progress_bar.finish }
49
+ end
50
+
51
+ def dump_failures
52
+ # don't!
53
+ end
54
+
55
+ def instafail
56
+ @instafail ||= RSpec::Instafail.new(@options, output)
57
+ #since instafail won't be able to get the current example_group it must be
58
+ #updated every time
59
+ @instafail.example_group_started(example_group)
60
+ @instafail
61
+ end
62
+
63
+ def with_color
64
+ output.print COLORS[state] if colour?
65
+ yield
66
+ output.print "\e[0m"
67
+ end
68
+
69
+ def state
70
+ @state ||= :green
71
+ end
72
+
73
+ end
@@ -0,0 +1,163 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe Fuubar do
5
+
6
+ before do
7
+ @output = StringIO.new
8
+ @options = Spec::Runner::Options.new(@output, @output)
9
+ @formatter = Fuubar.new(@options, @output)
10
+ @formatter.start(2)
11
+ @progress_bar = @formatter.instance_variable_get(:@progress_bar)
12
+ @example_group = Spec::Example::ExampleGroup.describe(nil)
13
+ @formatter.example_group_started(@example_group)
14
+ @example = @example = @example_group.example
15
+ end
16
+
17
+ describe 'start' do
18
+
19
+ it 'should create a new ProgressBar' do
20
+ @progress_bar.should be_instance_of ProgressBar
21
+ end
22
+
23
+ it 'should set the title' do
24
+ @progress_bar.instance_variable_get(:@title).should == ' 2 examples'
25
+ end
26
+
27
+ it 'should set the total amount of specs' do
28
+ @progress_bar.instance_variable_get(:@total).should == 2
29
+ end
30
+
31
+ it 'should set the output' do
32
+ @progress_bar.instance_variable_get(:@out).should == @formatter.output
33
+ end
34
+
35
+ it 'should set the example_count' do
36
+ @formatter.instance_variable_get(:@example_count).should == 2
37
+ end
38
+
39
+ it 'should set the finished_count to 0' do
40
+ @formatter.instance_variable_get(:@finished_count).should == 0
41
+ end
42
+
43
+ it 'should set the bar mark to =' do
44
+ @progress_bar.instance_variable_get(:@bar_mark).should == '='
45
+ end
46
+
47
+ end
48
+
49
+ describe 'passed, pending and failed' do
50
+
51
+ before do
52
+ @formatter.stub!(:increment)
53
+ end
54
+
55
+ describe 'example_passed' do
56
+
57
+ it 'should call the increment method' do
58
+ @formatter.should_receive :increment
59
+ @formatter.example_passed(@example)
60
+ end
61
+
62
+ end
63
+
64
+ describe 'example_pending' do
65
+
66
+ it 'should call the increment method' do
67
+ @formatter.should_receive :increment
68
+ @formatter.example_pending(@example, 'message')
69
+ end
70
+
71
+ it 'should set the state to :yellow' do
72
+ @formatter.example_pending(@example, 'message')
73
+ @formatter.state.should == :yellow
74
+ end
75
+
76
+ it 'should not set the state to :yellow when it is :red already' do
77
+ @formatter.instance_variable_set(:@state, :red)
78
+ @formatter.example_pending(@example, 'message')
79
+ @formatter.state.should == :red
80
+ end
81
+
82
+ end
83
+
84
+ describe 'example_failed' do
85
+
86
+ before do
87
+ @formatter.instafail.stub!(:example_failed)
88
+ end
89
+
90
+ it 'should call the increment method' do
91
+ @formatter.should_receive :increment
92
+ @formatter.example_failed(@example, 1, 'message')
93
+ end
94
+
95
+ it 'should call instafail.example_failed' do
96
+ @formatter.instafail.should_receive(:example_failed).with(@example, 1, 'message')
97
+ @formatter.example_failed(@example, 1, 'message')
98
+ end
99
+
100
+ it 'should set the state to :red' do
101
+ @formatter.example_failed(@example, 1, 'message')
102
+ @formatter.state.should == :red
103
+ end
104
+
105
+ end
106
+
107
+ end
108
+
109
+ describe 'increment' do
110
+
111
+ it 'should increment the progress bar' do
112
+ @progress_bar.should_receive(:inc)
113
+ @formatter.increment
114
+ end
115
+
116
+ it 'should change the progress bar title' do
117
+ @formatter.stub!(:finished_count).and_return(1)
118
+ @formatter.stub!(:example_count).and_return(2)
119
+ @formatter.increment
120
+ @progress_bar.instance_variable_get(:@title).should == ' 1/2'
121
+ end
122
+
123
+ it 'should increment the finished_count' do
124
+ lambda { @formatter.increment }.should change(@formatter, :finished_count).by(1)
125
+ end
126
+
127
+ it 'should increment the progress bar before updating the title' do
128
+ @progress_bar.should_receive(:instance_variable_set).ordered
129
+ @progress_bar.should_receive(:inc).ordered
130
+ @formatter.increment
131
+ end
132
+
133
+ end
134
+
135
+ describe 'instafail' do
136
+
137
+ it 'should be an instance of RSpec::Instafail' do
138
+ @formatter.instafail.should be_instance_of(RSpec::Instafail)
139
+ end
140
+
141
+ it 'should have same formatter options as fuubar' do
142
+ @formatter.instafail.instance_variable_get(:@options).should == @options
143
+ end
144
+ end
145
+
146
+ describe 'start_dump' do
147
+
148
+ it 'should finish the progress bar' do
149
+ @progress_bar.should_receive(:finish)
150
+ @formatter.start_dump
151
+ end
152
+
153
+ end
154
+
155
+ describe 'state' do
156
+
157
+ it 'should be :green by default' do
158
+ @formatter.state.should == :green
159
+ end
160
+
161
+ end
162
+
163
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format Fuubar
@@ -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,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuubar-legacy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
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: 2012-03-19 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ hash: 9
28
+ segments:
29
+ - 1
30
+ - 3
31
+ version: "1.3"
32
+ prerelease: false
33
+ requirement: *id001
34
+ type: :runtime
35
+ name: rspec
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 13
43
+ segments:
44
+ - 0
45
+ - 0
46
+ - 9
47
+ version: 0.0.9
48
+ prerelease: false
49
+ requirement: *id002
50
+ type: :runtime
51
+ name: chalofa_ruby-progressbar
52
+ - !ruby/object:Gem::Dependency
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 19
59
+ segments:
60
+ - 0
61
+ - 1
62
+ - 4
63
+ version: 0.1.4
64
+ prerelease: false
65
+ requirement: *id003
66
+ type: :runtime
67
+ name: rspec-instafail
68
+ - !ruby/object:Gem::Dependency
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ prerelease: false
79
+ requirement: *id004
80
+ type: :development
81
+ name: rake
82
+ description: the instafailing RSpec progress bar formatter
83
+ email:
84
+ - jeff@kreeftmeijer.nl
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files: []
90
+
91
+ files:
92
+ - .gitignore
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.textile
96
+ - Rakefile
97
+ - fuubar-legacy.gemspec
98
+ - lib/fuubar.rb
99
+ - spec/fuubar_spec.rb
100
+ - spec/spec.opts
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/jeffkreeftmeijer/fuubar
103
+ licenses: []
104
+
105
+ post_install_message:
106
+ rdoc_options: []
107
+
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project: fuubar
131
+ rubygems_version: 1.8.11
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: the instafailing RSpec progress bar formatter
135
+ test_files:
136
+ - spec/fuubar_spec.rb
137
+ - spec/spec.opts
138
+ - spec/spec_helper.rb