(asked this yesterday on #rspec, no response…)
Am I missing something obvious about --pattern? It seems to only run
the first spec that matches the pattern; I expected it to run all that
match.
I tried:
spec spec/models --pattern line_item
spec spec/models --pattern *line_item*
spec spec/models --pattern ‘line_item’
all to no avail…
Maybe I’ll go look at the source. That would be a concept.
dwh
On Wed, Sep 23, 2009 at 9:46 AM, Denis H. [email protected]
wrote:
all to no avail…
The pattern is passed to Dir.glob, referenced from the ./spec
directory in the project. It needs to be in the correct format given
those considerations. The three variations you tried all look for
files matching line_item in the ./spec directory, not its
subdirectories. Try this:
spec spec/models --pattern “**/line_item*”
Aah… thank you.
It looks like what I really want is --example (I want to be able to run
a selected few examples). But that also seems to have some weirdess:
$ spec spec/models --example spec/models/discount_spec.rb
Finished in 1.527043 seconds
0 examples, 0 failures
I can see from the log that application initialization is happening, but
none of the examples are being run.
Suggestions?
Thanks,
dwh
On Wed, Sep 23, 2009 at 1:24 PM, Denis H. [email protected]
wrote:
none of the examples are being run.
Suggestions?
spec --help
Cheers,
David
Reverse-engineering with --format e, it turns out --example is the
whole example name, e.g.
“LineItem should allow a offer code to be associated with it”
So is there any easy way to run just a few files?
Thx,
dwh
On Wed, Sep 23, 2009 at 2:00 PM, Denis H. [email protected]
wrote:
Reverse-engineering with --format e, it turns out --example is the whole
example name, e.g.
“LineItem should allow a offer code to be associated with it”
So is there any easy way to run just a few files?
Right now there is not, though there will be better ways in the
future. For now, the best thing to do is probably set up a rake task.
The --pattern option can take a comma separated list of patterns, so
you can just list out the files you want.
You can also set up the rake task so it gets the pattern list from a
file that lists the files you want one per line. Something like:
Spec::Rake::SpecTask.new(:focused) do |t|
t.spec_files = File.readlines(‘spec_files.txt’).collect{|f| f.strip}
end
Then you can run ‘rake spec:focused’ and just copy the file names you
want into spec_files.txt. That’s probably the lowest overhead because
it’s easy to change what you’re running but then stay focused on that
set of files until you’re ready to change.
HTH,
David