[rspec-users] [RSPEC] [CUCUMBER] have autotest running *only* the features

Jean-Michel Garnier jean-michel at 21croissants.com
Thu Apr 30 06:08:51 EDT 2009

I'll reply to my own question as I have found an "hacked" solution.

In Autotest::Rspec (rspec/lib/autotest/rspec-rb)
I redefined make_test_cmd like this:
def make_test_cmd(files_to_test)
    if ENV['AUTOFEATURE'] =~ /true/i
      return "#{ruby} -S #{spec_command} #{add_options_if_present}
      return "#{ruby} -S #{spec_command} #{add_options_if_present}
#{files_to_test.keys.flatten.join(' ')}"

truth_spec is a dummy spec :
describe "Truth" do
  it "should be true" do
    true.should be_true

Doing this, autotest with AUTOFEATURE= true first runs the "specs" but only
finds truth_spec which takes about 1s to run and then run the features.

Jean-Michel Garnier wrote:
> Hi,
> I am joining a project which is using Rails 2.0.2, Rspec as a plugin 1.1.4
> The problem is specs take 10 minutes to run and I have no time to optimize
> them now.
> I am adding cucumber features and would like to run them with autotest
> (ZenTest 4.0.0).
> Is there a way to  have autotest running *only* the features? It would
> save
> me a LOT of time ...
> In the past, I think I managed to do it with a /script/autofeatures_only
> looking like:
> #!/usr/bin/env ruby
> ENV['AUTOFEATURE'] = 'true' # run only cucumber features
> ENV['RSPEC'] = 'false'     # ONLY the features, not the spec! NOT allows
> autotest to discover rspec
> system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'),
> *ARGV) ||
>   $stderr.puts("Unable to find autotest.  Please install ZenTest or fix
> your
> PATH")
> My rspec/lib/autotest/discover.rb looks like:
> Autotest.add_discovery do
>   "rspec" if File.directory?('spec') && ENV['RSPEC'] == true
> end
> Does anyone have a similar set up with different versions of RSpec? I am
> planning to upgrade Rails and RSpec in the coming months.
> Thanks,
> JM
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

View this message in context: http://www.nabble.com/-RSPEC---CUCUMBER--have-autotest-running-*only*-the-features-tp23299036p23313297.html
Sent from the rspec-users mailing list archive at Nabble.com.

More information about the rspec-users mailing list