I just updated my Rails install to the most current Edge and my controller specs fail: 1) TypeError in ''The User Controller should be a user controller'' can''t convert nil into String Each spec fails the same way. <context string> <spec string> can''t convert nil into String Any ideas what''s up with this? Thanks, s.ross
This blog seems to have quite a bit of information about running with
edge Rails:
http://blog.methodmissing.com/2006/11/23/using-simply_helpful-with-
rspec-controller-tests
which I''ve found useful.
I''m running rspec 0.7.3 and the trunk of the rails plugin and most of
my controller specs pass, but I still get
undefined method `render?'' for #<ActionController::TestResponse:
0x28886c4>
errors for specs such as
specify "should render show.rhtml" do
response.should_render :show
end
Marcus
On 24 Nov 2006, at 07:11, s.ross wrote:
> I just updated my Rails install to the most current Edge and my
> controller specs fail:
>
> 1)
> TypeError in ''The User Controller should be a user
controller''
> can''t convert nil into String
>
> Each spec fails the same way.
>
> <context string> <spec string>
> can''t convert nil into String
>
> Any ideas what''s up with this?
>
> Thanks,
>
> s.ross
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
I have nearly the same problem, though for me it seems to be fixture related. Every context that includes fixtures breaks with the ''can''t convert nil into String'' TypeError. I tried building the trunk version of RSpec and installing the head version of the rails plugin, but no luck. Really shouldn''t have decided to use RSpec for my attempt at a rapid programming contest submission! Regards, Mathias On Nov 24, 2006, at 8:11 AM, s.ross wrote:> I just updated my Rails install to the most current Edge and my > controller specs fail: > > 1) > TypeError in ''The User Controller should be a user controller'' > can''t convert nil into String > > Each spec fails the same way. > > <context string> <spec string> > can''t convert nil into String > > Any ideas what''s up with this? > > Thanks, > > s.ross > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
The change that broke rspec_on_rails was in 5604. Here''s the svn diff:
--- activerecord/lib/active_record/fixtures.rb (revision 5603)
+++ activerecord/lib/active_record/fixtures.rb (revision 5604)
@@ -436,7 +436,7 @@
module Test #:nodoc:
module Unit #:nodoc:
class TestCase #:nodoc:
- cattr_accessor :fixture_path
+ class_inheritable_accessor :fixture_path
class_inheritable_accessor :fixture_table_names
class_inheritable_accessor :fixture_class_names
class_inheritable_accessor :use_transactional_fixtures
Poking around in Rails, the nil that can''t be converted to a string
is (d''oh) fixture_path.
On Nov 24, 2006, at 3:12 AM, Mathias Biilmann Christensen wrote:
> I have nearly the same problem, though for me it seems to be fixture
> related.
>
> Every context that includes fixtures breaks with the
''can''t convert
> nil into String'' TypeError.
>
> I tried building the trunk version of RSpec and installing the head
> version of the rails plugin, but no luck.
>
> Really shouldn''t have decided to use RSpec for my attempt at a
rapid
> programming contest submission!
>
> Regards,
> Mathias
>
>
> On Nov 24, 2006, at 8:11 AM, s.ross wrote:
>
>> I just updated my Rails install to the most current Edge and my
>> controller specs fail:
>>
>> 1)
>> TypeError in ''The User Controller should be a user
controller''
>> can''t convert nil into String
>>
>> Each spec fails the same way.
>>
>> <context string> <spec string>
>> can''t convert nil into String
>>
>> Any ideas what''s up with this?
>>
>> Thanks,
>>
>> s.ross
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
Hi, I believe the response object doesn''t respond to render? ... you need to use the controller instance as the receiver. - Lourens On 2006/11/24, at 07:53, Marcus Roberts wrote:> This blog seems to have quite a bit of information about running with > edge Rails: > > http://blog.methodmissing.com/2006/11/23/using-simply_helpful-with- > rspec-controller-tests > > which I''ve found useful. > > I''m running rspec 0.7.3 and the trunk of the rails plugin and most of > my controller specs pass, but I still get > > undefined method `render?'' for #<ActionController::TestResponse: > 0x28886c4> > > errors for specs such as > > specify "should render show.rhtml" do > response.should_render :show > end > > > Marcus > > On 24 Nov 2006, at 07:11, s.ross wrote: > >> I just updated my Rails install to the most current Edge and my >> controller specs fail: >> >> 1) >> TypeError in ''The User Controller should be a user controller'' >> can''t convert nil into String >> >> Each spec fails the same way. >> >> <context string> <spec string> >> can''t convert nil into String >> >> Any ideas what''s up with this? >> >> Thanks, >> >> s.ross >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Same here, I''m rolling back to rspec 0.7.2 to give it a go and see what happens. -Chad On Nov 24, 2006, at 2:11 AM, s.ross wrote:> I just updated my Rails install to the most current Edge and my > controller specs fail: > > 1) > TypeError in ''The User Controller should be a user controller'' > can''t convert nil into String > > Each spec fails the same way. > > <context string> <spec string> > can''t convert nil into String > > Any ideas what''s up with this? > > Thanks, > > s.ross > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
I found the cause, it looks like this revision of edge rails introduced the error we are seeing in rspec. http:// dev.rubyonrails.org/changeset/5604 -Chad On Nov 24, 2006, at 2:11 AM, s.ross wrote:> I just updated my Rails install to the most current Edge and my > controller specs fail: > > 1) > TypeError in ''The User Controller should be a user controller'' > can''t convert nil into String > > Each spec fails the same way. > > <context string> <spec string> > can''t convert nil into String > > Any ideas what''s up with this? > > Thanks, > > s.ross > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Followup: Adding the following to your tests that encounter the problem seems to fix them self.fixture_path = RAILS_ROOT + ''/spec/fixtures'' Discovered on the related rails ticket: http://dev.rubyonrails.org/ticket/6672 -Chad On Nov 24, 2006, at 6:12 AM, Mathias Biilmann Christensen wrote:> I have nearly the same problem, though for me it seems to be fixture > related. > > Every context that includes fixtures breaks with the ''can''t convert > nil into String'' TypeError. > > I tried building the trunk version of RSpec and installing the head > version of the rails plugin, but no luck. > > Really shouldn''t have decided to use RSpec for my attempt at a rapid > programming contest submission! > > Regards, > Mathias > > > On Nov 24, 2006, at 8:11 AM, s.ross wrote: > >> I just updated my Rails install to the most current Edge and my >> controller specs fail: >> >> 1) >> TypeError in ''The User Controller should be a user controller'' >> can''t convert nil into String >> >> Each spec fails the same way. >> >> <context string> <spec string> >> can''t convert nil into String >> >> Any ideas what''s up with this? >> >> Thanks, >> >> s.ross >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Add this line to spec_helper.rb so your testcase subclasses inherit
the parent''s fixture path and it restores the ''old''
way of rails''
fixtures.
module Spec
module Rails
class EvalContext < Test::Unit::TestCase
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
self.fixture_path = RAILS_ROOT + ''/spec/fixtures''
+ cattr_accessor :fixture_path
...
end
end
end
>I found the cause, it looks like this revision of edge rails
>introduced the error we are seeing in rspec. http://
>dev.rubyonrails.org/changeset/5604
>
>-Chad
>
>On Nov 24, 2006, at 2:11 AM, s.ross wrote:
>
>> I just updated my Rails install to the most current Edge and my
>> controller specs fail:
>>
>> 1)
>> TypeError in ''The User Controller should be a user
controller''
>> can''t convert nil into String
>>
>> Each spec fails the same way.
>>
>> <context string> <spec string>
>> can''t convert nil into String
>>
>> Any ideas what''s up with this?
>>
>> Thanks,
>>
>> s.ross
Weird, my messages to the list must be taking forever to show up, or not showing up for me? I sent a msg a few hours ago about it but I never saw it show up. I like your solution better than the one I came up with, thanks! -Chad On Nov 24, 2006, at 11:02 PM, Courtenay wrote:> Add this line to spec_helper.rb so your testcase subclasses inherit > the parent''s fixture path and it restores the ''old'' way of rails'' > fixtures. > > module Spec > module Rails > class EvalContext < Test::Unit::TestCase > self.use_transactional_fixtures = true > self.use_instantiated_fixtures = false > self.fixture_path = RAILS_ROOT + ''/spec/fixtures'' > + cattr_accessor :fixture_path > ... > end > end > end > >> I found the cause, it looks like this revision of edge rails >> introduced the error we are seeing in rspec. http:// >> dev.rubyonrails.org/changeset/5604 >> >> -Chad >> >> On Nov 24, 2006, at 2:11 AM, s.ross wrote: >> >>> I just updated my Rails install to the most current Edge and my >>> controller specs fail: >>> >>> 1) >>> TypeError in ''The User Controller should be a user controller'' >>> can''t convert nil into String >>> >>> Each spec fails the same way. >>> >>> <context string> <spec string> >>> can''t convert nil into String >>> >>> Any ideas what''s up with this? >>> >>> Thanks, >>> >>> s.ross > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
No, that doesn''t fix it. fixture_path is still nil in load_fixtures. Note also that use_transactional_fixtures is false when it shouldn''t be. The settings aren''t getting pushed down into AR. s.ross On Nov 24, 2006, at 8:02 PM, Courtenay wrote:> Add this line to spec_helper.rb so your testcase subclasses inherit > the parent''s fixture path and it restores the ''old'' way of rails'' > fixtures. > > module Spec > module Rails > class EvalContext < Test::Unit::TestCase > self.use_transactional_fixtures = true > self.use_instantiated_fixtures = false > self.fixture_path = RAILS_ROOT + ''/spec/fixtures'' > + cattr_accessor :fixture_path > ... > end > end > end > >> I found the cause, it looks like this revision of edge rails >> introduced the error we are seeing in rspec. http:// >> dev.rubyonrails.org/changeset/5604 >> >> -Chad >> >> On Nov 24, 2006, at 2:11 AM, s.ross wrote: >> >>> I just updated my Rails install to the most current Edge and my >>> controller specs fail: >>> >>> 1) >>> TypeError in ''The User Controller should be a user controller'' >>> can''t convert nil into String >>> >>> Each spec fails the same way. >>> >>> <context string> <spec string> >>> can''t convert nil into String >>> >>> Any ideas what''s up with this? >>> >>> Thanks, >>> >>> s.ross > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Here''s code I hacked up in my spec_helper.rb that works. Order of the
statement is important: The cattr_accessor''s must precede the
assignments. (big sigh of relief :)
module Spec
module Rails
class EvalContext < Test::Unit::TestCase
cattr_accessor :fixture_path
+ cattr_accessor :use_transactional_fixtures
+ cattr_accessor :use_instantiated_fixtures
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
self.fixture_path = RAILS_ROOT + ''/spec/fixtures''
...
end
end
end
On Nov 24, 2006, at 8:02 PM, Courtenay wrote:
> Add this line to spec_helper.rb so your testcase subclasses inherit
> the parent''s fixture path and it restores the
''old'' way of rails''
> fixtures.
>
> module Spec
> module Rails
> class EvalContext < Test::Unit::TestCase
> self.use_transactional_fixtures = true
> self.use_instantiated_fixtures = false
> self.fixture_path = RAILS_ROOT + ''/spec/fixtures''
> + cattr_accessor :fixture_path
> ...
> end
> end
> end
>
>> I found the cause, it looks like this revision of edge rails
>> introduced the error we are seeing in rspec. http://
>> dev.rubyonrails.org/changeset/5604
>>
>> -Chad
>>
>> On Nov 24, 2006, at 2:11 AM, s.ross wrote:
>>
>>> I just updated my Rails install to the most current Edge and my
>>> controller specs fail:
>>>
>>> 1)
>>> TypeError in ''The User Controller should be a user
controller''
>>> can''t convert nil into String
>>>
>>> Each spec fails the same way.
>>>
>>> <context string> <spec string>
>>> can''t convert nil into String
>>>
>>> Any ideas what''s up with this?
>>>
>>> Thanks,
>>>
>>> s.ross
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
No, seriously. I mis-pasted, move the cattr_accessor up a line to
before the setter line
cattr_accessor :fixture_path
self.fixture_path = RAILS_ROOT + ''/spec/fixtures''
I just tested again, it works a charm here. If the cattr_accessor
line is below the fixture path it fails.
However, the fact that the test::unit stuff like transactions isn''t
propagating is an indication of a deeper problem, wherein the
inherited accessors are failing.
On 11/24/06, s.ross <cwdinfo at gmail.com> wrote:> No, that doesn''t fix it. fixture_path is still nil in
load_fixtures.
> Note also that use_transactional_fixtures is false when it
shouldn''t
> be. The settings aren''t getting pushed down into AR.
>
> s.ross
>
> On Nov 24, 2006, at 8:02 PM, Courtenay wrote:
>
> > Add this line to spec_helper.rb so your testcase subclasses inherit
> > the parent''s fixture path and it restores the
''old'' way of rails''
> > fixtures.
> >
> > module Spec
> > module Rails
> > class EvalContext < Test::Unit::TestCase
> > self.use_transactional_fixtures = true
> > self.use_instantiated_fixtures = false
> > self.fixture_path = RAILS_ROOT +
''/spec/fixtures''
> > + cattr_accessor :fixture_path
> > ...
> > end
> > end
> > end
> >
> >> I found the cause, it looks like this revision of edge rails
> >> introduced the error we are seeing in rspec. http://
> >> dev.rubyonrails.org/changeset/5604
> >>
> >> -Chad
> >>
> >> On Nov 24, 2006, at 2:11 AM, s.ross wrote:
> >>
> >>> I just updated my Rails install to the most current Edge and
my
> >>> controller specs fail:
> >>>
> >>> 1)
> >>> TypeError in ''The User Controller should be a user
controller''
> >>> can''t convert nil into String
> >>>
> >>> Each spec fails the same way.
> >>>
> >>> <context string> <spec string>
> >>> can''t convert nil into String
> >>>
> >>> Any ideas what''s up with this?
> >>>
> >>> Thanks,
> >>>
> >>> s.ross
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
Well, I don''t know what kind of crack I was smoking, but quite suddenly I started experiencing the same problem. I''ve added the cattr_accessor statements and all is well. This is committed to the trunk (rev 1147). Cheers, David On 11/24/06, s.ross <cwdinfo at gmail.com> wrote:> Here''s code I hacked up in my spec_helper.rb that works. Order of the > statement is important: The cattr_accessor''s must precede the > assignments. (big sigh of relief :) > > module Spec > module Rails > class EvalContext < Test::Unit::TestCase > cattr_accessor :fixture_path > + cattr_accessor :use_transactional_fixtures > + cattr_accessor :use_instantiated_fixtures > self.use_transactional_fixtures = true > self.use_instantiated_fixtures = false > self.fixture_path = RAILS_ROOT + ''/spec/fixtures'' > ... > end > end > end > > On Nov 24, 2006, at 8:02 PM, Courtenay wrote: > > > Add this line to spec_helper.rb so your testcase subclasses inherit > > the parent''s fixture path and it restores the ''old'' way of rails'' > > fixtures. > > > > module Spec > > module Rails > > class EvalContext < Test::Unit::TestCase > > self.use_transactional_fixtures = true > > self.use_instantiated_fixtures = false > > self.fixture_path = RAILS_ROOT + ''/spec/fixtures'' > > + cattr_accessor :fixture_path > > ... > > end > > end > > end > > > >> I found the cause, it looks like this revision of edge rails > >> introduced the error we are seeing in rspec. http:// > >> dev.rubyonrails.org/changeset/5604 > >> > >> -Chad > >> > >> On Nov 24, 2006, at 2:11 AM, s.ross wrote: > >> > >>> I just updated my Rails install to the most current Edge and my > >>> controller specs fail: > >>> > >>> 1) > >>> TypeError in ''The User Controller should be a user controller'' > >>> can''t convert nil into String > >>> > >>> Each spec fails the same way. > >>> > >>> <context string> <spec string> > >>> can''t convert nil into String > >>> > >>> Any ideas what''s up with this? > >>> > >>> Thanks, > >>> > >>> s.ross > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >