rspec-half_full 0.20140618
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +13 -0
- data/Rakefile +19 -0
- data/lib/rspec/half_full.rb +61 -0
- data/spec/acceptance_spec.rb +18 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3ef25f42b006ae254b5c46e4351facd9aa5eb845
|
4
|
+
data.tar.gz: 745af5e18c58b7c9b8ae9aaf72462bcb4c4aef2e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c191db997a4c36bc3e4d5e74eb258cc5f6a7f566015343704ed258ad767b4a9bf32f806fa4e77025298ebee79a0a2bca018b05c78c77a7c243be68525fde36e8
|
7
|
+
data.tar.gz: 79315db845815d65e119f390a3fcdc8872000e62175148a5bb0a5943d81ba33b5fe33bf9c0ba0a45b649c0e1f947134066bd352d287233281500c45a059e81fc
|
data/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# rspec-half_full
|
2
|
+
|
3
|
+
There are no failed specs, only specs with unexpected outcomes.
|
4
|
+
|
5
|
+
If you subscribe to the view that tests are half-passing not half-failing, this gem might be for you!
|
6
|
+
|
7
|
+
## How to use
|
8
|
+
|
9
|
+
Run `rspec` like this:
|
10
|
+
|
11
|
+
rspec --color --require rspec/half_full --format RSpec::HalfFull
|
12
|
+
|
13
|
+
Or copy over `.rspec` file into your project.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
|
5
|
+
task :default => :test
|
6
|
+
task :test => :spec
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
spec = Gem::Specification.load('rspec-half_full.gemspec')
|
13
|
+
Gem::PackageTask.new(spec) { }
|
14
|
+
|
15
|
+
require 'rubygems/installer'
|
16
|
+
desc 'Build the gem and install it'
|
17
|
+
task :install => :gem do
|
18
|
+
Gem::Installer.new("pkg/#{spec.file_name}").install
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rspec/core/formatters/base_text_formatter'
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
class HalfFull < RSpec::Core::Formatters::BaseTextFormatter
|
5
|
+
def initialize(io)
|
6
|
+
super(io)
|
7
|
+
RSpec.configuration.failure_color = :green
|
8
|
+
end
|
9
|
+
|
10
|
+
def summary_line(example_count, failure_count, pending_count)
|
11
|
+
success_count = example_count - failure_count - pending_count
|
12
|
+
summary = pluralize(example_count, "example")
|
13
|
+
summary << ", " << "#{success_count} already successful" if success_count > 0
|
14
|
+
summary << ", " << pluralize(failure_count, "future success")
|
15
|
+
summary << ", #{pending_count} pending" if pending_count > 0
|
16
|
+
summary
|
17
|
+
end
|
18
|
+
|
19
|
+
def dump_failures
|
20
|
+
return if failed_examples.empty?
|
21
|
+
output.puts
|
22
|
+
output.puts "Future successes:"
|
23
|
+
failed_examples.each_with_index do |example, index|
|
24
|
+
output.puts
|
25
|
+
pending_fixed?(example) ? dump_pending_fixed(example, index) : dump_failure(example, index)
|
26
|
+
dump_backtrace(example)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def dump_failure_info(example)
|
31
|
+
exception = example.execution_result[:exception]
|
32
|
+
exception_class_name = exception_class_name_for(exception)
|
33
|
+
output.puts "#{long_padding}#{failure_color("Future Success:")} #{failure_color(read_failed_line(exception, example).strip)}"
|
34
|
+
output.puts "#{long_padding}#{failure_color(exception_class_name)}:" unless exception_class_name =~ /RSpec/
|
35
|
+
exception.message.to_s.split("\n").each { |line| output.puts "#{long_padding} #{failure_color(line)}" } if exception.message
|
36
|
+
|
37
|
+
if shared_group = find_shared_group(example)
|
38
|
+
dump_shared_failure_info(shared_group)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def dump_commands_to_rerun_failed_examples
|
43
|
+
return if failed_examples.empty?
|
44
|
+
output.puts
|
45
|
+
output.puts("Rerun on next step to success:")
|
46
|
+
output.puts
|
47
|
+
|
48
|
+
failed_examples.each do |example|
|
49
|
+
output.puts(failure_color("rspec #{RSpec::Core::Metadata::relative_path(example.location)}") + " " + detail_color("# #{example.full_description}"))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def pluralize(count, string)
|
54
|
+
if string.end_with?("success")
|
55
|
+
"#{count} #{string}#{'es' unless count.to_f == 1}"
|
56
|
+
else
|
57
|
+
super(count, string)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rspec/half_full"
|
2
|
+
|
3
|
+
describe 'Something Awesome' do
|
4
|
+
100.times do |i|
|
5
|
+
case i % 10
|
6
|
+
when 0
|
7
|
+
it "knows the answer is 42s but question is still pending"
|
8
|
+
when 1
|
9
|
+
it "will be awesome soon" do
|
10
|
+
(2+2).should == 5
|
11
|
+
end
|
12
|
+
else
|
13
|
+
it "is already awesome" do
|
14
|
+
(2+2).should == 4
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-half_full
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.20140618'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomasz Wegrzanowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.14'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.14'
|
27
|
+
description: RSpec reporter for incorrigible optimists
|
28
|
+
email: Tomasz.Wegrzanowski@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
33
|
+
files:
|
34
|
+
- lib/rspec/half_full.rb
|
35
|
+
- Rakefile
|
36
|
+
- spec/acceptance_spec.rb
|
37
|
+
- README.md
|
38
|
+
homepage: https://github.com/taw/rspec-half_full
|
39
|
+
licenses:
|
40
|
+
- MIT
|
41
|
+
metadata: {}
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 2.0.14
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: There are no failed specs
|
62
|
+
test_files:
|
63
|
+
- spec/acceptance_spec.rb
|