oren
2010-Oct-20 02:15 UTC
[rspec-users] rspec 2 - undefined method `redirect_to?'' for #<Rack::MockResponse:0xa43ef14>
I try to test sinatra app using rspec 2.0.0 and rack-test 0.5.6 it "redirect non-authenticated user to logout page" do get ''/'' last_response.should be_redirect_to(''/login) end and I get: undefined method `redirect_to?'' for #<Rack::MockResponse:0xa43ef14> where can I find reference/guide for methods I can use in rspec 2? I think it might be here, but I am not sure where: http://github.com/rspec/rspec http://github.com/rspec/rspec-core Thanks!
David Chelimsky
2010-Oct-20 04:55 UTC
[rspec-users] rspec 2 - undefined method `redirect_to?'' for #<Rack::MockResponse:0xa43ef14>
On Oct 19, 2010, at 9:15 PM, oren wrote:> I try to test sinatra app using rspec 2.0.0 and rack-test 0.5.6 > > it "redirect non-authenticated user to logout page" do > get ''/'' > last_response.should be_redirect_to(''/login) > end > > and I get: > undefined method `redirect_to?'' for #<Rack::MockResponse:0xa43ef14>Take a look at http://relishapp.com/rspec/rspec-expectations/v/2-0/dir/matchers/predicate-matchers to see how be_redirect_to tries to delegate to redirect_to? on the responses. There is a redirect_to matcher in rspec-rails, but it delegates to a Rails-specific assertion (assert_redirected_to), so you''re not going to get that one in a Sinatra app.> where can I find reference/guide for methods I can use in rspec 2? > I think it might be here, but I am not sure where: > http://github.com/rspec/rspec > http://github.com/rspec/rspec-coreDocumentation is there, plus: http://github.com/rspec/rspec-expectations http://github.com/rspec/rspec-mocks http://relishapp.com/rspec And, of course, The RSpec Book: http://pragprog.com/titles/achbd/the-rspec-book HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101019/7c78d8ed/attachment.html>
oren
2010-Oct-20 20:11 UTC
[rspec-users] rspec 2 - undefined method `redirect_to?'' for #<Rack::MockResponse:0xa43ef14>
thanks! On Oct 20, 4:55?am, David Chelimsky <dchelim... at gmail.com> wrote:> On Oct 19, 2010, at 9:15 PM, oren wrote: > > > I try to test sinatra app using rspec 2.0.0 and rack-test 0.5.6 > > > ?it "redirect non-authenticated user to logout page" do > > ? ?get ''/'' > > ? ?last_response.should be_redirect_to(''/login) > > ?end > > > and I get: > > undefined method `redirect_to?'' for #<Rack::MockResponse:0xa43ef14> > > Take a look athttp://relishapp.com/rspec/rspec-expectations/v/2-0/dir/matchers/pred...to see how be_redirect_to tries to delegate to redirect_to? on the responses. > > There is a redirect_to matcher in rspec-rails, but it delegates to a Rails-specific assertion (assert_redirected_to), so you''re not going to get that one in a Sinatra app. > > > where can I find reference/guide for methods I can use in rspec 2? > > I think it might be here, but I am not sure where: > >http://github.com/rspec/rspec > >http://github.com/rspec/rspec-core > > Documentation is there, plus: > > http://github.com/rspec/rspec-expectationshttp://github.com/rspec/rspec-mocks > > http://relishapp.com/rspec > > And, of course, The RSpec Book:http://pragprog.com/titles/achbd/the-rspec-book > > HTH, > David > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users