Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Omniauth in Rails

We are starting to develop a new website using Rails 3, RSpec 2, and OmniAuth 2. We wanted to follow TDD using RSpec to write the authentication, but we actually don't know where to start. We don't want to test the gem, as it had already been tested, but we want to test the flow of the application and it has routed correctly according to the outcome of the callback.

The best so far is we categorized the problem in two stages: 1- Before the callback: Faking the services like facebook and twitter to return the calls 2- After the callback: getting the results and creating the user and related service

Please guide us and shed us some light :)

like image 611
AsemRadhwi Avatar asked Dec 17 '22 14:12

AsemRadhwi


1 Answers

Did you checkout the Wiki?

** Edit **

Perhaps something like (untested):

before do
  OmniAuth.config.mock_auth[:twitter] = {
    'uid' => '123545'
  }
end

it "sets a session variable to the OmniAuth auth hash" do
  controller.session[:auth_hash]['uid'].should == '123545'
end
like image 158
monocle Avatar answered Dec 28 '22 06:12

monocle