class Crabfarm::Live::NavigatorRunnerRSpec
Attributes
example[R]
Public Class Methods
new(_manager, _target)
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 10 def initialize(_manager, _target) @manager = _manager @target = _target end
Public Instance Methods
execute()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 15 def execute @example = Utils::RSpecRunner.run_single_spec_for spec_for(@target), :live bubble_standard_errors end
show_results()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 20 def show_results if example.nil? show_empty_warning else show_example_output end end
Private Instance Methods
bubble_standard_errors()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 74 def bubble_standard_errors if example and example.exception and not example.exception.is_a? expectation_error raise example.exception end end
console()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 84 def console Utils::Console end
expectation_error()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 80 def expectation_error ::RSpec::Expectations::ExpectationNotMetError end
show_empty_warning()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 37 def show_empty_warning @manager.show_message( :warning, "No examples were found!", "You will need to write at least one spec for #{@target.to_s}" ) console.warning 'No examples were found!' end
show_example_output()
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 47 def show_example_output if example.exception @manager.show_message( :error, 'FAILED', example.exception.to_s, example.metadata[:result].to_json, :json ) console.error "Example \"#{example.full_description}\" failed (line: #{example.metadata[:line_number]})" console.error example.exception.to_s console.json_result example.metadata[:result] else @manager.show_message( :success, 'SUCCESS', "\"#{example.full_description}\"", example.metadata[:result].to_json, :json ) console.result "Example \"#{example.full_description}\" passed (line: #{example.metadata[:line_number]})" console.json_result example.metadata[:result] end end
spec_for(_class)
click to toggle source
# File lib/crabfarm/live/navigator_runner_rspec.rb, line 30 def spec_for(_class) route = Utils::Naming.route_from_constant(_class.to_s) route = route.join(File::SEPARATOR) route = route + '_spec.rb' File.join('spec','navigators', route) end