[Rspec-devel] TextMate command for RSpec on Rails

aslak hellesoy aslak.hellesoy at gmail.com
Sun Jul 2 03:17:42 EDT 2006


On 7/1/06, Brian Hughes <brianvh at alum.dartmouth.org> wrote:
>
> I think it looks like a great script, as well. I should also mention
> that I've been working on a semi-full rSpec bundle for TextMate, and
> the spec runner script was a big part of what I was missing. I've
> kind of put the project on the shelf, however, because there's
> currently no way for TM to select the language bundle based on a
> portion of the file name that isn't the file extension. So *_spec.rb
> is the same as every other *.rb file, which means you can't have a
> single project with Ruby, Rails and rSpec files in it.
>

We've thought about encouraging a new naming convention for spec
files. Instead of

  mooky_spec.rb

you would have

  mooky.spec

Would that solve your problems?

And also - feel free to contribute your bundle - even if it's not
"quite there" yet. All of the RSpec developers are on os x/textmate.
Bring it out and let others help improve it.

Aslak

> -Brian
>
> On Jul 1, 2006, at 09:32 PM, aslak hellesoy wrote:
> > 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