Posted By

sou on 03/07/08


Tagged

textmate rspec ruby openid


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

wbowers
webstic
illogic


Spec For Requesting Myopenid.com


 / Published in: Ruby
 

  1. require 'open-uri'
  2. require 'rubygems'
  3. require 'openid'
  4. # require 'openid/extensions/sreg'
  5. # require 'openid/extensions/pape'
  6. # require 'openid/store/filesystem'
  7. require 'spec'
  8.  
  9. describe "OpenID Request" do
  10. before(:each) do
  11. @claimed_identifier = "http://sou.myopenid.com/"
  12. @op_endpoint = "http://www.myopenid.com/server"
  13. @local_id = "http://sou.myopenid.com/"
  14. end
  15.  
  16. def do_request(uri)
  17. open(uri) do |response|
  18. yield response if block_given?
  19. end
  20. end
  21.  
  22. it "should discover XRDS document" do
  23. do_request(@claimed_identifier) do |response|
  24. response.meta.should be_has_key('x-xrds-location')
  25. xrds_location = response.meta['x-xrds-location']
  26. do_request(xrds_location) do |response|
  27. # xrds = OpenID::Yadis::parseXRDS(response.read)
  28. xrds = response.read
  29. xrds.should =~ Regexp.new(@op_endpoint)
  30. xrds.should =~ Regexp.new(@local_id)
  31. end
  32. end
  33. end
  34.  
  35. end

Report this snippet  

You need to login to post a comment.