Ruby file.spec?

perhaps this has been discussed before and you can point me to the
right thread, but is it possible to run specs from the command line
using just ruby?
ruby arguments_spec.rb

and it “just run” (like test/unit seems to)?

I can’t think of a great reason why this would be useful, other than
not having to remember which command is which to run files–you only
have to type “ruby” (and IDE’s that aren’t spec aware would be easier
to run with).

Thanks!
-r

On Thu, Nov 12, 2009 at 7:34 PM, rogerdpack [email protected]
wrote:

to run with).
You want to use “spec” to run files directly. If you have your heart
set on running files from “ruby” then you’ll need to load
“spec/autorun” to actually execute the specs. Note using the following
will not work on ruby 1.8.x (see thread
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/334942 )
but it should work on 1.9.x.
ruby -rubygems -rspec -rspec/autorun file_spec.rb


Zach D.
http://www.continuousthinking.com (personal)
http://www.mutuallyhuman.com (hire me)
http://ideafoundry.info/behavior-driven-development (first rate BDD
training)
@zachdennis (twitter)

On Thu, Nov 12, 2009 at 8:36 PM, Zach D. [email protected]
wrote:

You want to use “spec” to run files directly. If you have your heart
set on running files from “ruby” then you’ll need to load
“spec/autorun” to actually execute the specs.

After giving the original querent a hard time, it surprises me to have
to tell you that you’re wrong. At least if you’re running any spec
file written with the typical Railsish convention of requiring
‘spec_helper.rb’ at the top. If for some reason you have spec files
that don’t require the framework one way or another, you’d be
correct, but…why wouldn’t you? Otherwise, it works fine.

(How do I know? I went into one of my projects, then into a spec
directory, and typed ‘ruby user_spec.rb’ and watched it work. At
first I didn’t think that trying things before posting to a mailing
list about them was an extraordinary act, but now I’m wondering if I
ought to get a medal for courage.)


Have Fun,
Steve E. ([email protected])
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org

On Thu, Nov 12, 2009 at 7:34 PM, rogerdpack [email protected]
wrote:

perhaps this has been discussed before and you can point me to the
right thread, but is it possible to run specs from the command line
using just ruby?
ruby arguments_spec.rb

and it “just run” (like test/unit seems to)?

What happens when you try it?

(You do have the power to experiment, you know. You don’t need
permission.)


Have Fun,
Steve E. ([email protected]nvalid)
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org

On Thu, Nov 12, 2009 at 10:28 PM, Stephen E. [email protected] wrote:

that don’t require the framework one way or another, you’d be
correct, but…why wouldn’t you? Otherwise, it works fine.

And in that case spec_helper.rb still needs to load spec/autorun for
this to work.

Steve E. ([email protected])
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org


Zach D.
http://www.continuousthinking.com (personal)
http://www.mutuallyhuman.com (hire me)
http://ideafoundry.info/behavior-driven-development (first rate BDD
training)
@zachdennis (twitter)

What happens when you try it?

(You do have the power to experiment, you know. You don’t need permission.)

C:\dev\ruby\old\arguments\spec>ruby arguments_spec.rb
arguments_spec.rb:5: undefined method `describe’ for main:Object
(NoMethodError)

or adding a
require ‘spec’
in there

C:\dev\ruby\old\arguments\spec>ruby arguments_spec.rb

C:\dev\ruby\old\arguments\spec> # (it output nothing)

adding
require ‘spec/autorun’ worked like a champ, however.

It’s not clear from the github wiki where I would submit such a tidbit
of information. Also is there a link to rdoc’s somewhere?
Thanks!

-r