Created
December 3, 2012 19:07
-
-
Save NobbZ/4197170 to your computer and use it in GitHub Desktop.
Redirecting open-method for rspec test that I dont have to rely on availability of an API-Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
def User < ActiveRecord::Base | |
def update_user | |
xml = Nokogiri::XML(open("http://example.com/api/#{pkey}/#{ukey}")) | |
self.name = xml.xpath('hordes/headers/owner/citizen').first['name'] | |
self.avatar = xml.xpath('hordes/headers/owner/citizen').first['avatar'] | |
self.last_update = Time.now | |
self.save | |
self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment