[Rspec-devel] TextMate command for RSpec on Rails

aslak hellesoy aslak.hellesoy at gmail.com
Sat Jul 1 21:32:55 EDT 2006


Hi Jonathan,

This is great! I haven't had the chance to try it yet, but I will next week.

Would you be ok with us adding it to RSpce's svn? (vendor/textmate -
to be distributed as a separate package from the Rspec gem). We'll
credit you duly in the docs.

Cheers,
Aslak

On 6/30/06, Jonathan del Strother <maillist at steelskies.com> wrote:
> Don't know how many TextMate users we've got here, but:
>
> I was getting a little tired of tweaking a spec file, swapping to
> Terminal, running specs, and swapping back again, so I came up with a
> TextMate command to do this for me.  It runs 'rake spec' and display
> the output, complete with clickable links to any files.
>
>
>
> ===
>
> #!/usr/bin/env ruby
>
> def process_for_html(string)
>    string.gsub!("\n", "<br/>")
>
>    #try to find file names and make them into proper links
>    string.gsub! /\.(\/[^:]*):([\d]*)/ do |m|
>      path = Dir.pwd + $1
>      "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>"
>    end
>    string
> end
>
> Dir.chdir(ENV['TM_PROJECT_DIRECTORY'])
>
> output = `rake spec`
> output.gsub!("\n", "<br/>")
>
> #try to find file names and make them into proper links
> output.gsub! /\.(\/[^:]*):([\d]*)/ do |m|
>    path = Dir.pwd + $1
>    "<a href=\"txmt://open?url=file://#{path}&line=#{$2}\">#{m}</a>"
> end
>
> puts "<html><body style='font-size:0.8em'>#{"<h1>rspec</h1>"+output}</
> body></html>"
>
>
> ===
>
>
> Just create a new bundle command, and set its output to 'Show as
> HTML', and you should be good to go.
>
>
> There's a few limitations though - mainly that stderr isn't captured,
> so any stderr gets dumped at the top of the file , without
> formatting.  This includes the ruby invocation commands (ruby -Ilib "/
> usr/local/lib/ruby/gems/1.8/gems/rspec-0.5.13/bin/spec" "spec/models/
> active_user_spec.rb"), and any syntax errors in your specs.  I've
> been trying for the past hour to properly capture stderr and
> interpolate it into the normal output, without success.  popen3 just
> gives you stdout and stderr as separate objects, with no way of re-
> joining them up in the order they occurred.
> So, if anyone has a fix to the stderr problem, or any other additions
> & improvements, I'd love to see them.
>
>
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the Rspec-devel mailing list