Shoulda and Textmate - how can you get the cmd R trigger to work?

6 views
Skip to first unread message

Chris Adams

unread,
Oct 22, 2009, 8:33:02 PM10/22/09
to shoulda
Hi everyone,

Does anybody here use Textmate and Shoulda together, running tests
from within Textmate with cmd-R to trigger tests?

I'm getting this error when I try doing this with Shoulda:

LoadError: no such file to load — shoulda

Yet when I run the same commands in terminal, I'm getting the tests
working fine.

I think another person here[1] has been experiencing what seems to be
a similar case, but alas, I'm not actually sure what steps I'd need to
take for shoulda to be recognised, as I thought I had taken the
necessary steps outlined on this textmate shell page[2].

The shell page suggests having something like this if you're looking
to call a ruby that's called from /opt/local/bin:

{ PATH = "/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";}

These are the paths listed in my .MacOSX/environment.plist (I'm not
running my own ruby out from opt) file:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/
bin:/usr/local/git/bin

And these are the relevant variables dropped out of an env dump
(calling `env`) with cmd-R when within Textmate:

TM_RUBY=/usr/bin/ruby
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/
opt/local/bin:/usr/local/git/bin

And yet, no luck at all.

What am I missing here to make the shoulda gem be detected?

Thanks,

Chris



[1]: http://www.nabble.com/Ruby-Bundle-cmd-R-doesn't-find-gems-td23179075.html
[2]: http://manual.macromates.com/en/shell_commands#search_path

david.l...@gmail.com

unread,
Oct 22, 2009, 8:43:59 PM10/22/09
to sho...@googlegroups.com
have you tried adding this to the top of test_helper.rb?

$:.reject!{ |e| e.include? 'TextMate' }


-D

Chris Adams

unread,
Oct 23, 2009, 6:40:53 AM10/23/09
to sho...@googlegroups.com
Hi Daniel,

I'm currently working in a single file here, so I've added your
snippet in at the top to no avail - I'm still getting the same error.

I've also added the output from 'gem list', 'gem environment', and
'env' called from within textmate, to see if there's anything really
obvious that I'm missing.

https://gist.github.com/5562d84349b19032dd06

Thanks for your help so far!

C

2009/10/23 <david.l...@gmail.com>:
--
Chris Adams
mob: 07974 368 229
tel: 0207 558 8971
skype: chris.d.adams
twitter: chris_d_adams

Karel Minarik

unread,
Oct 23, 2009, 6:52:18 AM10/23/09
to shoulda
Hi Chris,

how are you requiring Shoulda in the first place?

If you do it the preferred way for a Rails app (ie. adding `config.gem
'thoughtbot-shoulda', :lib => 'shoulda'`), it should pick it up in
test_helper.rb (top line loads environment). There are problems with
loading test_helper.rb itself when running cmd+R in TM, but that's
unrelated here.

For a non-Rails Ruby app, simple:

require 'rubygems'
require 'shoulda'

in a test helper or test itself should really be fine. At least it
"works on my machine" and I have not heard of any problems.

--karmi
> [1]:http://www.nabble.com/Ruby-Bundle-cmd-R-doesn't-find-gems-td23179075....
> [2]:http://manual.macromates.com/en/shell_commands#search_path

Karel Minarik

unread,
Oct 23, 2009, 6:58:55 AM10/23/09
to shoulda
Sorry for double post, I haven't catched your gist -- the
"shoulda_got_it_working_by_now.rb" works fine even without the
reject...TextMate line. It really, really should.

$ gem list | grep -C 0 shoulda
202:thoughtbot-shoulda (2.10.1)

--karmi

On Oct 23, 12:40 pm, Chris Adams <m...@chrisadams.me.uk> wrote:
> Hi Daniel,
>
> I'm currently working in a single file here, so I've added your
> snippet in at the top to no avail - I'm still getting the same error.
>
> I've also added the output from 'gem list', 'gem environment', and
> 'env' called from within textmate, to see if there's anything really
> obvious that I'm missing.
>
> https://gist.github.com/5562d84349b19032dd06
>
> Thanks for your help so far!
>
> C
>
> 2009/10/23  <david.lowenf...@gmail.com>:
> >> [1]:http://www.nabble.com/Ruby-Bundle-cmd-R-doesn't-find-gems-td23179075....

Chris Adams

unread,
Oct 23, 2009, 7:23:01 AM10/23/09
to sho...@googlegroups.com
Hey Karmi,

Thanks for checking at your end - this confirms that there's something
deeper that's playing silly buggers in my mac, and I should probably
check on the textmate mailing list to see what's up, before I nuke my
mac from orbit with a clean install...

Cheers again for the help!

Chris

Karel Minarik

unread,
Oct 24, 2009, 5:08:08 AM10/24/09
to shoulda
What about any other Rubygem loading code? Are you eg. able to run
Sinatra Hello World app from http://www.sinatrarb.com/intro.html?

Karel

Chris Adams

unread,
Oct 24, 2009, 6:05:49 AM10/24/09
to sho...@googlegroups.com
Hey Karel

This is strange.

I've followed your instructions, and put the test file into my rb file like so:

require 'rubygems'
require 'sinatra'
get '/hi' do
"Hello World!"
end

Then I've run the file to test it out:

~/Desktop$ sudo gem install sinatra
Password:
Successfully installed sinatra-0.9.4
1 gem installed
Installing ri documentation for sinatra-0.9.4...
Updating ri class cache with 5063 classes...
Installing RDoc documentation for sinatra-0.9.4...
~/Desktop$ ruby sinatra.rb
./sinatra.rb:3: undefined method `get' for main:Object (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from sinatra.rb:2

In fact, RubyGems appears to be causing more grief:

~/Desktop$ irb
>> require 'sinatra'
NoMethodError: undefined method `get' for main:Object
from ./sinatra.rb:3
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from (irb):1
>> require 'rubygems'
=> false
>> require 'rubygems'
=> false

What does it mean when a require returns false like this?


Gist here: - http://gist.github.com/217464

C


2009/10/24 Karel Minarik <karel....@gmail.com>:

Chris Adams

unread,
Oct 24, 2009, 6:13:27 AM10/24/09
to sho...@googlegroups.com
Whoops.

> I've followed your instructions, and put the test file into my rb file like so:
>
> require 'rubygems'
> require 'sinatra'
> get '/hi' do
> "Hello World!"
> end

Tried again with this file called myapp.rb instead of sinatra.rb, and
sinitra worked fine.

Which leaves us back looking at shoulda again...

C

Karel Minarik

unread,
Nov 1, 2009, 9:16:42 AM11/1/09
to shoulda
So, you're able to load and run other gems (eg. 'sinatra'), but not
'shoulda', in Textmate? If that is the case, it's quite weird. Did you
try uninstalling shoulda and installing it again?

Karel
Reply all
Reply to author
Forward
0 new messages