rspec-pride 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.markdown +12 -7
  2. data/Rakefile +8 -24
  3. data/lib/rspec/pride.rb +73 -36
  4. data/spec/pride_spec.rb +12 -28
  5. metadata +31 -37
data/README.markdown CHANGED
@@ -1,18 +1,23 @@
1
- # Rspec-pride
1
+ # rspec-pride
2
2
 
3
- Take pride in your test output
3
+ Take pride in your test output!
4
4
 
5
5
  Mimics the functionality of minitest/pride for RSpec2
6
6
 
7
- [![Build Status](http://travis-ci.org/ferrous26/rspec-pride.png)](http://travis-ci.org/ferrous26/rspec-pride)
8
-
9
7
  ## How to use Rspec-pride
10
8
 
11
- To use rspec-pride, you need to call `rspec` with the following options:
9
+ To use rspec-pride, you need to call `rspec` kind of like this:
10
+
11
+ rspec --require rspec/pride --format RSpec::Pride
12
+
13
+ Or put those options in your `.rspec` file.
12
14
 
13
- --require rspec/pride --format Pride
15
+ ## Tests
14
16
 
15
- Or put those in your `.rspec` file.
17
+ The tests are a lie! They don't test rspec-pride directly, they just
18
+ produce enough output so that you can visually verify that everything
19
+ is working. This was much faster than writing actual tests and works
20
+ just as well in this case.
16
21
 
17
22
  ## Contributing to Rspec-pride
18
23
 
data/Rakefile CHANGED
@@ -1,41 +1,25 @@
1
- require 'rubygems'
2
1
  require 'rake'
3
2
 
4
3
  task :default => :test
5
4
  task :test => :spec
6
5
 
7
- if RUBY_ENGINE == 'macruby'
8
-
6
+ if RUBY_ENGINE == 'macruby' && MACRUBY_REVISION.match(/^git commit/)
9
7
  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
-
8
+ Rake::CompileTask.new
23
9
  end
24
10
 
25
-
26
11
  require 'rspec/core/rake_task'
27
12
  RSpec::Core::RakeTask.new(:spec) do |spec|
28
13
  spec.skip_bundler = true
29
14
  spec.pattern = FileList['spec/**/*_spec.rb']
30
15
  end
31
16
 
32
-
33
- require 'rubygems/builder'
34
- require 'rubygems/installer'
17
+ require 'rake/gempackagetask'
35
18
  spec = Gem::Specification.load('rspec-pride.gemspec')
19
+ Rake::GemPackageTask.new(spec) { }
36
20
 
37
- desc 'Build the gem'
38
- task :build do Gem::Builder.new(spec).build end
39
-
21
+ require 'rubygems/installer'
40
22
  desc 'Build the gem and install it'
41
- task :install => :build do Gem::Installer.new(spec.file_name).install end
23
+ task :install => :gem do
24
+ Gem::Installer.new(spec.file_name).install
25
+ end
data/lib/rspec/pride.rb CHANGED
@@ -1,47 +1,84 @@
1
1
  require 'rspec/core/formatters/base_text_formatter'
2
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
3
+ module RSpec
4
+ class Pride < RSpec::Core::Formatters::BaseTextFormatter
17
5
 
18
- def example_passed proxy
19
- super
20
- output.print rainbow( @chars[@index % CHARS_SIZE] )
21
- end
6
+ # stolen from minitest/pride
7
+ ESC = "\e["
8
+ NND = "#{ESC}0m"
22
9
 
23
- def example_failed proxy
24
- super
25
- output.print red( 'F' )
26
- end
10
+ def initialize io
11
+ super
12
+ initialize_colors
13
+ @index = 0
14
+ @size = @colors.size
15
+ output.print "\n"
16
+ end
27
17
 
28
- def example_pending proxy
29
- super
30
- output.print bold_white( 'P' )
31
- end
18
+ def example_passed example; output.print pass ; end
19
+ def example_failed example; output.print failure; end
20
+ def example_pending example; output.print pending; end
32
21
 
22
+ def dump_summary duration, example_count, failure_count, pending_count
23
+ icing = 'Fabulous tests'.split(//).map { |x| rainbow x }.join
24
+ output.print "\n\n#{icing} in #{duration} seconds\n" +
25
+ "#{example_count} examples, #{failure_count} failures, #{pending_count} pending\n\n"
26
+ end
33
27
 
34
- private
35
28
 
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
29
+ private
30
+
31
+ def pass ; rainbow '.' ; end
32
+ def pending; "\e[40m\e[37mP#{NND}"; end
33
+ def failure; "\e[41m\e[37mF#{NND}"; end
34
+
35
+ if ENV['TERM'] =~ /^xterm(-256color)?$/
36
+
37
+ PI_3 = Math::PI / 3
38
+
39
+ # Taken, wholesale, from minitest/pride
40
+ def initialize_colors
41
+ # walk red, green, and blue around a circle separated by equal thirds.
42
+ #
43
+ # To visualize, type this into wolfram-alpha:
44
+ #
45
+ # plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
46
+
47
+ # 6 has wide pretty gradients. 3 == lolcat, about half the width
48
+ @colors = (0...(6 * 7)).map { |n|
49
+ n *= 1.0 / 6
50
+ r = (3 * Math.sin(n ) + 3).to_i
51
+ g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
52
+ b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
53
+
54
+ # Then we take rgb and encode them in a single number using base 6.
55
+ # For some mysterious reason, we add 16... to clear the bottom 4 bits?
56
+ # Yes... they're ugly.
57
+
58
+ 36 * r + 6 * g + b + 16
59
+ }
60
+ end
61
+
62
+ def rainbow string
63
+ color = @colors[@index % @size]
64
+ @index += 1
65
+ "#{ESC}38;5;#{color}m#{string}#{NND}"
66
+ end
67
+
68
+ else # Old Low-Res Pride
69
+
70
+ def initialize_colors
71
+ @colors = (31..36).to_a
72
+ end
73
+
74
+ def rainbow string
75
+ string = '*' if string == '.'
76
+ color = @colors[@index % @size]
77
+ @index += 1
78
+ "#{ESC}#{color}m#{string}#{NND}"
79
+ end
80
+
81
+ end
39
82
 
40
- def next_color
41
- @index += 1
42
- @colors[@index % COLORS_SIZE]
43
- end
44
- def reset_color
45
- "\e[0m"
46
83
  end
47
84
  end
data/spec/pride_spec.rb CHANGED
@@ -2,40 +2,24 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  require 'rspec/pride'
3
3
  require 'stringio'
4
4
 
5
- describe 'live status' do
6
- RED_HIGHLIGHT = 41
7
- BOLD_WHITE = 40
5
+ describe 'Some class' do
8
6
 
9
- before do
10
- @output = StringIO.new
11
- @formatter = Pride.new @output
7
+ 50.times do |n|
8
+ it "passes #{n}" do
9
+ 1.should == 1
10
+ end
12
11
  end
13
12
 
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
13
+ it 'should be pending'
23
14
 
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)
15
+ it 'should fail' do
16
+ 1.should == 0
28
17
  end
29
18
 
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}/
19
+ 10.times do |n|
20
+ it "passed #{n}" do
21
+ true.should be_true
22
+ end
34
23
  end
35
24
 
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
25
  end
metadata CHANGED
@@ -1,68 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rspec-pride
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
4
5
  prerelease:
5
- version: 1.0.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Mark Rada
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-04-17 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70306678499980 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
23
- version: "2.5"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.6'
24
22
  type: :runtime
25
- version_requirements: *id001
26
- description: Mimics the functionality of minitest/pride for Rspec2
23
+ prerelease: false
24
+ version_requirements: *70306678499980
25
+ description: Mimics the functionality of minitest/pride for RSpec2
27
26
  email: mrada@marketcircle.com
28
27
  executables: []
29
-
30
28
  extensions: []
31
-
32
- extra_rdoc_files:
33
- - Rakefile
29
+ extra_rdoc_files:
34
30
  - README.markdown
35
- files:
31
+ files:
36
32
  - lib/rspec/pride.rb
37
33
  - Rakefile
38
- - README.markdown
39
34
  - spec/pride_spec.rb
35
+ - README.markdown
40
36
  homepage: http://github.com/ferrous26/rspec-pride
41
- licenses:
37
+ licenses:
42
38
  - MIT
43
39
  post_install_message:
44
40
  rdoc_options: []
45
-
46
- require_paths:
41
+ require_paths:
47
42
  - lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
43
+ required_ruby_version: !ruby/object:Gem::Requirement
49
44
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
50
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
60
55
  requirements: []
61
-
62
56
  rubyforge_project:
63
- rubygems_version: 1.7.2
57
+ rubygems_version: 1.8.8
64
58
  signing_key:
65
59
  specification_version: 3
66
60
  summary: Take pride in your testing
67
- test_files:
61
+ test_files:
68
62
  - spec/pride_spec.rb