steven shingler
2008-Apr-28 15:31 UTC
[rspec-users] story runner on restful_authentication question
Hi all, Have been following: http://www.tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app ..as an introduction into the story runner. It shows how to get a couple of scenarios going to test the restful_authenticated plugin from plain text stories. I thought I''d go completely bonkers and try and add a story of my own :) Scenario: Registered user logs in Given a username ''jdoe'' And a password ''letmein'' And an existing user with these credentials When the user logs in with username and password Then should redirect to ''/'' And I added these steps to try and make this pass: Given "an existing user with these credentials" do @user = User.new({ :login => @username, :password => @password, :password_confirmation => @password, :email => "jdoe at test.comm" }) @user.save User.find_by_login(@username).should_not be_nil end When "the user logs in with username and password" do post "/sessions/create", :user => { :login => @username, :password => @password } end Then "should redirect to ''$path''" do |path| response.should redirect_to(path) end However, I''m getting a Spec::Expectations::ExpectationNotMetError: expected redirect to "/", got no redirect So the user is definitely being created in the test database, but the login doesn''t seem to work, or to do the redirect. I must be doing something silly. If anyone could point me in the right direction, I''d be very grateful. Thanks very much, Steven
Pat Maddox
2008-Apr-28 16:10 UTC
[rspec-users] story runner on restful_authentication question
On Mon, Apr 28, 2008 at 8:31 AM, steven shingler <shingler at gmail.com> wrote:> However, I''m getting a > Spec::Expectations::ExpectationNotMetError: expected redirect to "/", > got no redirectOften when this happens, it''s because an error occurs in the request. You can tail test.log to see if there are any exceptions being thrown. My initial guess is that your request needs to be post "/sessions" instead of post "/sessions/create" Pat
Andy Watts
2008-Apr-28 19:51 UTC
[rspec-users] story runner on restful_authentication question
Assuming there''s nothing helpful in test.log.. Adding ''debugger'' to the misfiring steps may help troubleshoot this.. You''ll prolly need to add the following to your helper.rb first. require ''rubygems'' require ''ruby-debug'' Re-run the story and it should stop at the debugger. Between manually submitting requests and inspecting test.log you should get further. - Andy -- View this message in context: http://www.nabble.com/story-runner-on-restful_authentication-question-tp16941586p16945873.html Sent from the rspec-users mailing list archive at Nabble.com.
Bart Zonneveld
2008-Apr-28 20:16 UTC
[rspec-users] story runner on restful_authentication question
On 28 apr 2008, at 17:31, steven shingler wrote:> > When "the user logs in with username and password" do > post "/sessions/create", :user => { :login => @username, :password > => @password } > endTry post_via_redirect... greetz, bartz
Rick DeNatale
2008-Apr-29 10:46 UTC
[rspec-users] story runner on restful_authentication question
On Mon, Apr 28, 2008 at 4:16 PM, Bart Zonneveld <loop at superinfinite.com> wrote:> > On 28 apr 2008, at 17:31, steven shingler wrote: > > > > > When "the user logs in with username and password" do > > post "/sessions/create", :user => { :login => @username, :password > > => @password } > > end > > > > Try post_via_redirect...No that will make his "should redirect to ''$path" step fail since it will eat the redirect response and follow it. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/
Bart Zonneveld
2008-Apr-29 10:49 UTC
[rspec-users] story runner on restful_authentication question
On 29-apr-2008, at 12:46, Rick DeNatale wrote:> On Mon, Apr 28, 2008 at 4:16 PM, Bart Zonneveld > <loop at superinfinite.com> wrote: >> >> On 28 apr 2008, at 17:31, steven shingler wrote: >> >>> >>> When "the user logs in with username and password" do >>> post "/sessions/create", :user => { :login => @username, :password >>> => @password } >>> end >>> >> >> Try post_via_redirect... > > No that will make his "should redirect to ''$path" step fail since it > will eat the redirect response and follow it.Ack, brainfart. I mixed up the two in my head. gr, bartz
steven shingler
2008-Apr-29 10:51 UTC
[rspec-users] story runner on restful_authentication question
Thank you for all the replies. I''m unable to use ruby-debug, cos am running on JRuby, but a liberal sprinkling of logger.debug in the controllers helped me sort out what was going on the test.log. Thanks for that tip. It made me want for a way of writing something to the log from within the rspec step though - is there a quick way of doing that? Cheers, Steven On Mon, Apr 28, 2008 at 9:16 PM, Bart Zonneveld <loop at superinfinite.com> wrote:> > On 28 apr 2008, at 17:31, steven shingler wrote: > > > > > When "the user logs in with username and password" do > > post "/sessions/create", :user => { :login => @username, :password > > => @password } > > end > > > > Try post_via_redirect... > > greetz, > bartz > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Rick DeNatale
2008-Apr-29 11:36 UTC
[rspec-users] story runner on restful_authentication question
On Tue, Apr 29, 2008 at 6:51 AM, steven shingler <shingler at gmail.com> wrote:> Thank you for all the replies. > I''m unable to use ruby-debug, cos am running on JRuby,I haven''t yet used JRuby, but there seems to be a JRuby wrapper for rdebug http://wiki.jruby.org/wiki/Using_the_JRuby_Debugger -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/
steven shingler
2008-Apr-29 12:33 UTC
[rspec-users] story runner on restful_authentication question
ooh - good spot! thanks :) On Tue, Apr 29, 2008 at 12:36 PM, Rick DeNatale <rick.denatale at gmail.com> wrote:> On Tue, Apr 29, 2008 at 6:51 AM, steven shingler <shingler at gmail.com> wrote: > > Thank you for all the replies. > > I''m unable to use ruby-debug, cos am running on JRuby, > > I haven''t yet used JRuby, but there seems to be a JRuby wrapper for rdebug > > http://wiki.jruby.org/wiki/Using_the_JRuby_Debugger > > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > _______________________________________________ > > > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >