Stubbing out OpenID: integration edition

This is an update to Stubbing out OAuth or OpenID, on how everything hangs together now.

I have a file “spec/stub_openid.rb”, which contains:

require 'openid'
require 'openid/extensions/ax'
require 'gapps_openid'

class OpenID::Consumer
  def begin(*args)
    o =
    class << o
      def add_extension(*args)

      def redirect_url(*args)

  def complete(*args) => OpenID::Consumer::SUCCESS)

class OpenID::AX::FetchResponse
  def self.from_success_response(response) => { "" => })

This has changed slightly from the previous version. We’re now doing some fancy meta stuff because the gapps_openid extension – required to make the openid library find the accounts hosted under Google Apps for Your Domain – changes the way the extension works a bit.

Because the library names are a bit nutty, we have these two gemfile lines:
gem “ruby-openid”, “2.1.8”, :require => [‘openid’, ‘openid/extensions/ax’]
gem “ruby-openid-apps-discovery”, “1.2.0”, :require => ‘gapps_openid’

That stub_openid.rb file is ignored in production, and those two lines mean the library gets included properly. Thanks, bundler!

In order to make the library not be hit in the cucumber environment, our config/environments/cucumber.rb file requires ‘spec/stub_openid’.

And now it’s time for rainbows and unicorns.

One thought on “Stubbing out OpenID: integration edition

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s