Forum: JRuby JRuby method dispatch problem under rspec

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Maurício L. (Guest)
on 2008-10-27 22:15
(Received via mailing list)
Hello guys,

I've got a completely unexpected behaviour in my specs, if a protected
method is called under any controller spec, JRuby throws an error like
this one:

  NameError in 'SampleController on index calls Should call the
protected method `protected_method' called for
#<SampleController:0x238067>

But under MRI it just works

Here's the controller:

class SampleController < ApplicationController

  def index
    protected_method
  end

  protected

  def protected_method
    @protected = 'This is the protected string'
  end

end

And here's the spec:

require File.dirname(__FILE__) + '/../spec_helper'

describe SampleController do

  describe 'on index calls' do

    def do_get
      get :index
    end

    it 'Should call the protected method' do
      controller.should_receive :protected_method
      do_get
    end

    it 'Should assign the @protected variable' do
      do_get
      assigns[:protected].should_not be_blank
    end

  end

end

Any ideas about what's happening ()

--
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
João Pessoa, PB, +55 83 8867-7208

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.