how to run a spec file with ruby without spec?
How do i inherit the spec base class to the current ruby spec file?
how to run a spec file with ruby without spec?
How do i inherit the spec base class to the current ruby spec file?
I think all you need are the files required in the spec_helper.rb you should be able to call the specs with
ruby -Ispec my_spec.rb #=> assuming you have a spec folder and there is a spec helper inside.
That's two questions.
1) "how to run a spec file with ruby without spec?"
either put
require "rubygems"
require "spec"
require "spec/autorun"
in the file, or run
ruby -rrubygems -rspec -rspec/autorun whatever_spec.rb
from the command line. But spec
is easier.
2) "How do i inherit the spec base class to the current ruby spec file?"
Basically, you don't. RSpec is an internal DSL which means that it generates objects for you based on your describe
and it
blocks. These objects are instances of real classes (e.g. Spec::Example::ExampleGroup
), but they're very complicated and magical and you shouldn't try to extend them unless you really know what you're doing. What are you trying to accomplish?