Jim Morris
2008-Jul-08 05:36 UTC
[rspec-users] is there a plain format output for stories?
When running a lot of stories from a script it would be nice to have the plain format of dots rather than the verbose story descriptions. Is there a way to do this? I tried -f p but it ignored it. Thanks -- Jim Morris, http://blog.wolfman.com
Jim Morris wrote:> When running a lot of stories from a script it would be nice to have > the plain format of dots rather than the verbose story descriptions. > > Is there a way to do this? I tried -f p but it ignored it. > > Thanks >AFAIK there is currently no such formatter. Such a formatter would be easy to make though and you can pass in the formatter you want to use on the command line (even custom classes that you create.) To get an idea of how to do it you can look at the rspec source code in lib/spec/runner/formatter. The formatter for the examples can be found there and the story formatter''s are in the story subdir. -Ben
David Salgado
2008-Jul-09 15:16 UTC
[rspec-users] is there a plain format output for stories?
I''ve created a very simple ''basic'' formatter, than prints story scenarios as . / P / F for passing, pending and failing scenarios. You can get it here; http://github.com/digitalronin/rspec/tree/master Run it by appending " --format=basic " to the command-line when running your stories. Hope it''s useful David On Jul 8, 4:11 pm, Ben Mabey <b... at benmabey.com> wrote:> Jim Morris wrote: > > When running a lot of stories from a script it would be nice to have > > the plain format of dots rather than the verbose story descriptions. > > > Is there a way to do this? I tried -f p but it ignored it. > > > Thanks > > AFAIK there is currently no such formatter. Such a formatter would be > easy to make though and you can pass in the formatter you want to use on > the command line (even custom classes that you create.) To get an idea > of how to do it you can look at the rspec source code in > lib/spec/runner/formatter. The formatter for the examples can be found > there and the story formatter''s are in the story subdir. > > -Ben > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080709/465c4975/attachment.html>
Jim Morris
2008-Jul-09 19:55 UTC
[rspec-users] is there a plain format output for stories?
David Salgado wrote:> I''ve created a very simple ''basic'' formatter, than prints story > scenarios as . / P / F for passing, pending and failing scenarios. You > can get it here; > > http://github.com/digitalronin/rspec/tree/master > > Run it by appending " --format=basic " to the command-line when running > your stories. >Thanks, that is pretty simple. I knocked up this one, which shows progress like the progress for examples. I just put it in my spec_helper.rb and do --format ProgressFormatter require ''spec/runner/formatter/base_text_formatter'' class ProgressFormatter < Spec::Runner::Formatter::BaseTextFormatter def initialize(options, where) super @successful_scenario_count = 0 @pending_scenario_count = 0 @failed_scenarios = [] @pending_steps = [] @previous_type = nil end def run_started(count) @count = count end def story_started(title, narrative) @current_story_title = title @output.print ''['' @output.flush end def story_ended(title, narrative) @output.puts '']'' end def scenario_started(story_title, scenario_name) @current_scenario_name = scenario_name @scenario_already_failed = false end def scenario_succeeded(story_title, scenario_name) @successful_scenario_count += 1 @output.print ''*'' @output.flush end def scenario_failed(story_title, scenario_name, err) @options.backtrace_tweaker.tweak_backtrace(err) @failed_scenarios << [story_title, scenario_name, err] unless @scenario_already_failed @scenario_already_failed = true @output.print ''F'' @output.flush end def scenario_pending(story_title, scenario_name, msg) @pending_scenario_count += 1 unless @scenario_already_failed @scenario_pending = true @scenario_already_failed = true @output.print ''P'' @output.flush end def run_ended @output.print "#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending" unless @pending_steps.empty? @output.print "\nPending Steps:" @pending_steps.each_with_index do |pending, i| story_name, scenario_name, msg = pending @output.print "#{i+1}) #{story_name} (#{scenario_name}): #{msg}" end end unless @failed_scenarios.empty? @output.print "\nFAILURES:" @failed_scenarios.each_with_index do |failure, i| title, scenario_name, err = failure @output.print %[ #{i+1}) #{title} (#{scenario_name}) FAILED #{err.class}: #{err.message} #{err.backtrace.join("\n")} ] end end @output.puts "" end def step_upcoming(type, description, *args) end def step_succeeded(type, description, *args) @output.print ''.'' @output.flush end def step_pending(type, description, *args) @pending_steps << [@current_story_title, @current_scenario_name, description] @output.print ''p'' @output.flush @scenario_pending = true @scenario_ok = false end def step_failed(type, description, *args) @output.print ''f'' @output.flush @scenario_ok = false end def collected_steps(steps) end def method_missing(sym, *args, &block) #:nodoc: # noop - ignore unknown messages end end -- Jim Morris, http://blog.wolfman.com