On Sat, Apr 12, 2008 at 11:54 AM, Ashley Moran <[EMAIL PROTECTED]> wrote: > Hi > > I have a story step that looks like this: > > When /(the user|then) runs "migrate (.*)"/ do |_, args| > cd project_dir do > @output = `#{migrate} #{args}` > end > @output_lines = @output.split("\n") > end > > Which is fine for testing STDOUT but not STDERR. I don't want to > redirect STDERR to STDOUT because then the story can't prove that > error messages are displayed separately (although the specs would)
How about something along the lines cd project_dir do @stdout, @stdterr = capture_outputs("#{migrate} #{args}") end ... def capture_outputs(cmd) stderr_log = "/tmp" + "/#{$0}-{$$}.log" out = `cmd 2> #{stderr_log}` err = File.read(stderr_log) if File.exist? stderr_log [out, err] end Totally untested, but hopefully you get the idea? -- "One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was not full of lettuces. This did not seem fair." -- Terry Pratchett, Mr. Bunnsy Has An Adventure _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users