class MockIdentity; end describe OmniAuth::Strategies::Identity do attr_accessor :app let(:auth_hash){ last_response.headers['env']['omniauth.auth'] } let(:identity_hash){ last_response.headers['env']['omniauth.identity'] } # customize rack app for testing, if block is given, reverts to default # rack app after testing is done def set_app!(identity_options = {}) identity_options = {:model => MockIdentity}.merge(identity_options) old_app = self.app self.app = Rack::Builder.app do use Rack::Session::Cookie, secret: '1234567890qwertyuiop' use OmniAuth::Strategies::Identity, identity_options run lambda{|env| [404, {'env' => env}, ["HELLO!"]]} end if block_given? yield self.app = old_app end self.app end before(:all) do set_app! end describe '#request_phase' do it 'should display a form' do get '/auth/identity' expect(last_response.body).to be_include("