How to use report_error method of Spinach Package

Best Spinach_ruby code snippet using Spinach.report_error

error_reporting_test.rb

Source:error_reporting_test.rb Github

copy

Full Screen

...24 )25 end26 describe '#error_summary' do27 it 'prints a summary with all the errors' do28 @reporter.expects(:report_error_steps).once29 @reporter.expects(:report_failed_steps).once30 @reporter.expects(:report_undefined_steps).once31 @reporter.expects(:report_undefined_features).once32 @reporter.expects(:report_pending_steps).once33 @reporter.error_summary34 @error.string.must_include 'Error summary'35 end36 end37 describe '#run_summary' do38 it 'prints a run summary' do39 @reporter.run_summary40 @out.string.must_include 'Steps Summary:'41 end42 end43 describe '#report_error_steps' do44 describe 'when some steps have raised an error' do45 it 'outputs the errors' do46 steps = [anything]47 @reporter.stubs(:error_steps).returns(steps)48 @reporter.expects(:report_errors).with('Errors', steps, :light_red)49 @reporter.report_error_steps50 end51 end52 describe 'when there are no error steps' do53 it 'does nothing' do54 @reporter.expects(:report_errors).never55 @reporter.report_error_steps56 end57 end58 end59 describe '#report_failed_steps' do60 describe 'when some steps have failed' do61 it 'outputs the failing steps' do62 steps = [anything]63 @reporter.stubs(:failed_steps).returns(steps)64 @reporter.expects(:report_errors).with('Failures', steps, :light_red)65 @reporter.report_failed_steps66 end67 end68 describe 'when there are no failed steps' do69 it 'does nothing' do70 @reporter.expects(:report_errors).never71 @reporter.report_failed_steps72 end73 end74 end75 describe '#report_undefined_steps' do76 describe 'when some steps have undefined' do77 it 'outputs the failing steps' do78 steps = [anything]79 @reporter.stubs(:undefined_steps).returns(steps)80 @reporter.expects(:report_errors).with('Undefined steps', steps, :red)81 @reporter.report_undefined_steps82 end83 end84 describe 'when there are no undefined steps' do85 it 'does nothing' do86 @reporter.expects(:report_errors).never87 @reporter.report_undefined_steps88 end89 end90 end91 describe '#report_pending_steps' do92 describe 'when some steps have pending' do93 it 'outputs the pending steps' do94 steps = [anything]95 @reporter.stubs(:pending_steps).returns(steps)96 @reporter.expects(:report_errors).with('Pending steps', steps, :yellow)97 @reporter.report_pending_steps98 end99 end100 describe 'when there are no pending steps' do101 it 'does nothing' do102 @reporter.expects(:report_errors).never103 @reporter.report_pending_steps104 end105 end106 end107 describe '#report_undefined_features' do108 describe 'when some features are undefined' do109 it 'outputs the undefined features' do110 @reporter.undefined_features << stub(name: 'Undefined feature name')111 @reporter.report_undefined_features112 @error.string.must_include "Undefined features (1)"113 @error.string.must_include "Undefined feature name"114 end115 end116 describe 'when there are no undefined features' do117 it 'does nothing' do118 error = @error.string.dup119 @reporter.report_undefined_steps120 error.must_equal @error.string121 end122 end123 end124 describe '#report_errors' do125 describe 'when some steps have raised an error' do126 it 'outputs a the banner with the number of steps given' do127 @reporter.report_errors('Banner', steps, :blue)128 @error.string.must_include 'Banner (1)'129 end130 it 'prints a summarized error' do131 @reporter.report_errors('Banner', steps, :blue)132 @error.string.must_include 'My feature :: A scenario :: Keyword step name'133 end134 it 'colorizes the output' do135 String.any_instance.expects(:colorize).with(:blue).at_least_once136 @reporter.report_errors('Banner', [], :blue)137 end138 end139 end140 describe '#report_error' do141 it 'raises when given an unsupported format' do142 proc {143 @reporter.report_error(error, :nil)144 }.must_raise RuntimeError, 'Format not defined'145 end146 it 'prints a summarized error by default' do147 @reporter.expects(:summarized_error).with(error).returns('summarized error')148 @reporter.report_error(error)149 @error.string.must_include 'summarized error'150 end151 it 'prints a summarized error' do152 @reporter.expects(:summarized_error).with(error).returns('summarized error')153 @reporter.report_error(error, :summarized)154 @error.string.must_include 'summarized error'155 end156 it 'prints a full error' do157 @reporter.expects(:full_error).with(error).returns('full error')158 @reporter.report_error(error, :full)159 @error.string.must_include 'full error'160 end161 end162 describe '#summarized_error' do163 it 'prints the error' do164 summary = @reporter.summarized_error(error)165 summary.must_include 'My feature :: A scenario :: Keyword step name'166 end167 it 'colorizes the print' do168 String.any_instance.expects(:red)169 @reporter.summarized_error(error)170 end171 describe 'when given an undefined step exception' do172 it 'prints the error in red' do...

Full Screen

Full Screen

stdout_test.rb

Source:stdout_test.rb Github

copy

Full Screen

...40 before do41 @reporter.scenario_error = exception42 end43 it 'reports the full error' do44 @reporter.expects(:report_error).with(exception, :full)45 @reporter.after_scenario_run('name' => 'Arbitrary scenario')46 end47 it 'resets the scenario error' do48 @reporter.stubs(:report_error)49 @reporter.after_scenario_run('name' => 'Arbitrary scenario')50 @reporter.scenario_error.must_equal nil51 end52 end53 end54 describe '#on_successful_step' do55 let(:step) { stub(keyword: 'Given', name: 'I am too cool') }56 let(:step_location){['error_step_location', 1]}57 let(:step_definitions){ stub }58 it 'adds the step to the output buffer' do59 @reporter.on_successful_step(step, step_location)60 @out.string.must_include '✔'61 @out.string.must_include 'Given'62 @out.string.must_include 'am too cool'...

Full Screen

Full Screen

reporting.rb

Source:reporting.rb Github

copy

Full Screen

...11 # Prints the errors for this run.12 #13 def error_summary14 error.puts "\nError summary:\n"15 report_error_steps16 report_failed_steps17 report_undefined_features18 report_undefined_steps19 report_pending_steps20 end21 def report_error_steps22 report_errors('Errors', error_steps, :light_red) if error_steps.any?23 end24 def report_failed_steps25 report_errors('Failures', failed_steps, :light_red) if failed_steps.any?26 end27 def report_undefined_steps28 if undefined_steps.any?29 error.puts "\nUndefined steps summary:\n"30 report_errors('Undefined steps', undefined_steps, :red)31 end32 end33 def report_pending_steps34 if pending_steps.any?35 error.puts "\nPending steps summary:\n"36 report_errors('Pending steps', pending_steps, :yellow)37 end38 end39 def report_undefined_features40 if undefined_features.any?41 error.puts " Undefined features (#{undefined_features.length})".red42 undefined_features.each do |feature|43 error.puts " #{feature.name}".red44 end45 end46 end47 # Prints the error for a given set of steps48 #49 # @param [String] banner50 # the text to prepend as the title51 #52 # @param [Array] steps53 # the steps to output54 #55 # @param [Symbol] color56 # The color code to use with Colorize to colorize the output.57 #58 def report_errors(banner, steps, color)59 error.puts " #{banner} (#{steps.length})".colorize(color)60 steps.each do |error|61 report_error error62 end63 error.puts ""64 end65 # Prints an error in a nice format66 #67 # @param [Array] error68 # An array containing the feature, scenario, step and exception69 #70 # @param [Symbol] format71 # The format to output the error. Currently supproted formats are72 # :summarized (default) and :full73 #74 # @return [String]75 # The error report76 #77 def report_error(error, format=:summarized)78 case format79 when :summarized80 self.error.puts summarized_error(error)81 when :full82 self.error.puts full_error(error)83 else84 raise "Format not defined"85 end86 end87 # Returns summarized error report88 #89 # @param [Array] error90 # An array containing the feature, scenario, step and exception91 #...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Spinach_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful