Somehow the wrong response XML is being sent. I would try breaking
that up into 3 tests and try to trace down where that XML is coming
from.
Mike
On Dec 15, 2008, at 8:43 PM, George Deglin wrote:
> A couple of months ago I forked facebooker and pushed a bunch of
> patches I''ve written for work to the fork. Today I finally had
some
> time to write tests so I can submit the patches to core.
>
> This is my first time working with test_unit and I''m having some
> trouble getting the very first test I''m trying to write working.
>
> The patch I''m writing the test for is to fix a caching bug with
> events. A similar patch was pushed to core a few days ago but it only
> fixed @user.events and not @session.events.
>
> The patched version is:
> session.rb
>
> def events(options = {})
> @events ||= {}
> @events[options.to_s] = post(''facebook.events.get'',
options) do
> |response|
> response.map do |hash|
> Event.from_hash(hash)
> end
> end
> end
>
> The test I''m trying to get working is:
> session_test.rb
>
> def test_events_caching_honors_params
> expect_http_posts_with_responses(example_events_get_xml)
> Facebooker::Event.expects(:from_hash)
> @session.events
> Facebooker::Event.expects(:from_hash)
> @session.events(:eids => "1,2")
> Facebooker::Event.expects(:from_hash).never
> @session.events(:eids => "1,2")
> end
>
> When I run the test I get the following error:
> test_events_caching_honors_params(SessionTest):
> RuntimeError: Element events_get_response not found in <?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>
> ./test/../lib/facebooker/parser.rb:48:in `element''
> ./test/../lib/facebooker/parser.rb:373:in `process''
> ./test/../lib/facebooker/parser.rb:17:in `parse''
> ./test/../lib/facebooker/service.rb:14:in `post''
> ./test/../lib/facebooker/session.rb:486:in `post_without_loggin
> ./test/../lib/facebooker/session.rb:498:in `post''
> ./test/../lib/facebooker/logging.rb:27:in `log_fb_api''
> c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
> c:/ruby/lib/ruby/1.8/benchmark.rb:307:in `realtime''
> ./test/../lib/facebooker/logging.rb:27:in `log_fb_api''
> ./test/../lib/facebooker/session.rb:497:in `post''
> ./test/../lib/facebooker/session.rb:201:in `events''
> test/session_test.rb:141:in `test_events_caching_honors_params''
>
> I''ve been trying to get this work for over an hour now. It seems
that
> @session.events works fine but when I call @session.events(:eids =>
> "1,2") I get the error above.
>
> Any idea where I might be going wrong?
>
> Thanks!
> _______________________________________________
> Facebooker-talk mailing list
> Facebooker-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/facebooker-talk
--
Mike Mangino
http://www.elevatedrails.com