Today trying to run my RSpec tests and I get an odd error:
uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError)
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:105:inconst_missing'gem_original_require’
/usr/local/lib/ruby/gems/1.8/gems/test-unit-2.0.3/lib/test/unit/testresult.rb:28
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'require’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in
….
After doing some research online I found out that the issue is caused by Shoulda and Mocha being included in my app. It seems that if you put a gem dependence for Shoulda before Mocha, you’ll get this error, so the fix is to place the gem dependence for Mocha before Shoulda.
config.gem “rspec”, :lib => false, :version => “>=1.2.6″
config.gem “rspec-rails”, :lib => ‘spec/rails’, :version => “>=1.2.6″
config.gem “mocha”
config.gem “thoughtbot-shoulda”, :lib => “shoulda”, :source => “http://gems.github.com”
Hope that helps
UPDATE:
I hit the same error having shoulda in my environment.rb file, moving it to the test.rb (in environment folder) fixed the issue as well.
Learn MoreToday I’ve upgraded my gems and noticed that when running my autospec I get an odd error:
[01:09:25 /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.10/lib/ole/storage/base.rb:146:load]
WARN root name was “R”
sh: line 1: 6303 Trace/BPT trap /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep ‘/Users/andrew/rails_apps/example_com’ 2>&1sh: line 1: 6307 Trace/BPT trap /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep ‘/Users/andrew/rails_apps/example_com’ 2>&1
sudo gem uninstall autotest-fsevent‘) and install the older version (‘sudo gem install autotest-fsevent --version 0.1.1‘)/usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.2.1/fsevent/darwin/fsevent_sleep ; exit;
~% /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.2.1/fsevent/darwin/fsevent_sleep ; exit;
dyld: unknown required load command 0x80000022
zsh: trace trap
The only work around (outside of downgrading to version 0.1.1) is to copy fsevent_sleep from version 0.1.1 to version 0.2.1. However I’m not sure how stable that solution is.
Learn MoreI have an application that has subdomains based on account (i.e. user1.example.com) but I want one login for the whole system, no matter what subdomain/account your in. In rails 2.2 I’d set it up by setting:
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_domain] = '.domain.com'
Notice the leading ‘.’ (very much needed)
But in rails 2.3 it doesn’t work, so I found from Mark Gandolfo you can set it using:
config.action_controller.session = {
:session_key => '_my_session_id',
:secret => '..your_secret_code_here..',
:domain => ".domain.com"
}
Hope that helps someone!
UPDATE:
If what I’m showing here is to simple for your needs, I did find a great post on how to deal with multiple domains (not just subdomains) in rails 2.3 at Code Tunes
Learn MoreIn Rails 2.3, templates are simple ruby files containing DSL for adding plugins, gems, initializers, etc. to your freshly created Rails project. To apply the template, you need to provide the rails generator with location of the template you wish to apply, using -m option.
Reading up on the commands in the template system and watching the railscasts.com episode, I got fired up on the possibilities of such a simple yet amazing system. So I dove in and started creating my base template. I was so excited that I write the whole template out in one go and than ran it. The result: FAIL!
After including some gems, I ran a rake "gems:install" and ended up with an Exec format error. I googled the problem and found that mostly Windows users were getting this error and the recommend solution was to use a rake.bat (or rake.cmd) instead of the rake command from ruby. So I wrote my own function:
#HELPERS
def win_env?
RUBY_PLATFORM=~ /win32/
end
def rake(command, options = {})
env = options[:env] || 'development'
log 'rake', "#{command} in #{env} "
sudo = win_env? ? '' : (options[:sudo] ? 'sudo' : '')
rake_cmd = win_env? ? "rake.bat" : 'rake'
in_root { run("#{sudo} #{rake_cmd} #{command} RAILS_ENV=#{env}", false) }
end
Another thing that I was able to fix is the “Sudo” option, works great on UNIX systems but not so great in Windows. I haven’t been able to test it but I’m pretty sure this will work on a UNIX system without any issues.
All worked out great till I ran run "cucumber features -n" and got the exact same error! Lucky there was a .bat version of cucmber command so I was able to easily fix it by calling run "cucumber#{win_env? ? '.bat': ''} features -n"
One more small issue I found in Windows when making a template was in the git command. When doing a commit you need to use double quotes inside the commit message otherwise you get an error: pathspec 'commit'' did not match any file(s) known to git.
If you’re interested in downloading my template, you can download it from here
If you really want to see the power of template system I recommend you read the template_runner.rb in the rails folder. Enjoy and have fun with it!
Learn More