I am having trouble apologizing for RSpec for the OmniauthCallbacksController, do some research on this and it works for me. I add my codes here if someone finds it necessary. Tests for a bon voyage :)
require 'spec_helper' describe OmniauthCallbacksController do describe "#linkedin" do let(:current_user) { Fabricate(:user) } before(:each) do OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:linkedin] = OmniAuth::AuthHash.new({provider: :linkedin, uid: '12345', credentials: {token: 'linkedin-token', secret: 'linkedin-secret'}}) request.env["devise.mapping"] = Devise.mappings[:user] @controller.stub!(:env).and_return({"omniauth.auth" => OmniAuth.config.mock_auth[:linkedin]}) User.stub(:from_auth).and_return(current_user) end describe "#linkedin" do context "with a new linkedin user" do before { get :linkedin } it "should authenticate user" do warden.authenticated?(:user).should == true end it "should set current_user" do subject.current_user.should_not be_nil end it "should redirect to root_path" do response.should redirect_to(root_path) end end end end end
source share