Sha256: 4d9d4ef1893864ea6f3f3e4515e160a9f38a6f2bb7baadffdb3b156d0890c9e9

Contents?: true

Size: 1.88 KB

Versions: 32

Compression:

Stored size: 1.88 KB

Contents

require 'test/unit'
require 'rubygems'
require 'flexmock/test_unit'
require 'mocha'

require File.dirname(__FILE__)+'/../lib/facebooker/rails/test_helpers'

$: << File.join(File.dirname(__FILE__), '..', 'lib')

rails_root = File.join(File.dirname(__FILE__),'..','..')
if defined? RAILS_ROOT
  RAILS_ROOT.replace(rails_root)
else
  RAILS_ROOT = rails_root
end

require 'facebooker'

class Test::Unit::TestCase
  include Facebooker::Rails::TestHelpers
    
  private
  
  def expect_http_posts_with_responses(*responses_xml)
    mock_http = establish_session
    responses_xml.each do |xml_string|
      mock_http.should_receive(:post_form).and_return(xml_string).once.ordered(:posts)
    end   
  end
  
  def establish_session(session = @session)
    mock = flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml).once.ordered(:posts)
    mock.should_receive(:post_form).and_return(example_get_session_xml).once.ordered(:posts)
    session.secure!    
    mock
  end
  
  def example_auth_token_xml
    <<-XML
    <?xml version="1.0" encoding="UTF-8"?>
    <auth_createToken_response xmlns="http://api.facebook.com/1.0/" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
        3e4a22bb2f5ed75114b0fc9995ea85f1
        </auth_createToken_response>    
    XML
  end
  
  def example_get_session_xml
    <<-XML
    <?xml version="1.0" encoding="UTF-8"?>
    <auth_getSession_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
      <session_key>5f34e11bfb97c762e439e6a5-8055</session_key>
      <uid>8055</uid>
      <expires>1173309298</expires>
      <secret>ohairoflamao12345</secret>
    </auth_getSession_response>    
    XML
  end  
end

Version data entries

32 entries across 32 versions & 9 rubygems

Version Path
al-facebooker-1.0.12.1 test/test_helper.rb
al-facebooker-1.0.12 test/test_helper.rb
al-facebooker-1.0.9 test/test_helper.rb
cwninja-facebooker-1.0.8 test/test_helper.rb
djanowski-facebooker-1.0.1 test/test_helper.rb
djanowski-facebooker-1.0.10 test/test_helper.rb
djanowski-facebooker-1.0.11 test/test_helper.rb
djanowski-facebooker-1.0.12 test/test_helper.rb
djanowski-facebooker-1.0.2 test/test_helper.rb
djanowski-facebooker-1.0.4 test/test_helper.rb
djanowski-facebooker-1.0.7 test/test_helper.rb
djanowski-mmangino-facebooker-1.0.4 test/test_helper.rb
hashrocket-clearance-0.4.0 test/rails_root/vendor/plugins/facebooker/test/test_helper.rb
hashrocket-clearance-0.4.1 test/rails_root/vendor/plugins/facebooker/test/test_helper.rb
hashrocket-clearance-0.4.2 test/rails_root/vendor/plugins/facebooker/test/test_helper.rb
hashrocket-clearance-0.4.3 test/rails_root/vendor/plugins/facebooker/test/test_helper.rb
mmangino-facebooker-1.0.10 test/test_helper.rb
mmangino-facebooker-1.0.11 test/test_helper.rb
mmangino-facebooker-1.0.12 test/test_helper.rb
mmangino-facebooker-1.0.13 test/test_helper.rb