Forum: RSpec Running single spec files -- how?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F7d94c4c159ec28690c0190bbd304ec4?d=identicon&s=25 court3nay (Guest)
on 2009-05-12 01:11
(Received via mailing list)
Before upgrading from 1.1.11 to 1.2.4 I used to be able to do this:

  ruby spec/models/user_spec.rb

Now it looks like you have to do

  script/spec spec/models/user_spec.rb

Or something like this, which is actually kinda cool:

  script/spec spec/*/user*

Is that correct? Am I missing something?
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2009-05-12 01:18
(Received via mailing list)
court3nay wrote:
>   script/spec spec/*/user*
>
> Is that correct? Am I missing something?
>

There was a change that broke this behaviour, but it was documented in
the History and how to get back the old behaviour:

=== Version 1.2.0 / 2009-03-15

* warnings:

  * If you use the ruby command to run specs instead of the spec
command, you'll
    need to require 'spec/autorun' or they won't run. This won't affect
you if
    you use the spec command or the Spec::Rake::SpecTask that ships with
RSpec.



So... just add a require 'spec/autorun' in your spec_helper.rb and you
should be good to go.

HTH,

Ben
369b9fd2a0d9e7cdbc60907a2a056ad9?d=identicon&s=25 Scott Taylor (Guest)
on 2009-05-12 01:18
(Received via mailing list)
On May 11, 2009, at 7:10 PM, court3nay wrote:

> Before upgrading from 1.1.11 to 1.2.4 I used to be able to do this:
>
>  ruby spec/models/user_spec.rb

I would assume that would work if you are requiring test-unit interop
mode.  I believe in previous versions of rspec it was automatically
included if the constants Test && Test::Unit were present (which AR
automatically adds once AR is required).

> Is that correct? Am I missing something?
I've always kept around this alias:

alias ss='./script/spec -O spec/spec.opts'

So I can do:

ss spec/unit/models/event_*

Scott
This topic is locked and can not be replied to.