snowday 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -0
- data/lib/snowday.rb +48 -0
- data/snowday.gemspec +23 -0
- data/spec/snowday_spec.rb +78 -0
- data/spec/spec_helper.rb +11 -0
- metadata +63 -0
data/README
ADDED
File without changes
|
data/lib/snowday.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'rspec/core/formatters/base_text_formatter'
|
4
|
+
|
5
|
+
class Snowday < RSpec::Core::Formatters::BaseTextFormatter
|
6
|
+
def start(example_count)
|
7
|
+
super(example_count)
|
8
|
+
output.print cyan <<-snowytimes
|
9
|
+
It's snowing outside...
|
10
|
+
|
11
|
+
* * * * *
|
12
|
+
* * * * *
|
13
|
+
* * * * *
|
14
|
+
☃
|
15
|
+
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
16
|
+
|
17
|
+
snowytimes
|
18
|
+
end
|
19
|
+
|
20
|
+
def stop
|
21
|
+
case @failed_examples.length
|
22
|
+
when 0
|
23
|
+
output.print green("\n\n☃ Brrrr. It's nice and cold for these snowmens. Feels like winter out here.")
|
24
|
+
when 1..5
|
25
|
+
output.print red("\n\n☹ Oh noes! A few snowmens are melted. Feels like fall out here.")
|
26
|
+
when 6..10
|
27
|
+
output.print red("\n\n☹ Oh noes! Some of your snowmens are getting watery. Feels like spring out here.")
|
28
|
+
else
|
29
|
+
output.print red("\n\n☹ Oh noes! Your snowmens are melted. Feels like summer out here.")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def example_passed(example)
|
34
|
+
super(example)
|
35
|
+
output.print green("☃ ")
|
36
|
+
end
|
37
|
+
|
38
|
+
def example_pending(example)
|
39
|
+
super(example)
|
40
|
+
output.print yellow('☃ ')
|
41
|
+
end
|
42
|
+
|
43
|
+
def example_failed(example)
|
44
|
+
super(example)
|
45
|
+
output.print red('☃ ')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
data/snowday.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "snowday"
|
8
|
+
s.version = '0.1.1'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Mike Pack"]
|
11
|
+
s.email = ["mikepackdev@gmail.com"]
|
12
|
+
s.homepage = "http://www.mikepackdev.com"
|
13
|
+
s.summary = %q{Snowday Formatter for RSpec}
|
14
|
+
s.description = %q{Makes you feel all warm inside. Like hot chocolate.}
|
15
|
+
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'rspec'
|
19
|
+
|
20
|
+
s.files = %w( README snowday.gemspec ) + Dir["lib/**/*.rb"]
|
21
|
+
s.test_files = Dir["spec/**/*.rb"]
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Snowday do
|
6
|
+
let(:output) { StringIO.new }
|
7
|
+
let(:formatter) { Snowday.new(output) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
formatter.stub(:delay => true)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "Snowday output" do
|
14
|
+
let(:example) {
|
15
|
+
double("example 1",
|
16
|
+
:execution_result => {:status => 'failed', :exception => Exception.new }
|
17
|
+
)
|
18
|
+
}
|
19
|
+
|
20
|
+
it "displays 'It's snowing outside' at the start of the suite" do
|
21
|
+
formatter.start(1)
|
22
|
+
output.string.should =~ /It's snowing outside/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "displays a pretty snowfall at the start of the suite" do
|
26
|
+
formatter.start(1)
|
27
|
+
output.string.should =~ /\*/
|
28
|
+
end
|
29
|
+
|
30
|
+
it "displays '☃' when examples pass" do
|
31
|
+
formatter.example_passed(example)
|
32
|
+
output.string.should =~ /☃/
|
33
|
+
end
|
34
|
+
|
35
|
+
it "displays '☃' when examples fail" do
|
36
|
+
formatter.example_failed(example)
|
37
|
+
output.string.should =~ /☃/
|
38
|
+
end
|
39
|
+
|
40
|
+
it "displays '☃' when examples are pending" do
|
41
|
+
formatter.example_pending(example)
|
42
|
+
output.string.should =~ /☃/
|
43
|
+
end
|
44
|
+
|
45
|
+
it "displays '☃ Brrrr. It's nice and cold for these snowmens. Feels like winter out here.' all examples pass" do
|
46
|
+
formatter.example_passed(example)
|
47
|
+
formatter.stop
|
48
|
+
output.string.should =~ /winter/
|
49
|
+
end
|
50
|
+
|
51
|
+
it "displays '☹ Oh noes! A few snowmens are melted. Feels like fall out here.' when 1-5 examples fail" do
|
52
|
+
formatter.example_passed(example)
|
53
|
+
(Random.rand(5) + 1).times do
|
54
|
+
formatter.example_failed(example)
|
55
|
+
end
|
56
|
+
formatter.stop
|
57
|
+
output.string.should =~ /fall/
|
58
|
+
end
|
59
|
+
|
60
|
+
it "displays '☹ Oh noes! Some of your snowmens are getting watery. Feels like spring out here.' when 6-10 examples fail" do
|
61
|
+
formatter.example_passed(example)
|
62
|
+
(Random.rand(5) + 6).times do
|
63
|
+
formatter.example_failed(example)
|
64
|
+
end
|
65
|
+
formatter.stop
|
66
|
+
output.string.should =~ /spring/
|
67
|
+
end
|
68
|
+
|
69
|
+
it "displays '☹ Oh noes! Your snowmens are melted. Feels like summer out here.' when more than 10 examples fail" do
|
70
|
+
formatter.example_passed(example)
|
71
|
+
11.times do
|
72
|
+
formatter.example_failed(example)
|
73
|
+
end
|
74
|
+
formatter.stop
|
75
|
+
output.string.should =~ /summer/
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snowday
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Pack
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70208716644340 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70208716644340
|
25
|
+
description: Makes you feel all warm inside. Like hot chocolate.
|
26
|
+
email:
|
27
|
+
- mikepackdev@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- README
|
33
|
+
- snowday.gemspec
|
34
|
+
- lib/snowday.rb
|
35
|
+
- spec/snowday_spec.rb
|
36
|
+
- spec/spec_helper.rb
|
37
|
+
homepage: http://www.mikepackdev.com
|
38
|
+
licenses: []
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.6
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.8.10
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Snowday Formatter for RSpec
|
61
|
+
test_files:
|
62
|
+
- spec/snowday_spec.rb
|
63
|
+
- spec/spec_helper.rb
|