[rspec-users] View Specs Fail with "protected method render"

David Chelimsky dchelimsky at gmail.com
Thu Apr 19 13:57:54 EDT 2007


On 4/19/07, Jeff Dean <jeff at jefdean.com> wrote:
> Thanks for all of your help on this.  By the way - is there a donate link
> anywhere?
>
> Here's the result of spec spec/views/users/show_rhtml
> _spec.rb -b
> NoMethodError in '/users/show.rhtml should render attributes in <p>'
> protected method `render' called for
> #<Spec::Rails::Runner::ViewSpecController:0x31388d4>
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:14:in
> `call'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-
> 0.8.2/lib/spec/expectations/sugar.rb:14:in
> `_method_missing'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectations/sugar.rb:10:in
> `method_missing'
> /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in
> `render'
> ./spec/views/users/show_rhtml_spec.rb:13:
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in
> `instance_eval'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:66:in
> `execute_spec'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/specification.rb:31:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:37:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-
> 0.8.2/lib/spec/runner/context.rb:34:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context.rb:34:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:21:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in
> `each'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/runner/context_runner.rb:20:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-
> 0.8.2/lib/spec/runner/command_line.rb:29:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-0.8.2/bin/spec:4:
> /usr/local/bin/spec:18:in `load'
> /usr/local/bin/spec:18:

Well, I'm not sure why there is a conflict between rspec 0.8.2 and
edge rails, but there is apparently. I tried this w/ rails 1.2.3 and
also using edge rails/edge rspec - in both cases there was no problem.
I guess if you're using edge rails you should probably be using edge
rspec too.



>
>
> On 4/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> >
> > On 4/19/07, Jeff Dean <jeff at jefdean.com> wrote:
> > > I run the view specs with rake spec:views.  I mentioned zentest only
> because
> > > I wasn't sure if it affected the specs in any way.
> > >
> > > If render is protected, how should I be writing my view specs?
> >
> > #render is protected on the controller - not within your spec - so saying
> ...
> >
> > it "should render new form" do
> >   render "/users/new.rhtml"
> >   ...
> > end
> >
> > ... is fine.
> >
> > I think the message about render is a red herring. I'm not sure what
> > the real problem is from the info we've got so far. Would you mind
> > doing this:
> >
> > spec spec/views/users/show_rhtml_spec.rb -b
> >
> > If you are using rspec installed as a plugin then do this:
> >
> > vendor/rspec/bin/spec spec/views/users/show_rhtml_spec.rb
> -b
> >
> > That will provide the full backtrace info which might help diagnose this.
> >
> > Thanks,
> > David
> >
> > >
> > >
> > >  On 4/19/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > >
> > > > On 4/10/07, Jeff Dean < jeff at jefdean.com> wrote:
> > > > > I've got rspec and zentest installed as well as the rspec rails
> plugin,
> > > and
> > > > > my model/controller specs all pass and work well.  I can't seem to
> get
> > > views
> > > > > to work though - 100% of the specs fail with:
> > > > >
> > > > > NoMethodError in '/users/show.rhtml should render attributes in <p>'
> > > > > protected method `render' called for
> > > > >
> #<Spec::Rails::Runner::ViewSpecController:0x3197dfc>
> > > > >
> > >
> /Users/jeff/Sites/niche/trunk/vendor/plugins/rspec_on_rails/lib/spec/rails/runner/context/view.rb:102:in
> > > > > `render'
> > > > > ./spec/views/users/show_rhtml_spec.rb:13:
> > > > >
> > > > > Note the "protected method `render' called for
> > > > >
> #<Spec::Rails::Runner::ViewSpecController:0x3197dfc>"
> > > > >
> > > > > Here's an example spec:
> > > > >
> > > > > require File.dirname(__FILE__) + '/../../spec_helper'
> > > > >
> > > > > context "/users/new.rhtml" do
> > > > >   include UsersHelper
> > > > >
> > > > >   setup do
> > > > >     @errors = mock("errors")
> > > > >     @errors.stub!(:count).and_return(0)
> > > > >
> > > > >     @user = mock_user
> > > > >     @user.stub!(:errors).and_return @errors
> > > > >     assigns[:user] = @user
> > > > >   end
> > > > >
> > > > >   specify "should render new form" do
> > > > >     render "/users/new.rhtml"
> > > > >     response.should_have_tag 'form', :attributes =>{:action =>
> > > users_path,
> > > > > :method => 'post'}
> > > > >
> > > > >   end
> > > > > end
> > > > >
> > > > > Can anyone think of why "render" is protected?  Is this a versioning
> > > issue?
> > > >
> > > > It's protected in ActionController::Base in rails >= 1.2.3 (perhaps
> > > > before), so Spec::Rails made it protected as well.
> > > >
> > > > You mentioned that you've got zentest installed - what does that have
> > > > to do with this problem? RSpec's dependency on ZenTest has been gone
> > > > for quite some time now. Are you running specs w/ autotest or
> > > > rspec_autotest?
> > > >
> > > >
> > > > >
> > > > > Thanks - Jeff
> > > > >
> > > > > _______________________________________________
> > > > > 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
> > > >
> > >
> > >
> > > _______________________________________________
> > > 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
> >
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list