Hi, In my functional tests it was convenient to use: @controller.expects(:admin?).at_least_once.returns(true) to simulate requests which come from an admin user. But it seems that in Rails 2.3.8 it''s gone away. What replaces it now? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fernando Perez wrote:> Hi, > > In my functional tests it was convenient to use: > > @controller.expects(:admin?).at_least_once.returns(true) > > to simulate requests which come from an admin user. But it seems that in > Rails 2.3.8 it''s gone away. What replaces it now?Anyone? Currently my apps are running test less because I can''t use expects or whatever method to stub out some behavior. Where could I find relevant information about that? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> In my functional tests it was convenient to use: >> >> @controller.expects(:admin?).at_least_once.returns(true) >> >> to simulate requests which come from an admin user. But it seems that in >> Rails 2.3.8 it''s gone away. What replaces it now?Up, it''s important. Nobody uses functional tests here? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 29, 3:53 pm, Fernando Perez <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> >> In my functional tests it was convenient to use: > > >> @controller.expects(:admin?).at_least_once.returns(true) > > >> to simulate requests which come from an admin user. But it seems that in > >> Rails 2.3.8 it''s gone away. What replaces it now? > > Up, it''s important. Nobody uses functional tests here?Should still work. What happens instead? What version were you migrating from? That stuff is setup by ActionController::TestCase Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Fred, Here is some code: ------------------ require ''test_helper'' class Admin::OrdersControllerTest < ActionController::TestCase def setup @controller = Admin::OrdersController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @controller.expects(:admin?).at_least_once.returns(true) @order = Factory.order end def test_index get :index assert_response :success end end And here is the error message: ------------------------------ 1) Error: test_index(Admin::OrdersControllerTest): NoMethodError: undefined method `expects'' for #<Admin::OrdersController:0x229a32c @real_format=nil> -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 29, 5:23 pm, Fernando Perez <li...@ruby-forum.> > class Admin::OrdersControllerTest < ActionController::TestCase > > def setup > @controller = Admin::OrdersController.new > @request = ActionController::TestRequest.new > @response = ActionController::TestResponse.new > @controller.expects(:admin?).at_least_once.returns(true) > @order = Factory.order > endDo you explicitly require mocha somewhere? By the way you no longer need to setup @controller/@request/@response - actioncontroller::testcase does that for you Fred Fred> > def test_index > get :index > assert_response :success > end > end > > And here is the error message: > ------------------------------ > > 1) Error: > test_index(Admin::OrdersControllerTest): > NoMethodError: undefined method `expects'' for > #<Admin::OrdersController:0x229a32c @real_format=nil> > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> Do you explicitly require mocha somewhere?I don''t use mocha. Did rails delegate the stubbing to mocha recently? So that could be my missing piece of the puzzle. Where should I require it in? test_helper.rb?> By the way you no longer need to setup @controller/@request/@response - > actioncontroller::testcase does that for youIndeed, I''ll update my tests accordingly, thanks for pointing that out. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It seems that simply installing the mocha gem solved my problem. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 30, 10:53 am, Fernando Perez <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > Do you explicitly require mocha somewhere? > > I don''t use mocha. Did rails delegate the stubbing to mocha recently? So > that could be my missing piece of the puzzle. Where should I require it > in? test_helper.rb? >it always has, but rails may have been accidentally requiring it for you Fred> > By the way you no longer need to setup @controller/@request/@response - > > actioncontroller::testcase does that for you > > Indeed, I''ll update my tests accordingly, thanks for pointing that out. > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> it always has, but rails may have been accidentally requiring it for > you > > FredThat makes sense. Thanks Fred. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.