I was suffering with a problem running tests inside of textmate on a Rails 2 project, until I found this comment by David Vrensk at the bottom of this blog post by Rob Sanheim:
Posted by David Vrensk 18 January 2008 @ 9am
I think the easiest solution can be gleaned from the TM ticket that you link to (http://macromates.com/ticket/show?ticket_id=F4DA8B03). I just modify test/test_helper.rb in my current projects so that it starts with
$:.reject! { |e| e.include? ‘TextMate’ }
No patching the distros, and svn still works the way it should.
I’m pleased to announce a textmate bundle that I assembled for the wonderfully simple shoulda testing framework.
The snippets were contributed by Dan Croak, James Golick, and Sam Livingston-Gray, and mashed up by me.
Grab the latest version here: http://macromates.com/svn/Bundles/trunk/Review/Bundles/Ruby%20Shoulda.tmbundle
Inspired by err’s cryptic yaml_to_spec rake task, I wrote my own version for shoulda, based off of Jeremy Hubert’s textmate bundle It’s a bit less cryptic, and it for extra nerd points it uses recursion to allow for nested contexts. :)
desc "Converts a YAML file into a Shoulda skeleton"
task :yaml_to_shoulda do
require 'yaml'
def yaml_to_context hash, indent=0
indent1 = ' '*indent
indent2 = ' '*(indent+1)
hash.each_pair do |context,shoulds|
puts indent1+"context \"#{context}\" do"
puts
shoulds.each do |should|
yaml_to_context( should, indent+1 ) and next if should.is_a?( Hash )
puts indent2+"should_eventually \"#{should.gsub(/^should +/,'')}\" do"
puts indent2+"end"
puts
end
puts indent1+"end"
end
yaml_to_context( YAML.load_file( ENV['FILE'] || !puts("Pass in FILE argument.") && exit ) )
end
Here is an example YAML file and it’s output:
This blog post: - should mention shoulda - should be concise - should be written by me - when saved as a draft: - should have multiple revisions - should not be published publiclycontext "This blog post" do should_eventually "mention shoulda" do end should_eventually "be concise" do end should_eventually "be written by me" do end context "when saved as a draft" do should_eventually "have multiple revisions" do end should_eventually "not be published publicly" do end end end
I will be adding this to my shoulda textmate bundle.
the scripts mentioned here come in handy… you can check them out via subversion: svn co http://ssel.vub.ac.be/svn-gen/bdefrain/fmscripts/
install them somewhere in your path (I like to use ~/bin)
then set these helper apps in your ~/.subversion/config:
### Set diff-cmd to the absolute path of your 'diff' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff implementation.
### diff-cmd = fmdiff
### Set diff3-cmd to the absolute path of your 'diff3' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff3 implementation.
diff3-cmd = fmdiff3
you can do conflict resolution with filemerge directly from textmate… with Ctrl-Shift-A -> Resolve Conflicts with FileMerge…
UPDATE: it’s pretty annoying to set diff-cmd to fmdiff… you get filemerge popping all the time when you might not need it. The best of both worlds is to set the Shell Variable in textmate Advanced preferences: variable: TM_SVN_DIFF_CMD value: fmdiff This way you get nice graphical diffs in textmate, but you get the straight up text stuff in the shell.
