So, why do the instructions at
http://rdoc.info/projects/thoughtbot/shoulda
say to unpack the gem into vendor/gems? Is that neccessary? It doesn't
appear to be - as long as I put the config.gem line in
$RAILS_ROOT/config/environment.rb. Then, with a little bit of tweaking
for syntax changes, my tests run file.
But if I try to move the config.gem line into
$RAILS_ROOT/config/environments/test.rb, the 'rake gems' tasks seem to
think it is fine, but 'rake test' doesn't load the correct version and
I get very old versions of Shoulda complaining about macros not found.
What am I missing about gem/plugin loading? And is the answer really
to RTFM and do "rake gems:unpack"?
Current Rails: 2.1.2
Installed Gems:
seanhussey-woulda (0.2.2, 0.2.0, 0.1.6)
Shoulda (1.2.0, 1.1.1)
thoughtbot-shoulda (2.10.1, 2.9.1, 2.0.6)
enviroment.rb
config.gem 'mime-types', :lib => 'mime/types', :version => '1.15'
config.gem 'editable-image', :version => '0.25'
config.gem 'rmagick', :lib => 'RMagick', :version => '>= 1.15.13'
environments/test.rb
# Gems we only need for testing
config.gem 'thoughtbot-shoulda', :lib => 'shoulda', :version => '2.10.1', :source => 'http://gems.github.com'
config.gem 'mocha'
config.gem 'feedvalidator', :lib => 'feed_validator'
$ rake gems
(in /rails/grapevine)
[I] mime-types = 1.15
[I] editable-image = 0.25
[I] rmagick >= 1.15.13
$ rake gems RAILS_ENV=test
(in /rails/grapevine)
[I] mime-types = 1.15
[I] editable-image = 0.25
[I] rmagick >= 1.15.13
[I] thoughtbot-shoulda = 2.10.1
[I] mocha
[I] feedvalidator
$ rake test:units
/software/stow/ruby-enterprise-1.8.6-20080709/bin/ruby -I"lib:test"
"/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"
"test/unit/site_image_test.rb" "test/unit/page_test.rb" "test/unit/document_test.rb" "test/unit/event_test.rb"
"test/unit/document_category_test.rb" "test/unit/ldap_server_test.rb" "test/unit/role_test.rb" "test/unit/user_test.rb"
"test/unit/layout_test.rb" "test/unit/homepage_image_test.rb" "test/unit/site_preference_test.rb"
/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/Shoulda-1.2.0/lib/shoulda.rb:273:in
`send': undefined method `should_belong_to' for PageTest:Class (NoMethodError)
from
/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/Shoulda-1.2.0/lib/shoulda.rb:273:in
`
method_missing' from ./test/unit/page_test.rb:6:in `__bind_1245701310_688247'
Sort of. With the following line in my environments/test.rb
config.gem 'thoughtbot-shoulda', :lib => 'shoulda/rails', \
:version => '2.10.1', :source => 'http://gems.github.com'
I can show that I am loading the right version of the shoulda
gem. I know that from the stack trace for the new error message (same
for all sets of tests (unit, functional, and integration)
/software/stow/ruby-enterprise-1.8.6-20080709/bin/ruby -I"lib:test"
"/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"
"test/unit/site_image_test.rb" "test/unit/page_test.rb"...
/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/\
dependencies.rb:440:in `load_missing_constant': uninitialized constant Shoulda::Assertions (NameError)
from
/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
from
/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/gems/1.8/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/action_controller.rb:22
from
/software/stow/ruby-enterprise-1.8.6-20080709/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require' ....
I know I have an old version being loaded (the error message lists
version), what I don't know is why.
> You an easily check that by going to your gems directory or doing a
> gem list command.
My original post shows which versions of shoulda I have installed as
gems - and it includes the 2.10.1 thoughtbot-should gem referenced in
my config.gem statement. It just isn't being used if I move my gem
requirement from environment.rb to test.rb
--
Cynthia Kiser
c...@caltech.edu
It never hurts to double check. Yes, I have no shoulda anything in my
vendor/plugins directory. And what I am trying to do is to avoid
having shoulda in vendor/gems as the install instructions imply one
should do. If I am going to have to install shoulda in my production
environment, at least I only want the single copy in my shared gems
location.