Forum: RSpec get_via_redirect in controller specs

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.
Andrew P. (Guest)
on 2009-05-26 17:52
(Received via mailing list)
Want to do the following in my controller spec

describe CheckoutController, "handling stale session" do

  before do
   session[:order_id] = 5
   Order.delete_all
 end

 it "should not throw a 404" do
   get_via_direct :index
 end

Getting the following error message,

NoMethodError in 'CheckoutController handling stale session should not
throw
a 404'
undefined method `get_via_redirect' for
#<Spec::Rails::Example::ControllerExampleGroup::Subclass_1:0x21cc080>

not sure why I can call 'get' and 'put' but can't call this method


Rails 2.3.2
RSpec 1.2.6

TIA

Andrew
David C. (Guest)
on 2009-05-26 18:09
(Received via mailing list)
On Tue, May 26, 2009 at 9:42 AM, Andrew P. 
<removed_email_address@domain.invalid>
wrote:
>  end
> Getting the following error message,
> NoMethodError in 'CheckoutController handling stale session should not throw
> a 404'
> undefined method `get_via_redirect' for
> #<Spec::Rails::Example::ControllerExampleGroup::Subclass_1:0x21cc080>
>
> not sure why I can call 'get' and 'put' but can't call this method

get_via_direct is available in ActionController::IntegrationTest, not
ActionController::TestCase, which is what is wrapped by controller
specs.

HTH,
David
Andrew P. (Guest)
on 2009-05-26 19:31
(Received via mailing list)
2009/5/26 David C. <removed_email_address@domain.invalid>

> >  it "should not throw a 404" do
>
> get_via_direct is available in ActionController::IntegrationTest, not
> ActionController::TestCase, which is what is wrapped by controller
> specs.
>
> HTH,
> David
>

Thanks David, seems that I should write a feature for this instead using
Cucumber.
This topic is locked and can not be replied to.