ruby on rails - HTTP basic auth for Capybara -
i'm writing rspec tests rails 3 application , trying switch webrat capybara. far application uses http basic auth authorize admin user, idea how can test capybara?
here current webrat step:
it 'should authenticate admin' basic_auth('user', 'secret') visit '/admin' response.status.should eql 200 response.status.should_not eql 401 end
how do capybara? thanks!
i got work using page.driver.basic_authorize(name, password)
instead
update:
at moment, after capybara upgrade, i'm using pile of workarounds:
if page.driver.respond_to?(:basic_auth) page.driver.basic_auth(name, password) elsif page.driver.respond_to?(:basic_authorize) page.driver.basic_authorize(name, password) elsif page.driver.respond_to?(:browser) && page.driver.browser.respond_to?(:basic_authorize) page.driver.browser.basic_authorize(name, password) else raise "i don't know how log in!" end
Comments
Post a Comment