nyan-cat-formatter 0.0.7 → 0.0.8
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/README.md +41 -13
- data/data/nyan-cat.mp3 +0 -0
- data/demo.rb +30 -0
- data/lib/nyan_cat_formatter.rb +2 -3
- data/lib/{rspec1.rb → nyan_cat_formatter/rspec1.rb} +1 -0
- data/lib/{rspec2.rb → nyan_cat_formatter/rspec2.rb} +1 -1
- data/lib/nyan_cat_music_formatter.rb +29 -0
- data/nyan-cat-formatter.gemspec +3 -1
- data/spec/nyan_cat_formatter_spec.rb +15 -12
- data/spec/nyan_cat_music_formatter_spec.rb +79 -0
- metadata +24 -9
data/README.md
CHANGED
@@ -14,12 +14,28 @@ The rainbow changes colors as it runs. See it in action [here](http://vimeo.com/
|
|
14
14
|
|
15
15
|
Works with RSpec 1.3 and RSpec 2.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
```
|
17
|
+
Using Nyan Cat
|
18
|
+
---------------
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
You can either specify the formatting when using the `rspec` command:
|
21
|
+
|
22
|
+
rspec --format NyanCatFormatter
|
23
|
+
|
24
|
+
Or add `--format NyanCatFormatter` to a `.rspec` file placed in your project's root directory,
|
25
|
+
so that you won't have to specify the `--format` option everytime you run the command.
|
26
|
+
|
27
|
+
###Using with Bundler
|
28
|
+
|
29
|
+
To use Nyan Cat with a project that uses Bundler (Rails or Sinatra f.e.) you need to add Nyan Cat dependecy to your Gemfile:
|
30
|
+
|
31
|
+
group :test do
|
32
|
+
gem "nyan-cat-formatter"
|
33
|
+
end
|
34
|
+
|
35
|
+
And then run `bundle install`.
|
36
|
+
|
37
|
+
Installing it
|
38
|
+
-------------
|
23
39
|
|
24
40
|
```
|
25
41
|
$ gem install nyan-cat-formatter
|
@@ -31,22 +47,34 @@ If you want to use Nyan Cat as your default formatter, simply put the options in
|
|
31
47
|
--format NyanCatFormatter
|
32
48
|
```
|
33
49
|
|
34
|
-
|
35
|
-
|
50
|
+
Playing the Nyan Cat song
|
51
|
+
-------------------------
|
52
|
+
|
53
|
+
You can then enjoy playback in two ways:
|
36
54
|
|
37
|
-
|
55
|
+
**1. Play the song only when desired using a command line option:**
|
56
|
+
|
57
|
+
Use the following command to run your specs:
|
38
58
|
|
39
59
|
```
|
40
|
-
|
41
|
-
gem "nyan-cat-formatter"
|
42
|
-
end
|
60
|
+
$ rspec spec -f NyanCatMusicFormatter
|
43
61
|
```
|
44
|
-
|
62
|
+
|
63
|
+
And enjoy the site of Nyan Cat running across your terminal to the Nyan Cat song!
|
64
|
+
|
65
|
+
**2. Play the song by default when you run your specs:**
|
66
|
+
|
67
|
+
Make sure your .rspec file in your application's root directory contains the following:
|
45
68
|
|
46
69
|
```
|
47
|
-
|
70
|
+
--color
|
71
|
+
--format NyanCatMusicFormatter
|
48
72
|
```
|
49
73
|
|
74
|
+
Then run `rspec spec` and enjoy Nyan Cat formatted text output accompanied by the Nyan Cat song by default!
|
75
|
+
|
76
|
+
**This currently only works on Mac OSx.**
|
77
|
+
|
50
78
|
Contributing
|
51
79
|
----------
|
52
80
|
|
data/data/nyan-cat.mp3
ADDED
Binary file
|
data/demo.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'spec/spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe NyanCatFormatter do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@output = StringIO.new
|
8
|
+
@formatter = NyanCatFormatter.new(@output)
|
9
|
+
@formatter.start(2)
|
10
|
+
@example = RSpec::Core::ExampleGroup.describe.example
|
11
|
+
|
12
|
+
@samples = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
|
13
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
14
|
+
|
15
|
+
sleep(0.1) # Just to slow it down a little :-)
|
16
|
+
end
|
17
|
+
|
18
|
+
100.times do |index|
|
19
|
+
it "should perform passing specs" do
|
20
|
+
@formatter.current.should == @samples.sample
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should perform pending specs" do
|
24
|
+
if @samples.sample == 1
|
25
|
+
pending
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/nyan_cat_formatter.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
rspec_bin = $0.split('/').last
|
4
4
|
if rspec_bin == 'spec'
|
5
|
-
['spec', 'rspec1', 'spec/runner/formatter/base_text_formatter'].each {|f| require f}
|
5
|
+
['spec', 'nyan_cat_formatter/rspec1', 'spec/runner/formatter/base_text_formatter'].each {|f| require f}
|
6
6
|
parent_class = Spec::Runner::Formatter::BaseTextFormatter
|
7
7
|
rspec_module = RSpec1
|
8
8
|
else
|
9
|
-
['rspec2','rspec/core/formatters/base_text_formatter'].each {|f| require f}
|
9
|
+
['nyan_cat_formatter/rspec2', 'rspec/core/formatters/base_text_formatter'].each {|f| require f}
|
10
10
|
parent_class = RSpec::Core::Formatters::BaseTextFormatter
|
11
11
|
rspec_module = RSpec2
|
12
12
|
end
|
@@ -171,6 +171,5 @@ NyanCatFormatter = Class.new(parent_class) do
|
|
171
171
|
else mark
|
172
172
|
end
|
173
173
|
end
|
174
|
-
|
175
174
|
end
|
176
175
|
|
@@ -40,6 +40,7 @@ module RSpec1
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
43
|
+
system("killall -9 afplay") if File.exists?(File.expand_path("~/.nyan-cat.mp3")) && RUBY_PLATFORM.downcase.include?("darwin")
|
43
44
|
@output.puts "\nYou've Nyaned for #{duration} seconds\n".each_char.map {|c| rainbowify(c)}.join
|
44
45
|
summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
|
45
46
|
summary << ", #{pending_count} pending" if pending_count > 0
|
@@ -28,11 +28,11 @@ module RSpec2
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
31
|
+
system("killall -9 afplay") if File.exists?("#{ROOT}/data/nyan-cat.mp3") && RUBY_PLATFORM.downcase.include?("darwin")
|
31
32
|
dump_profile if profile_examples? && failure_count == 0
|
32
33
|
summary = "\nYou've Nyaned for #{format_seconds(duration)} seconds\n".split(//).map { |c| rainbowify(c) }
|
33
34
|
output.puts summary.join
|
34
35
|
output.puts colorise_summary(summary_line(example_count, failure_count, pending_count))
|
35
|
-
|
36
36
|
if respond_to?(:dump_commands_to_rerun_failed_examples)
|
37
37
|
dump_commands_to_rerun_failed_examples
|
38
38
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'nyan_cat_formatter'
|
3
|
+
|
4
|
+
NyanCatMusicFormatter = Class.new(NyanCatFormatter) do
|
5
|
+
def osx?
|
6
|
+
platform.include?("darwin")
|
7
|
+
end
|
8
|
+
|
9
|
+
def kernel=(kernel)
|
10
|
+
@kernel = kernel
|
11
|
+
end
|
12
|
+
|
13
|
+
def kernel
|
14
|
+
@kernel ||= Kernel
|
15
|
+
end
|
16
|
+
|
17
|
+
def platform=(platform)
|
18
|
+
@platform = platform
|
19
|
+
end
|
20
|
+
|
21
|
+
def platform
|
22
|
+
@platform ||= RUBY_PLATFORM
|
23
|
+
end
|
24
|
+
|
25
|
+
def start input
|
26
|
+
super
|
27
|
+
kernel.system("afplay '#{ROOT}/data/nyan-cat.mp3' &") if osx?
|
28
|
+
end
|
29
|
+
end
|
data/nyan-cat-formatter.gemspec
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
2
|
|
3
|
+
ROOT = "#{File.dirname(__FILE__)}" unless defined?(ROOT)
|
4
|
+
|
3
5
|
Gem::Specification.new do |s|
|
4
6
|
s.name = "nyan-cat-formatter"
|
5
|
-
s.version = "0.0.
|
7
|
+
s.version = "0.0.8"
|
6
8
|
s.authors = ["Matt Sears"]
|
7
9
|
s.email = ["matt@mattsears.com"]
|
8
10
|
s.homepage = "http://mtts.rs/nyancat"
|
@@ -34,10 +34,11 @@ describe NyanCatFormatter do
|
|
34
34
|
|
35
35
|
it 'should relax Nyan Cat' do
|
36
36
|
@formatter.example_passed(@example)
|
37
|
-
@formatter.nyan_cat.should == [
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
@formatter.nyan_cat.should == [
|
38
|
+
'_,------, ',
|
39
|
+
'_| /\_/\ ',
|
40
|
+
'~|_( ^ .^) ',
|
41
|
+
' "" "" '
|
41
42
|
].join("\n")
|
42
43
|
end
|
43
44
|
|
@@ -61,10 +62,11 @@ describe NyanCatFormatter do
|
|
61
62
|
|
62
63
|
it 'should alert Nyan Cat' do
|
63
64
|
@formatter.example_pending(@example)
|
64
|
-
@formatter.nyan_cat.should == [
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
@formatter.nyan_cat.should == [
|
66
|
+
'_,------, ',
|
67
|
+
'_| /\_/\ ',
|
68
|
+
'~|_( o .o) ',
|
69
|
+
' "" "" '
|
68
70
|
].join("\n")
|
69
71
|
end
|
70
72
|
|
@@ -84,10 +86,11 @@ describe NyanCatFormatter do
|
|
84
86
|
|
85
87
|
it 'should alert Nyan Cat' do
|
86
88
|
@formatter.example_failed(@example)
|
87
|
-
@formatter.nyan_cat.should == [
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
@formatter.nyan_cat.should == [
|
90
|
+
'_,------, ',
|
91
|
+
'_| /\_/\ ',
|
92
|
+
'~|_( o .o) ',
|
93
|
+
' "" "" '
|
91
94
|
].join("\n")
|
92
95
|
end
|
93
96
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
require 'nyan_cat_music_formatter'
|
4
|
+
|
5
|
+
class MockKernel
|
6
|
+
def system(string)
|
7
|
+
seen << string
|
8
|
+
end
|
9
|
+
|
10
|
+
def seen
|
11
|
+
@seen ||= []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe NyanCatMusicFormatter do
|
16
|
+
def path_to_mp3
|
17
|
+
"'#{ROOT}/data/nyan-cat.mp3'"
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:stdout) { StringIO.new }
|
21
|
+
let(:formatter) { described_class.new stdout }
|
22
|
+
let(:mock_kernel) { MockKernel.new }
|
23
|
+
|
24
|
+
before { formatter.kernel = mock_kernel }
|
25
|
+
|
26
|
+
describe 'kernel' do
|
27
|
+
it 'defaults to Kernel' do
|
28
|
+
described_class.new(stdout).kernel.should == Kernel
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'can be set' do
|
32
|
+
formatter = described_class.new stdout
|
33
|
+
formatter.kernel = 'something else'
|
34
|
+
formatter.kernel.should == 'something else'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'platform' do
|
39
|
+
it 'defaults to RUBY_PLATFORM' do
|
40
|
+
described_class.new(stdout).platform.should equal RUBY_PLATFORM
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can be set' do
|
44
|
+
formatter = described_class.new stdout
|
45
|
+
formatter.platform = 'something else'
|
46
|
+
formatter.platform.should == 'something else'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'start' do
|
51
|
+
it 'sets the total amount of specs' do
|
52
|
+
formatter.start 3
|
53
|
+
formatter.example_count.should == 3
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'sets the current to 0' do
|
57
|
+
formatter.start 3
|
58
|
+
formatter.current.should == 0
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when on OS X' do
|
62
|
+
before { formatter.platform = 'darwin' }
|
63
|
+
|
64
|
+
it 'plays the song in the background' do
|
65
|
+
formatter.start 3
|
66
|
+
mock_kernel.seen.should include "afplay #{path_to_mp3} &"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when not on OS X' do
|
71
|
+
before { formatter.platform = 'windows' }
|
72
|
+
|
73
|
+
it 'does not play the song' do
|
74
|
+
formatter.start 4
|
75
|
+
mock_kernel.seen.should be_empty
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nyan-cat-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rspec
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
description: ! 'Nyan Cat inspired RSpec formatter! '
|
37
47
|
email:
|
38
48
|
- matt@mattsears.com
|
@@ -49,11 +59,15 @@ files:
|
|
49
59
|
- LICENSE.md
|
50
60
|
- README.md
|
51
61
|
- Rakefile
|
62
|
+
- data/nyan-cat.mp3
|
63
|
+
- demo.rb
|
52
64
|
- lib/nyan_cat_formatter.rb
|
53
|
-
- lib/rspec1.rb
|
54
|
-
- lib/rspec2.rb
|
65
|
+
- lib/nyan_cat_formatter/rspec1.rb
|
66
|
+
- lib/nyan_cat_formatter/rspec2.rb
|
67
|
+
- lib/nyan_cat_music_formatter.rb
|
55
68
|
- nyan-cat-formatter.gemspec
|
56
69
|
- spec/nyan_cat_formatter_spec.rb
|
70
|
+
- spec/nyan_cat_music_formatter_spec.rb
|
57
71
|
- spec/spec_helper.rb
|
58
72
|
homepage: http://mtts.rs/nyancat
|
59
73
|
licenses: []
|
@@ -75,10 +89,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
89
|
version: '0'
|
76
90
|
requirements: []
|
77
91
|
rubyforge_project: nyan-cat-formatter
|
78
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.24
|
79
93
|
signing_key:
|
80
94
|
specification_version: 3
|
81
95
|
summary: Nyan Cat inspired RSpec formatter!
|
82
96
|
test_files:
|
83
97
|
- spec/nyan_cat_formatter_spec.rb
|
98
|
+
- spec/nyan_cat_music_formatter_spec.rb
|
84
99
|
- spec/spec_helper.rb
|