rspec-pride 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,29 @@
1
+ # Rspec-pride
2
+
3
+ Take pride in your test output
4
+
5
+ Mimics the functionality of minitest/pride for RSpec2
6
+
7
+ [![Build Status](http://travis-ci.org/ferrous26/rspec-pride.png)](http://travis-ci.org/ferrous26/rspec-pride)
8
+
9
+ ## How to use Rspec-pride
10
+
11
+ To use rspec-pride, you need to call `rspec` with the following options:
12
+
13
+ --require rspec/pride --format Pride
14
+
15
+ Or put those in your `.rspec` file.
16
+
17
+ ## Contributing to Rspec-pride
18
+
19
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
20
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
21
+ * Fork the project
22
+ * Start a feature/bugfix branch
23
+ * Commit and push until you are happy with your contribution
24
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
25
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
26
+
27
+ ## Copyright
28
+
29
+ Copyright (c) 2011 Mark Rada. See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ task :default => :test
5
+ task :test => :spec
6
+
7
+ if RUBY_ENGINE == 'macruby'
8
+
9
+ require 'rake/compiletask'
10
+ Rake::CompileTask.new do |t|
11
+ t.files = FileList["lib/**/*.rb"]
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Clean MacRuby binaries'
16
+ task :clean do
17
+ FileList["lib/**/*.rbo"].each do |bin|
18
+ puts "rm #{bin}"
19
+ rm bin
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new(:spec) do |spec|
28
+ spec.skip_bundler = true
29
+ spec.pattern = FileList['spec/**/*_spec.rb']
30
+ end
31
+
32
+
33
+ require 'rubygems/builder'
34
+ require 'rubygems/installer'
35
+ spec = Gem::Specification.load('rspec-pride.gemspec')
36
+
37
+ desc 'Build the gem'
38
+ task :build do Gem::Builder.new(spec).build end
39
+
40
+ desc 'Build the gem and install it'
41
+ task :install => :build do Gem::Installer.new(spec.file_name).install end
@@ -0,0 +1,47 @@
1
+ require 'rspec/core/formatters/base_text_formatter'
2
+
3
+ class Pride < RSpec::Core::Formatters::BaseTextFormatter
4
+
5
+ # stolen from minitest/pride
6
+ COLORS = (31..36).to_a
7
+ COLORS_SIZE = COLORS.size
8
+ CHARS = ['*']
9
+ CHARS_SIZE = CHARS.size
10
+
11
+ def initialize io
12
+ super
13
+ @colors = COLORS
14
+ @chars = CHARS
15
+ @index = 0
16
+ end
17
+
18
+ def example_passed proxy
19
+ super
20
+ output.print rainbow( @chars[@index % CHARS_SIZE] )
21
+ end
22
+
23
+ def example_failed proxy
24
+ super
25
+ output.print red( 'F' )
26
+ end
27
+
28
+ def example_pending proxy
29
+ super
30
+ output.print bold_white( 'P' )
31
+ end
32
+
33
+
34
+ private
35
+
36
+ def bold_white string; "\e[40m\e[37m#{string}" + reset_color; end
37
+ def red string; "\e[41m\e[37m#{string}" + reset_color; end
38
+ def rainbow string; "\e[#{next_color}m#{string}" + reset_color; end
39
+
40
+ def next_color
41
+ @index += 1
42
+ @colors[@index % COLORS_SIZE]
43
+ end
44
+ def reset_color
45
+ "\e[0m"
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'rspec/pride'
3
+ require 'stringio'
4
+
5
+ describe 'live status' do
6
+ RED_HIGHLIGHT = 41
7
+ BOLD_WHITE = 40
8
+
9
+ before do
10
+ @output = StringIO.new
11
+ @formatter = Pride.new @output
12
+ end
13
+
14
+ it 'should print a star for passing tests' do
15
+ @formatter.example_passed self
16
+ @output.string.should match /\*/
17
+ end
18
+
19
+ # the same colour comes around with the same period
20
+ it 'should cycle colours for the passing tests' do
21
+ colours_count = Pride::COLORS.size
22
+ test_count = colours_count * 1000
23
+
24
+ test_count.times { @formatter.example_passed self }
25
+ occurences = @output.string.scan(/#{Pride::COLORS.sample}/).size
26
+
27
+ occurences.should be_within(1).of(test_count/colours_count)
28
+ end
29
+
30
+ it 'should print an F highlighted in red for failed tests' do
31
+ @formatter.example_failed self
32
+ @output.string.should match /F/
33
+ @output.string.should match /#{RED_HIGHLIGHT}/
34
+ end
35
+
36
+ it 'should print a bold white P for pending tests' do
37
+ @formatter.example_pending self
38
+ @output.string.should match /P/
39
+ @output.string.should match /#{BOLD_WHITE}/
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-pride
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Mark Rada
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-17 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "2.5"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: Mimics the functionality of minitest/pride for Rspec2
27
+ email: mrada@marketcircle.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - Rakefile
34
+ - README.markdown
35
+ files:
36
+ - lib/rspec/pride.rb
37
+ - Rakefile
38
+ - README.markdown
39
+ - spec/pride_spec.rb
40
+ homepage: http://github.com/ferrous26/rspec-pride
41
+ licenses:
42
+ - MIT
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.7.2
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Take pride in your testing
67
+ test_files:
68
+ - spec/pride_spec.rb