[rspec-devel] Multiple formatters

aslak hellesoy aslak.hellesoy at gmail.com
Wed May 2 20:22:44 EDT 2007


On 5/3/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>
> On May 1, 2007, at 8:14 AM, Scott Taylor wrote:
>
> >
> > On May 1, 2007, at 7:45 AM, aslak hellesoy wrote:
> >
> >> On 5/1/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> >>>
> >>> On Apr 24, 2007, at 4:41 AM, aslak hellesoy wrote:
> >>>
> >>>> Hi all,
> >>>>
> >>>> RSpec supports multiple formatters, but currently you can only
> >>>> use one
> >>>> at a time. I really need to use several at the same time.
> >>>>
> >>>> I'd like to make RSpec handle several --format options. However,
> >>>> that
> >>>> would require some rethinking of how/where output is written - it
> >>>> can't all go to the same stream (file or stdout).
> >>>>
> >>>> So I'm thinking of making --format take a composite argument:
> >>>>
> >>>> --format html:/path/to/index.html --format rdoc:/path/to/index.rdoc
> >>>> --format progress
> >>>>
> >>>> If nothing comes after the format, output is STDOUT, so this
> >>>> would be
> >>>> backwards compatible.
> >>>>
> >>>> If we do this, we could also get rid of --failures - it would
> >>>> just be
> >>>> a special formatter.
> >>>>
> >>>> WDYT?
> >>>> _______________________________________________
> >>>> rspec-devel mailing list
> >>>> rspec-devel at rubyforge.org
> >>>> http://rubyforge.org/mailman/listinfo/rspec-devel
> >>>
> >>>
> >>> I've seen that you've already implemented this in trunk.
> >>>
> >>> I'm not running the latest version of trunk, but I've noticed
> >>> that in
> >>> 0.9RC1, when specifying a failures file and an examples file, that
> >>> the following behavior is exhibited by rspec:
> >>>
> >>> 1. If the file exists, but is empty, rspec will run all specs
> >>> 2. If the file exists, but contains failing examples, these failing
> >>> specs will be run
> >>> 3. If the file does not exists, it creates the file (through --
> >>> failures  - now --format e:filename), but runs no specs.
> >>>
> >>> Would a patch addressing the third case (which would mimic the first
> >>> case) be a welcome addition to rspec?
> >>>
> >>
> >> It would, but how do you suggest that RSpec guesses that you meant a
> >> file, and not the name of a behaviour or example?
> >
> > I would assume that this would be the case if:
> >
> > 1. There is a failing examples or failing behavior formatter, with at
> > @where != out
> > 2. and that an "example" has the same name as the formatter's @where
> > 3. (and of course)...that the examples/failures file does not yet
> > exist
> >
> > In this case, the example could just be removed from the list.
> > Obviously this must go on after the ::OptionParser#parse method is
> > called.
> >
> > So tell me if I'm missing something obvious, but it would seem very
> > strange if one chose a failures file with the same name as an
> > example, wouldn't it?  It could be done, but who ever dream of doing
> > so?  Who would create a file with a name like "should do such and
> > such" as the name of their failures file?
>

I don't think anyone would create a file named "should this and that",
but currently the --example option is used both for files and
behaviour names. RSpec will read the file if it exists, otherwise it
will assume it's a behaviour name.

>
> Do you think it would be acceptable to remove the appropriate example
> when the File is empty?
>

When the file is empty, all specs will run. It will behave as if you
didn't specify --example at all. But maybe I'm misunderstanding what
you mean by remove.

How would you like RSpec to figure out by itself that --example
foo_bar refers to a file when foo_bar doesn't exist? Would it make
sense to add logic so that it will only be assumed to be a file
(existant or not) if it ends with .txt?

Aslak

> Scott
>
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list