Skip to content

Instantly share code, notes, and snippets.

@NobbZ
Created December 3, 2012 19:07
Show Gist options
  • Save NobbZ/4197170 to your computer and use it in GitHub Desktop.
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
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