Getting storyrunner success/failure status in rake task

Hi folks - I’m trying to build a rake task to run our plain-text
stories, both from a normal build and from our continuous integration
server.

However, I’m having a problem - running all.rb doesn’t return any sort
of success/failure - so a broken story doesn’t indicate to Cruise
Control that the build is broken.

Currently the rake task is:
desc “Run all stories”
task :stories do
output = “#{ARTIFACT_DIR}/doc/rspec/story_results.txt”
ruby “#{RAILS_ROOT}/stories/all.rb”
end

and all.rb calls story files which do the standard sort of thing:

require File.dirname(FILE) + “/helper”

with_steps_for(:stuff, :morestuff) do
run_local_story “my_first_story”, :type => RailsStory
end

I’m going to try switching to Kyle Hargrave’s story runner stuff - but
it’s unclear to me if this has any sort of success/fail indicator
either…

Any suggestions on how to get the above to return a failure code, or
throw an exception? I’ve seen stuff in the code relating to
Spec::Story::World.errors() - but I can’t seem to work out how to
access this.

(Oh, and I’m very new to rspec stories, and somewhat new to rake
tasks, so forgive me if I’m missing something obvious)

  • Korny


Kornelis Sietsma korny at my surname dot com
kornys at gmail dot com on google chat – kornys on skype
“we do what we must, because we can”

Korny S. wrote:

task :stories do
end

(Oh, and I’m very new to rspec stories, and somewhat new to rake
tasks, so forgive me if I’m missing something obvious)

  • Korny

Korny,
The exit code for the story runner does not work in the current (1.1.3)
version. I made a patch to add that functionality so our CI would be
happy and it is already in rspec edge and will be in 1.1.4. You can
either grab my patch or switch to edge rspec. My patch is here:
http://rspec.lighthouseapp.com/projects/5645/tickets/228-story-runner-exit-code

-Ben

Argh! I finally got this going, but only with much pain.
I had a problem that on my cruise box I was running:
“ruby stories/all.rb | tee #{output}”
But the call to ‘tee’ was hiding the return code from the ruby call…

This was all complicated by the fact that stories are actually run by
an at_exit handler - it took me quite a lot of digging to work out
what actually kicked off the stories!

  • Korny

On Wed, Apr 16, 2008 at 5:17 PM, Korny S. [email protected]
wrote:

stories, both from a normal build and from our continuous integration
ruby “#{RAILS_ROOT}/stories/all.rb”

tasks, so forgive me if I’m missing something obvious)
either grab my patch or switch to edge rspec. My patch is here:


Kornelis Sietsma korny at my surname dot com
kornys at gmail dot com on google chat – kornys on skype
“we do what we must, because we can”


Kornelis Sietsma korny at my surname dot com
kornys at gmail dot com on google chat – kornys on skype
“we do what we must, because we can”

Sweet! We’re on an r&d project, so we’ll probably move to edge…

  • Korny

On Wed, Apr 16, 2008 at 3:53 PM, Ben M. [email protected] wrote:

Currently the rake task is:
with_steps_for(:stuff, :morestuff) do
Spec::Story::World.errors() - but I can’t seem to work out how to
Korny,
http://rubyforge.org/mailman/listinfo/rspec-users


Kornelis Sietsma korny at my surname dot com
kornys at gmail dot com on google chat – kornys on skype
“we do what we must, because we can”