tags:

views:

294

answers:

5

I just updated to Ruby 1.9.1 and nearly all my rspec are broken giving me a "can't modify frozen object". Even the Rspec sample code from a generate rspec_controller fails.

RuntimeError in 'DownloadsController should use DownloadsController'
can't modify frozen object                                                                                                                                                          
/usr/local/lib/ruby19/1.9.1/timeout.rb:44:in `timeout'


Generated by the following code: 

it "should use DownloadsController" do
  controller.should be_an_instance_of(DownloadsController)
end

Can anyone help ?

A: 

I think this thread is helpful.

khelll
Thanks for the help, but unfortunately, it's not related to my issue. The thread is talking about a bug with remarkable and spec_server...I just using rake spec to run my tests which all pass with 1.8. 206 out of 254 fail when running with ruby 1.9
xto
+1  A: 

Try opening /usr/local/lib/ruby19/1.9.1/timeout.rb and replace line 44 with the following:

begin
  return yield(sec) if sec == nil or sec.zero?
rescue => e
  puts e.backtrace.join("\n")
  raise e
end

Though this seems odd, in some cases I've found that this gives me more detailed information on the actual source of the problem. If you still don't know how to fix the problem, paste your results here and maybe it will help us track down the issue.

Peter Wagenet
A: 

xto, any success with the problem?

neolix
A: 

Are you use you aren't trying to stub something that is nil.

In 1.8 nil wasn't frozen. It is however frozen in ruby 1.9.

shaner
Thhanks for the input. I'll try it perhaps this weekend. I've been sent on a contract and taken off my Rails project.
xto
A: 

@shaner was the correct answer for me. it was hiding a nil reference error behind this "can't modify frozen object". it was extra confusing for me b/c some of my tests expect an object to be frozen (deleted from ActiveRecord), so i initially thought it was that. unfortunately i don't have enough reputation yet to vote up his answer.

Stephen C