spinach_file_reporter 0.0.1.1

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: 3c36e9f36eae4d906bd88a0897b52fcec867b91c
4
+ data.tar.gz: 4caf81fb55686887ba8846a1a91e376207fb4da9
5
+ SHA512:
6
+ metadata.gz: 32e5e1575393a586c34257e3158cde8d42b39dd077770368e2367148980f314712be56f85cf2895bf168cc404c7c871eb620b332efd8688378cf13c40610bc46
7
+ data.tar.gz: 232be7b501e2768cbae08f746f0da3e1c2d0b024b139c72656c6c0d61bc86538cba56edfcc5cd2ea7435361485312ed8c5bce45d5e8383eb986d9033de77b768
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yi Wen
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,34 @@
1
+ # spinach_file_reporter
2
+ Gem version: 0.0.1
3
+
4
+ Reporter for Spinach tests. This reports to console and into a file.
5
+ File is saved under tmp/spinach_errors.txt
6
+
7
+ This is a reporter that meant to use on Jenkins, combined with (https://github.com/dblock/jenkins-ansicolor-plugin) to bring the color output to Jenkins console.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'spinach-file-reporter'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install spinach-file-reporter
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ $ bundle exec spinach -r file_reporter
27
+ ```
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
@@ -0,0 +1,16 @@
1
+ module Spinach
2
+ module FileReporter
3
+ module Reporter
4
+ module GemDescription
5
+ class << self
6
+ def to_s
7
+ <<-EOF
8
+ This is a console and file reporter for spinach. It works like output reporter of
9
+ spinach and add a file reporter of the errors to a file
10
+ EOF
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,203 @@
1
+ # encoding: utf-8
2
+ module Spinach
3
+ class Reporter
4
+ # The Stdout reporter outputs the runner results to the standard output
5
+ #
6
+ class FileReporter < Reporter
7
+ include Reporting
8
+
9
+ # Initialitzes the runner
10
+ #
11
+ # @param [Hash] options
12
+ # Sets a custom output buffer by setting options[:output]
13
+ # Sets a custom error buffer by setting options[:error]
14
+ #
15
+ def initialize(*args)
16
+ super(*args)
17
+ @out = options[:output] || $stdout
18
+ @error = options[:error] || $stderr
19
+ @max_step_name_length = 0
20
+ @file_errors = []
21
+ end
22
+
23
+ def after_run(success)
24
+ if !success
25
+ file = File.new("tmp/spinach_errors.txt", "w")
26
+ file.puts @file_errors.uniq.join(' ')
27
+ file.close
28
+ else
29
+ File.delete("tmp/spinach.txt")
30
+ end
31
+ end
32
+
33
+ # Prints the feature name to the standard output
34
+ #
35
+ # @param [Hash] data
36
+ # The feature in a JSON GherkinRubyRuby format
37
+ #
38
+ def before_feature_run(feature)
39
+ name = feature.name
40
+ out.puts "\n#{'Feature:'.magenta} #{name.light_magenta}"
41
+ end
42
+
43
+ # Prints the scenario name to the standard ouput
44
+ #
45
+ # @param [Hash] data
46
+ # The feature in a JSON GherkinRubyRuby format
47
+ #
48
+ def before_scenario_run(scenario, step_definitions = nil)
49
+ @max_step_name_length = scenario.steps.map(&:name).map(&:length).max if scenario.steps.any?
50
+ name = scenario.name
51
+ out.puts "\n #{'Scenario:'.green} #{name.light_green}"
52
+ end
53
+
54
+ # Adds an error report and re
55
+ #
56
+ # @param [Hash] data
57
+ # The feature in a JSON GherkinRubyRuby format
58
+ #
59
+ def after_scenario_run(scenario, step_definitions = nil)
60
+ if scenario_error
61
+ report_error(scenario_error, :full)
62
+ self.scenario_error = nil
63
+ end
64
+ end
65
+
66
+ # Adds a passed step to the output buffer.
67
+ #
68
+ # @param [Step] step
69
+ # The step.
70
+ #
71
+ # @param [Array] step_location
72
+ # The step source location
73
+ #
74
+ def on_successful_step(step, step_location, step_definitions = nil)
75
+ output_step('✔', step, :green, step_location)
76
+ self.scenario = [current_feature, current_scenario, step]
77
+ successful_steps << scenario
78
+ end
79
+
80
+ # Adds a failing step to the output buffer.
81
+ #
82
+ # @param [Hash] step
83
+ # The step in a JSON GherkinRubyRuby format
84
+ #
85
+ # @param [Exception] failure
86
+ # The exception that caused the failure
87
+ #
88
+ def on_failed_step(step, failure, step_location, step_definitions = nil)
89
+ output_step('✘', step, :red, step_location)
90
+ self.scenario_error = [current_feature, current_scenario, step, failure]
91
+ feature = step_location[0].split( '/' ).last.split('.').first
92
+ @file_errors.push( "features/#{feature}.feature") if step_location
93
+ failed_steps << scenario_error
94
+ end
95
+
96
+ # Adds a step that has raised an error to the output buffer.
97
+ #
98
+ # @param [Hash] step
99
+ # The step in a JSON GherkinRubyRuby format
100
+ #
101
+ # @param [Exception] failure
102
+ # The exception that caused the failure
103
+ #
104
+ def on_error_step(step, failure, step_location, step_definitions = nil)
105
+ output_step('!', step, :red, step_location)
106
+ feature = step_location[0].split( '/' ).last.split('.').first
107
+ self.scenario_error = [current_feature, current_scenario, step, failure]
108
+ error_steps << scenario_error
109
+ end
110
+
111
+ # Adds an undefined step to the output buffer.
112
+ #
113
+ # @param [Hash] step
114
+ # The step in a JSON GherkinRubyRuby format
115
+ #
116
+ def on_undefined_step(step, failure, step_definitions = nil)
117
+ output_step('?', step, :red)
118
+ self.scenario_error = [current_feature, current_scenario, step, failure]
119
+ undefined_steps << scenario_error
120
+ end
121
+
122
+ # Adds an undefined step to the output buffer.
123
+ #
124
+ # @param [Hash] step
125
+ # The step in a JSON GherkinRubyRuby format
126
+ #
127
+ def on_pending_step(step, failure)
128
+ output_step('P', step, :yellow)
129
+ self.scenario_error = [current_feature, current_scenario, step, failure]
130
+ pending_steps << scenario_error
131
+ end
132
+
133
+ # Adds a feature not found message to the output buffer.
134
+ #
135
+ # @param [Hash] feature
136
+ # the feature in a json gherkin format
137
+ #
138
+ # @param [Spinach::FeatureNotFoundException] exception
139
+ # the related exception
140
+ #
141
+ def on_feature_not_found(feature)
142
+ generator = Generators::FeatureGenerator.new(feature)
143
+ lines = "Could not find steps for `#{feature.name}` feature\n\n"
144
+ lines << "\nPlease create the file #{generator.filename} at #{generator.path}, with:\n\n"
145
+
146
+ lines << generator.generate
147
+
148
+ lines.split("\n").each do |line|
149
+ out.puts " #{line}".red
150
+ end
151
+ out.puts "\n\n"
152
+
153
+ undefined_features << feature
154
+ end
155
+
156
+ # Adds a step that has been skipped to the output buffer.
157
+ #
158
+ # @param [Hash] step
159
+ # The step that GherkinRubyRuby extracts
160
+ #
161
+ def on_skipped_step(step, step_definitions = nil)
162
+ output_step('~', step, :cyan)
163
+ end
164
+
165
+ # Adds to the output buffer a step result
166
+ #
167
+ # @param [String] symbol
168
+ # A symbol to prepend before the step keyword (might be useful to
169
+ # indicate if everything went ok or not).
170
+ #
171
+ # @param [Hash] step
172
+ # The step in a JSON GherkinRubyRuby format
173
+ #
174
+ # @param [Symbol] color
175
+ # The color code to use with Colorize to colorize the output.
176
+ #
177
+ # @param [Array] step_location
178
+ # step source location and file line
179
+ #
180
+ def output_step(symbol, step, color, step_location = nil)
181
+ step_location = step_location.first.gsub("#{File.expand_path('.')}/", '# ')+":#{step_location.last.to_s}" if step_location
182
+ max_length = @max_step_name_length + 60 # Colorize and output format correction
183
+
184
+ # REMEMBER TO CORRECT PREVIOUS MAX LENGTH IF OUTPUT FORMAT IS MODIFIED
185
+ buffer = []
186
+ buffer << indent(4)
187
+ buffer << symbol.colorize(:"light_#{color}")
188
+ buffer << indent(2)
189
+ buffer << step.keyword.colorize(:"light_#{color}")
190
+ buffer << indent(1)
191
+ buffer << step.name.colorize(color)
192
+ joined = buffer.join.ljust(max_length)
193
+
194
+ out.puts(joined + step_location.to_s.colorize(:grey))
195
+ end
196
+
197
+ private
198
+ def indent(n = 1)
199
+ " " * n
200
+ end
201
+ end
202
+ end
203
+ end
@@ -0,0 +1 @@
1
+ require_relative "spinach_file_reporter/spinach_file_reporter"
Binary file
@@ -0,0 +1,18 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "spinach_file_reporter/gem_description"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'spinach_file_reporter'
6
+ s.version = '0.0.1.1'
7
+ s.date = '2015-07-24'
8
+ s.summary = 'Reporter for spinach with file output'
9
+ s.description = Spinach::FileReporter::Reporter::GemDescription.to_s
10
+ s.authors = ["JuanMa Jurado"]
11
+ s.email = "JuanMa Jurado"
12
+ s.license = 'MIT'
13
+ s.files = `git ls-files`.split($\)
14
+ s.require_paths = ["lib"]
15
+ s.homepage = 'https://github.com/jmjurado23/spinach_file_reporter'
16
+
17
+ s.add_runtime_dependency(%q<spinach>, '~>0.4')
18
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spinach_file_reporter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - JuanMa Jurado
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: spinach
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.4'
27
+ description: |2
28
+ This is a console and file reporter for spinach. It works like output reporter of
29
+ spinach and add a file reporter of the errors to a file
30
+ email: JuanMa Jurado
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - lib/spinach_file_reporter.rb
38
+ - lib/spinach_file_reporter/gem_description.rb
39
+ - lib/spinach_file_reporter/spinach_file_reporter.rb
40
+ - spinach_file_reporter-0.0.1.gem
41
+ - spinach_file_reporter.gemspec
42
+ homepage: https://github.com/jmjurado23/spinach_file_reporter
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.2.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Reporter for spinach with file output
66
+ test_files: []