Sha256: ceb3fc52e9d55bdc977b68591d929a902376b03bdcef131b01325f96fb28a661

Contents?: true

Size: 1012 Bytes

Versions: 3

Compression:

Stored size: 1012 Bytes

Contents

require 'test_helper'
require 'yaml'

# sets up a socialize faker.
#
# example::
# <tt>
# FakeSocialize.setup_response("disconnect", :success)
# </tt>
class FakeSocialize
  
  @@responses ||= {}

  def self.setup_response(method_ref, response_name)
    reload_responses if @@responses.nil? || @@responses.empty?
    response = @@responses[method_ref]
    FakeWeb.register_uri(
      response[:request_type], 
      Regexp.new(Giggly::Rest::Socialize::GIGYA_URL + response[:method_name]), 
      :body => response[response_name]
    )
    return response.merge({:response_key => "socialize.#{response[:method_name]}Response"})
  end
  
  def self.reload_responses
    responses = {}
    Dir.new(File.join(File.dirname(__FILE__), 'responses')).each do |filename|
      file_path = File.join(File.dirname(__FILE__), 'responses', filename)
      next unless File.file?(file_path)
      responses.merge!(YAML.load(File.read(file_path))) if File.file?(file_path) 
    end
    @@responses = responses 
  end
  
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
giggly-0.1.2 test/fake_socialize.rb
giggly-0.1.1 test/fake_socialize.rb
giggly-0.1.0 test/fake_socialize.rb