cucumber-instafail 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 259fb3c2fd9134e5e7da9ee7206507bc77f609bd
4
+ data.tar.gz: ae4714946c607e3aae1017209b121c67ec546cef
5
+ SHA512:
6
+ metadata.gz: aa58fb9a902d1d497229f43e2b5ce2a434d47a530410a8fa1379f7cc048167aa2e32d48253943c84f521660dea69de1f1f2a42efbfd9412cad87f3061febeb4e
7
+ data.tar.gz: 2b182348c2c55651db716640fe85f6bf0a4036dc3ae41e3fe9006617169a77b79fb373001b173fac8093aa195f393354e416ec41864f0911cb03defa43e49d5d
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cucumber-instafail.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 zedtux
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Cucumber::Instafail
2
+
3
+ Show failing features instantly. Show passing spec as green dots as usual.
4
+ Highly inspired from
5
+ [rspec-instafail](https://github.com/grosser/rspec-instafail) from
6
+ [grosser](https://github.com/grosser).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'cucumber-instafail'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install cucumber-instafail
23
+
24
+ ## Usage
25
+
26
+ In order to use cucumber-instafail add the following flag to the cucumber
27
+ command line:
28
+
29
+ --format Cucumber::Instafail
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/zedtux/cucumber-instafail/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cucumber/instafail/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cucumber-instafail'
8
+ spec.version = Cucumber::Instafail::VERSION
9
+ spec.authors = ['Guillaume Hain']
10
+ spec.email = ['zedtux@zedroot.org']
11
+ spec.summary = 'Show failing features instantly'
12
+ spec.description = 'Show failing features instantly. Show passing spec ' \
13
+ 'as green dots as usual. Highly inspired by ' \
14
+ 'rspec-instafail from grosser ' \
15
+ '(https://github.com/grosser).'
16
+ spec.homepage = 'https://github.com/zedtux/cucumber-instafail'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(/^(test|spec|features)/)
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'cucumber', '~> 1.3'
25
+
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rubocop'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'cucumber-core'
31
+ end
@@ -0,0 +1,19 @@
1
+ require 'cucumber/formatter/console'
2
+ require 'cucumber/formatter/io'
3
+
4
+ module Cucumber
5
+ module Formatter
6
+ # The formatter used for <tt>--format progress-instafail</tt>
7
+ class ProgressInstafail < Cucumber::Formatter::Progress
8
+ def progress(status)
9
+ char = CHARS[status]
10
+ @io.print(format_string(char, status))
11
+ if status == :failed
12
+ last_failed = runtime.steps(:failed).last
13
+ print_elements(Array(last_failed), status, 'steps')
14
+ end
15
+ @io.flush
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ module Cucumber
2
+ #
3
+ # Cucumber::Instafail shows failing features instantly.
4
+ #
5
+ # @author zedtux
6
+ #
7
+ module Instafail
8
+ VERSION = '0.1.0'
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ require 'cucumber/instafail/formatter/progress-instafail'
2
+ require 'cucumber/instafail/version'
@@ -0,0 +1,174 @@
1
+ require 'spec_helper'
2
+ require 'cucumber/formatter/progress'
3
+ require 'support/cucumber_spec_helper'
4
+ require 'cucumber/cli/main'
5
+ require 'cucumber/instafail/formatter/progress_instafail'
6
+
7
+ module Cucumber
8
+ module Formatter
9
+ describe ProgressInstafail do
10
+ extend SpecHelperDsl
11
+ include SpecHelper
12
+
13
+ before(:each) do
14
+ Cucumber::Term::ANSIColor.coloring = false
15
+ @out = StringIO.new
16
+ @options = Cucumber::Cli::Options.new
17
+ @formatter = ProgressInstafail.new(step_mother, @out, @options)
18
+ run_defined_feature
19
+ end
20
+
21
+ context 'with a single passing scenario' do
22
+ define_feature <<-FEATURE
23
+ Feature: Banana party
24
+
25
+ Scenario: Monkey eats banana
26
+ Given there are bananas
27
+ FEATURE
28
+
29
+ define_steps do
30
+ Given(/^there are bananas$/) { }
31
+ end
32
+
33
+ it 'outputs the passed step' do
34
+ expect(@out.string).to include ".\n"
35
+ end
36
+ end
37
+
38
+ context 'with a single failing scenario' do
39
+ define_feature <<-FEATURE
40
+ Feature: Banana party
41
+
42
+ Scenario: Monkey eats banana
43
+ Given there are bananas
44
+ FEATURE
45
+
46
+ define_steps do
47
+ Given(/^there are bananas$/) do
48
+ raise 'Unable to create the bananas'
49
+ end
50
+ end
51
+
52
+ it 'outputs the failed step' do
53
+ expect(@out.string).to include "F(::) failed steps (::)\n"
54
+ end
55
+
56
+ it 'outputs the error "Unable to create the bananas (RuntimeError)"' do
57
+ message = 'Unable to create the bananas (RuntimeError)'
58
+ expect(@out.string).to include message
59
+ end
60
+
61
+ it 'should have 1 scenario and 1 failure' do
62
+ expect(@out.string).to include '1 scenario (1 failed)'
63
+ end
64
+ end
65
+
66
+ context 'with multiple scenarios' do
67
+ context 'and one failure' do
68
+ define_feature <<-FEATURE
69
+ Feature: Banana party
70
+
71
+ Scenario: Monkey eats banana
72
+ Given there are bananas
73
+ When he eats the bananas
74
+ Then the monkey should be happy
75
+
76
+ Scenario: Gorilla eats banana
77
+ Given there are bananas
78
+ When he eats the bananas
79
+ Then the gorilla should be happy
80
+
81
+ Scenario: Lion eats banana
82
+ Given there are bananas
83
+ When he eats the bananas
84
+ Then the lion should be happy
85
+
86
+ FEATURE
87
+
88
+ define_steps do
89
+ Given(/^there are bananas$/) { }
90
+ When(/^he eats the bananas$/) { }
91
+ Then(/^the (?:monkey|lion) should be happy$/) { }
92
+ Then(/^the gorilla should be happy$/) do
93
+ raise 'The Gorilla is unhappy : ('
94
+ end
95
+ end
96
+
97
+ it 'outputs the failed step' do
98
+ expect(@out.string).to include "F(::) failed steps (::)\n"
99
+ end
100
+
101
+ it 'outputs the error "The Gorilla is unhappy : ( (RuntimeError)"' do
102
+ message = 'The Gorilla is unhappy : ( (RuntimeError)'
103
+ expect(@out.string).to include message
104
+ end
105
+
106
+ it 'should have 3 scenarios, 1 failure and 2 passed' do
107
+ expect(@out.string).to include '3 scenarios (1 failed, 2 passed)'
108
+ end
109
+ end
110
+ context 'and multiple failures' do
111
+ define_feature <<-FEATURE
112
+ Feature: Banana party
113
+
114
+ Scenario: Monkey eats banana
115
+ Given there are bananas
116
+ When he eats the bananas
117
+ Then the monkey should be happy
118
+
119
+ Scenario: Gorilla eats banana
120
+ Given there are bananas
121
+ When he eats the bananas
122
+ Then the gorilla should be happy
123
+
124
+ Scenario: Lion eats banana
125
+ Given there are bananas
126
+ When he eats the bananas
127
+ Then the lion should be happy
128
+
129
+ FEATURE
130
+
131
+ define_steps do
132
+ Given(/^there are bananas$/) { }
133
+ When(/^he eats the bananas$/) { }
134
+ Then(/^the monkey should be happy$/) { }
135
+ Then(/^the gorilla should be happy$/) do
136
+ raise 'The Gorilla is unhappy : ('
137
+ end
138
+ Then(/^the lion should be happy$/) do
139
+ raise 'The Lion is unhappy too'
140
+ end
141
+ end
142
+
143
+ it 'outputs the failed step' do
144
+ expect(@out.string).to include "F(::) failed steps (::)\n"
145
+ end
146
+
147
+ it 'outputs the error "The Gorilla is unhappy : ( (RuntimeError)"' do
148
+ message = 'The Gorilla is unhappy : ( (RuntimeError)'
149
+ expect(@out.string).to include message
150
+ end
151
+
152
+ it 'outputs the error "The Lion is unhappy : ( (RuntimeError)"' do
153
+ message = 'The Lion is unhappy too (RuntimeError)'
154
+ expect(@out.string).to include message
155
+ end
156
+
157
+ it 'should have 3 scenarios, 2 failures and 1 passed' do
158
+ expect(@out.string).to include '3 scenarios (2 failed, 1 passed)'
159
+ end
160
+
161
+ it 'should not display duplicates' do
162
+ header = "F(::) failed steps (::)\n\n"
163
+
164
+ expected = "#{header}The Gorilla is unhappy : ( (RuntimeError)"
165
+ expect(@out.string).to include expected
166
+
167
+ expected = "#{header}The Lion is unhappy too (RuntimeError)"
168
+ expect(@out.string).to include expected
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,91 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ # config.filter_run :focus
51
+ # config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is
54
+ # recommended.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
58
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
59
+ # config.disable_monkey_patching!
60
+
61
+ # This setting enables warnings. It's recommended, but in some cases may
62
+ # be too noisy due to issues in dependencies.
63
+ # config.warnings = true
64
+
65
+ # Many RSpec users commonly either run the entire suite or an individual
66
+ # file, and it's useful to allow more verbose output when running an
67
+ # individual spec file.
68
+ # if config.files_to_run.one?
69
+ # # Use the documentation formatter for detailed output,
70
+ # # unless a formatter has already been configured
71
+ # # (e.g. via a command-line flag).
72
+ # config.default_formatter = 'doc'
73
+ # end
74
+
75
+ # Print the 10 slowest examples and example groups at the
76
+ # end of the spec run, to help surface which specs are running
77
+ # particularly slow.
78
+ # config.profile_examples = 10
79
+
80
+ # Run specs in random order to surface order dependencies. If you find an
81
+ # order dependency and want to debug it, you can fix the order by providing
82
+ # the seed, which is printed after each run.
83
+ # --seed 1234
84
+ # config.order = :random
85
+
86
+ # Seed global randomization in this process using the `--seed` CLI option.
87
+ # Setting this allows you to use `--seed` to deterministically reproduce
88
+ # test failures related to randomization by passing the same `--seed` value
89
+ # as the one that triggered the failure.
90
+ # Kernel.srand config.seed
91
+ end
@@ -0,0 +1,53 @@
1
+ module Cucumber
2
+ module Formatter
3
+ module SpecHelperDsl
4
+ attr_reader :feature_content, :step_defs, :feature_filename
5
+
6
+ def define_feature(string, feature_file = 'spec.feature')
7
+ @feature_content = string
8
+ @feature_filename = feature_file
9
+ end
10
+
11
+ def define_steps(&block)
12
+ @step_defs = block
13
+ end
14
+ end
15
+
16
+ module SpecHelper
17
+ def run_defined_feature
18
+ define_steps
19
+ features = load_features(self.class.feature_content ||
20
+ raise('No feature content defined!'))
21
+ run(features)
22
+ end
23
+
24
+ def step_mother
25
+ @step_mother ||= Runtime.new
26
+ end
27
+
28
+ def load_features(content)
29
+ feature_file = FeatureFile.new(self.class.feature_filename, content)
30
+ features = Ast::Features.new
31
+ filters = []
32
+ feature = feature_file.parse(filters, {})
33
+ features.add_feature(feature) if feature
34
+ features
35
+ end
36
+
37
+ def run(features)
38
+ configuration = Cucumber::Configuration.default
39
+ tree_walker = Cucumber::Ast::TreeWalker.new(step_mother, [@formatter],
40
+ configuration)
41
+ tree_walker.visit_features(features)
42
+ end
43
+
44
+ def define_steps
45
+ return unless step_defs = self.class.step_defs
46
+ rb = step_mother.load_programming_language('rb')
47
+ dsl = Object.new
48
+ dsl.extend RbSupport::RbDsl
49
+ dsl.instance_exec &step_defs
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-instafail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Guillaume Hain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cucumber-core
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Show failing features instantly. Show passing spec as green dots as usual.
98
+ Highly inspired by rspec-instafail from grosser (https://github.com/grosser).
99
+ email:
100
+ - zedtux@zedroot.org
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - cucumber-instafail.gemspec
112
+ - lib/cucumber/instafail.rb
113
+ - lib/cucumber/instafail/formatter/progress_instafail.rb
114
+ - lib/cucumber/instafail/version.rb
115
+ - spec/cucumber/instafail/formatter/progress_instafail_spec.rb
116
+ - spec/spec_helper.rb
117
+ - spec/support/cucumber_spec_helper.rb
118
+ homepage: https://github.com/zedtux/cucumber-instafail
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Show failing features instantly
142
+ test_files:
143
+ - spec/cucumber/instafail/formatter/progress_instafail_spec.rb
144
+ - spec/spec_helper.rb
145
+ - spec/support/cucumber_spec_helper.rb