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

Very close - but stuck #13

Closed barmstrong closed 11 years ago

barmstrong commented 11 years ago

Hi Tristan,

Awesome gem - was totally looking for something like this!

I'm very close but still not getting it to receive any messages. I think I've copied the code almost exactly.

In my view:

<%== PusherFake.javascript if defined?(PusherFake) %>

Pusher.instance = new Pusher(<%== Pusher.key.to_json %>);

var Chat = Pusher.instance.subscribe("chat");
Chat.bind("message", function(message) {
  console.log('foo');
  console.log(message);
});

And in my model:

puts "make sure this runs"
Pusher["chat"].trigger('message', {a: 1})

I've tried it with and without my development credentials (not sure if this is needed).

if !Rails.env.production?
  Pusher.app_id = '....'
  Pusher.key    = '....'
  Pusher.secret = '....'
end

Still not luck - do you have any idea why it might not be working? Thanks for the help!

tristandunn commented 11 years ago

Which version of the Pusher gem are you using? Also, how and where are you starting the server?

barmstrong commented 11 years ago

gem version 0.6.0

Yeah...so starting the server. I thought there might be something like this. But didn't see it in the example or readme (figured it might be running through the same thin that was doing the web server in development). Silly mistake. Guess I should have dug in a bit further - so how does one start the server? :/

tristandunn commented 11 years ago

No worry.

If you're using it in Cucumber, it's super simple. If not, check out what pusher-fake/cucumber does to start it.

tristandunn commented 11 years ago

Going to go ahead and close this. Feel free to reopen if there are any further issues.