Spec For Requesting Myopenid.com


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.