tristandunn / pusher-fake

A fake Pusher server for development and testing.
https://rubygems.org/gems/pusher-fake
MIT License
173 stars 32 forks source link

null body from pusher-fake causing error #14

Closed kbaum closed 11 years ago

kbaum commented 11 years ago

I am trying to use pusher within my tests and i am getting a null body which causes the following error:

 Dashboard top traffic sources shows top traffic sources
     Failure/Error: 2.times{ create :activity, action: 'space details viewed', visit: create(:visit, referer: 'http://blah.rfr.com'), subject: space_vts }
     NoMethodError:
       undefined method `inject' for nil:NilClass
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/request.rb:110:in `symbolize_first_level'
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/request.rb:93:in `handle_response'
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/request.rb:52:in `send_sync'
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/resource.rb:18:in `post'
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/client.rb:134:in `post'
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/client.rb:216:in `trigger'
     # /mnt/home/u41/bundle/ruby/1.9.1/gems/pusher-0.11.2/lib/pusher/channel.rb:59:in `trigger!'
     # ./app/models/space_activity_observer.rb:13:in `publish'
     # ./app/models/space_activity_observer.rb:5:in `after_create'

When i put a breakpoint in, this is what i see in the body:

http://grab.by/juqW

I am using

ruby 1.9.3 pusher 0.11.2 pusher-fake-0.6.0

I have this in my application.rb (rails) to start pusher:

https://gist.github.com/4683074

thx!

-karl

tristandunn commented 11 years ago

This could possibly be related to my REST API endpoint implementation. Would you mind providing the response or error from here? If that checks out, could you also provide more information on the event that's triggering the error?

kbaum commented 11 years ago

Ok.. turns out it was a problem with my Pusher.app_id not being set before PusherFake is configured. This caused the regexp's not to match within the server's switch statement and hence the null being returned as a response. Now I am running into another issue but i will open up another ticket for that :-).

kbaum commented 11 years ago

Actually.. i'm not opening a new issue. Everything is working perfectly now!

tristandunn commented 11 years ago

Nice! I'll probably add an error for invalid paths to make this a little more obvious. Thanks for the feedback.