cukeplusplus 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cukeplusplus.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Ingredients
2
+ =====
3
+ Designed for beauty and simplicity, a Cucumber custom formatter. This clean and easy to use Cucumber formatter displays scenarios as they are run, displaying failures as they occur.
4
+
5
+ I was dissatisfied with existing Cucumber formatters and spent a few hours figuring out the API and dismantling the Pretty formatter in order to create this. Cukeplusplus is inspired by the easy to read colorized output of Emerge, Gentoo’s package manager. Written during a marathon 32-hour coding session, my goal was to reduce the amount of time between running a failing test and being able to work on the bug.
6
+
7
+ Recipies
8
+ ======
9
+ Use this to quickly spot errors, you'll get the actual error displayed as well as the steps that lead up to it, without the visual noise and scrolling of showing every single step as it executes.
10
+
11
+ Reagents
12
+ ====
13
+ No dependancies other than Cucumber itself!
14
+
15
+ gem install cukeplusplus
16
+ cucumber --format 'Cukeplusplus::Base'
17
+
18
+ In the Kitchen with Cukeplusplus
19
+ ======================
20
+ Insert screencast here!
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cukeplusplus/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "cukeplusplus"
7
+ s.version = Cukeplusplus::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Anthony Michael Cook"]
10
+ s.email = ["anthonymichaelcook@gmail.com"]
11
+ s.homepage = "http://github.com/acook/cukeplusplus"
12
+ s.summary = %q{Designed for beauty and simplicity, a Cucumber custom formatter.}
13
+ s.description = %q{This clean and easy to use Cucumber formatter displays scenarios as they are run, displaying failures as they occur.}
14
+
15
+ s.add_dependency "cucumber"
16
+
17
+ s.post_install_message = <<-EOS
18
+
19
+ *****************************************************************
20
+ * To use the cukeplusplus formatter, simple add *
21
+ * --format 'Cukeplusplus::Formatter' *
22
+ * to your cucumber.yml, Rakefile, or command line call *
23
+ *****************************************************************
24
+
25
+ EOS
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ s.require_paths = ["lib"]
31
+ end
@@ -0,0 +1 @@
1
+ default: --format 'Cukeplusplus::Formatter'
@@ -0,0 +1,10 @@
1
+ Feature: Improve cuke feedback during slow-running tests
2
+
3
+ Scenario: slow failing test
4
+ Given I wait 2 seconds
5
+ When I wait 3 seconds
6
+ Then the test fails
7
+
8
+ Scenario: slow passing test
9
+ Given I wait 1 seconds
10
+ Then the test passes!
@@ -0,0 +1,13 @@
1
+ Given /^I wait (\d+) seconds$/ do |seconds|
2
+ seconds = seconds.to_i
3
+ sleep seconds
4
+ end
5
+
6
+ Then /^the test fails$/ do
7
+ (2+2).should == 5
8
+ end
9
+
10
+ Then /^the test passes!$/ do
11
+ (2+2).should == 4
12
+ end
13
+
@@ -0,0 +1,145 @@
1
+ require 'fileutils'
2
+ require 'cucumber/formatter/console'
3
+ require 'cucumber/formatter/io'
4
+ require 'gherkin/formatter/escaping'
5
+ require 'cucumber/formatter/pretty'
6
+
7
+ module Cukeplusplus
8
+ class Base < Cucumber::Formatter::Pretty
9
+ include FileUtils
10
+ include Cucumber::Formatter::Console
11
+ include Cucumber::Formatter::Io
12
+ include Gherkin::Formatter::Escaping
13
+ attr_writer :indent
14
+ attr_reader :step_mother
15
+ attr_accessor :tags, :exception, :source_line
16
+
17
+ def initialize(step_mother, path_or_io, options)
18
+ @step_mother, @io, @options = step_mother, ensure_io(path_or_io, "ugly"), options
19
+ @exceptions = []
20
+ @indent = 0
21
+ @prefixes = options[:prefixes] || {}
22
+ @delayed_announcements = []
23
+ end
24
+
25
+ def before_feature(*args)
26
+ end
27
+
28
+ def tag_name(tag_name)
29
+ @tags << format_string(tag_name, :comment) #.indent(@indent)
30
+ #@io.printf(tag)
31
+ #@io.flush
32
+ @indent = 1
33
+ end
34
+
35
+ def after_tags(tags)
36
+ if @indent == 1
37
+ #@io.puts
38
+ #@io.flush
39
+ end
40
+ end
41
+
42
+ def feature_name(keyword, name)
43
+ @io.puts
44
+ @io.puts format_string("#{keyword}: #{name}", :outline)
45
+ @io.flush
46
+ end
47
+
48
+ def before_feature_element(feature_element)
49
+ @indent = 2
50
+ @scenario_indent = 2
51
+ @tags = Array.new
52
+ end
53
+
54
+ def scenario_name(keyword, name, file_colon_line, source_indent)
55
+ print_feature_element_name(keyword, name, file_colon_line, source_indent, @tags)
56
+
57
+ @scenario_steps = String.new
58
+ end
59
+
60
+ def before_step(step)
61
+ @current_step = step
62
+ @indent = 6
63
+ end
64
+
65
+ def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
66
+ @hide_this_step = false
67
+ if exception
68
+ if @exceptions.include?(exception)
69
+ @hide_this_step = true
70
+ return
71
+ end
72
+ @exceptions << exception
73
+ end
74
+ if status != :failed && @in_background ^ background
75
+ @hide_this_step = true
76
+ return
77
+ end
78
+ @status = status
79
+ end
80
+
81
+ def step_name(keyword, step_match, status, source_indent, background)
82
+ return if @hide_this_step
83
+ source_indent = nil unless @options[:source]
84
+ name_to_report = format_step(keyword, step_match, status == :passed ? :pending : status, false)
85
+
86
+ #@io.puts
87
+ @scenario_steps << name_to_report.indent(@scenario_indent + 2) + "\n"
88
+ @source_line = format_string((' # ' + step_match.file_colon_line).indent(source_indent), :comment)
89
+ print_announcements
90
+ end
91
+
92
+ def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
93
+ if status == :failed
94
+ @io.puts
95
+ @io.puts @scenario_steps
96
+ end
97
+ end
98
+
99
+ def exception(exception, status)
100
+ @exception = format_string(exception, :comment)
101
+ end
102
+
103
+ def after_feature_element(feature_element)
104
+ @io.printf "\r "
105
+ if @status == :passed
106
+ @io.printf "[#{format_string('PASSED', :passed)}]"
107
+ else
108
+ @io.printf "[#{format_string('FAILED', :failed)}]"
109
+ end
110
+ @io.puts @exception ? " #{@exception} #{format_string(@source_line, :tag)}" : " "
111
+ @exception = nil
112
+ @source_line = nil
113
+ end
114
+
115
+ def after_features(features)
116
+ print_summary(features) unless @options[:autoformat]
117
+ end
118
+
119
+ private
120
+
121
+ def method_missing(m, *args)
122
+ puts m.to_s
123
+ end
124
+
125
+ def print_feature_element_name(keyword, name, file_colon_line, source_indent, tags)
126
+ @io.puts if @scenario_indent == 6
127
+ names = name.empty? ? [name] : name.split("\n")
128
+ line = "#{keyword}:#{tags.blank? ? '' : ' ' + tags.join(' ')} #{names[0]}".indent(@scenario_indent)
129
+ @io.print(line)
130
+ # if @options[:source]
131
+ # line_comment = " # #{file_colon_line}".indent(source_indent)
132
+ # @io.print(format_string(line_comment, :comment))
133
+ # end
134
+ names[1..-1].each {|s| @io.puts " #{s}"}
135
+ @io.flush
136
+ end
137
+
138
+ def print_summary(features)
139
+ puts
140
+ print_stats(features, @options.custom_profiles)
141
+ print_snippets(@options)
142
+ print_passing_wip(@options)
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,3 @@
1
+ module Cukeplusplus
2
+ VERSION = '0.0.6'
3
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cukeplusplus
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 6
9
+ version: 0.0.6
10
+ platform: ruby
11
+ authors:
12
+ - Anthony Michael Cook
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-20 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cucumber
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: This clean and easy to use Cucumber formatter displays scenarios as they are run, displaying failures as they occur.
34
+ email:
35
+ - anthonymichaelcook@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - README.md
46
+ - Rakefile
47
+ - cukeplusplus.gemspec
48
+ - example/cucumber.yml
49
+ - example/features/example.feature
50
+ - example/features/step_definitions/example_steps.rb
51
+ - lib/cukeplusplus.rb
52
+ - lib/cukeplusplus/version.rb
53
+ has_rdoc: true
54
+ homepage: http://github.com/acook/cukeplusplus
55
+ licenses: []
56
+
57
+ post_install_message: "\n *****************************************************************\n * To use the cukeplusplus formatter, simple add *\n * --format 'Cukeplusplus::Formatter' * \n * to your cucumber.yml, Rakefile, or command line call *\n *****************************************************************\n\n"
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.3.7
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Designed for beauty and simplicity, a Cucumber custom formatter.
85
+ test_files: []
86
+