addressalign-toparrow-leftarrow-leftarrow-right-10x10arrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1languagelaunch-new-window--smalllight-bulblightning-boltlinklocation-pinlockm-swarmSearchmailmediummessagesminusmobilemoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstar-shapestartickettrashtriangle-downtriangle-uptwitteruserwarningyahooyoutube

Re: [ruby-81] RETRY: rails rspec integration_tests and http authentication

From: Al C.
Sent on: Saturday, March 2, 2013, 10:12 PM
Looks like you would have to call the authorize method on page.driver.browser, because not all drivers support HTTP Basic Authentication:



Al



On Sat, Mar 2, 2013 at 9:32 PM, Jon Seidel <[address removed]> wrote:

(No idea why the formatting was wierd - looked fine on my end. Hope this is better)

=====================

I am using Rspec 2 and capybara and defined the basic integration test, i.e.

describe "EeRequisitions" do

describe "GET /ee_requisitions" do

it "works! (now write some real specs)" do

get ee_requisitions_path

response.status.should be(200)

end

end

end

Since the app uses HTTP basic authentication and since capybara says it includes Rack::Test, I expected that adding the line:

authorize 'user', 'password'

would handle it (I've since lost the stackoverflow post that told me that). Unfortunately it didn't - it kept throwing a 'method not found' error. I finally found the solution in a comment to this post: Rails/Rspec Make tests to pass with http basic authentication where Matt Connelly pointed me to this gist:https://gist.github.com/mattconnolly/4158961 which finally solved my problem.

So what I do now is call the function (defined in spec/support/auth_helper.rb)

http_login('user','password')

and replace this line:

get ee_requistitions_path

with:

get ee_requisitions_path, {}, @env

However, I'm still wondering why the Rack::Test approach failed as it seems to have worked for

others. Any suggestions on where to look for greater understanding would be appreciated as this is

Thanks much...jon

Jon Seidel, CMC®

EDP Consulting, Inc. / www.edpci.com / www.4mypasswords.com

Effective Decisions... Priceless





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jon Seidel ([address removed]) from The East Bay Ruby Meetup Group.
To learn more about Jon Seidel, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]



--
Finding a solution to a problem requires different thinking from that which created the problem. - paraphrasing Albert Einstein

People in this
group are also in: