Coder Social home page Coder Social logo

tristandunn / pusher-fake-example Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 3.0 260 KB

An example of pusher-fake with RSpec to test a Rails application.

Home Page: https://github.com/tristandunn/pusher-fake

License: MIT License

Ruby 9.27% JavaScript 89.12% HTML 1.61%
pusher pusherjs fake pusher-js pusher-api pusher-service

pusher-fake-example's Introduction

pusher-fake-example Build Status

An example of using pusher-fake with RSpec to test a Rails application.

How-To

1. Use the PusherFake JS for the Pusher JS instance.

<script>
  <% if defined?(PusherFake) %>
    // Test environment.
    //
    // Note: Ensure output is not HTML escaped, such as with the raw helper in Rails.
    var instance = <%= PusherFake.javascript %>;
  <% else %>
    // Other environments, such as production.
    var instance = new Pusher(...);
  <% end %>
</script>

2. Configure and start PusherFake in your RSpec environment.

require "pusher-fake/support/rspec"

3. Enjoy testing your Pusher application!

License

pusher-fake-example uses the MIT license. See LICENSE for more details.

pusher-fake-example's People

Contributors

lpender avatar pik avatar tristandunn avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pusher-fake-example's Issues

ssl handshake failed when using unencrypted websocket connection

The following error repeats for exactly 44 seconds on page load, and then finally the websocket connection will succeed. After that communication works fine. I'm running from the background javascript page of a chrome extension on same localhost. localhost is 64bit Ubuntu 14.04 LTS with Chrome 49

I don't understand why ssl is coming in to play at all? I've tried to set every relevant configuration on pusher fake server and javascript client to be unencrypted.

[16219:16258:0312/154027:ERROR:ssl_client_socket_openssl.cc(1149)] handshake failed; returned -1, SSL error code 1, net
_error -100
[16219:16258:0312/154027:ERROR:ssl_client_socket_openssl.cc(1149)] handshake failed; returned -1, SSL error code 1, net
_error -100
[16219:16219:0312/154027:INFO:CONSOLE(228)] "Pusher : Connecting : {"transport":"ws","url":"ws://localhost:50389/app/?protocol=7&client=js&version=3.0.0&flash=false"}", source: chrome-extension:///background.js (228)

pusher-js-3.0.0.js
var pusher = new Pusher(PUSHER_API_KEY, {
wsHost: 'localhost',
wsPort: 50389,
httpHost: 'localhost',
httpPort: 39381,
encrypted: false,
disableStats: true,

        enabledTransports: ["ws"],
        authEndpoint: PUSHER_AUTH_URL,
        auth: {
            headers: {
                'Authorization': authToken
            }
        }
    });

Config in pusher.rb

config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?

Pusher.app_id = ENV["PUSHER_APP_ID"]
Pusher.key = ENV["PUSHER_API_KEY"]
Pusher.secret = ENV["PUSHER_API_SECRET"]

PUSHER_HTTP_HOST = ENV["PUSHER_HTTP_HOST"] # 39381
HTTP_PORT = ENV["PUSHER_HTTP_PORT"] #localhost
PUSHER_WS_PORT = ENV["PUSHER_WS_PORT"] # 50389
PUSHER_WS_HOST = ENV["PUSHER_WS_HOST"] #localhost

require "pusher-fake"

Thin::Logging.silent = false
PusherFake.configuration.verbose = true
PusherFake.configuration.web_options = { host: PUSHER_HTTP_HOST, port: HTTP_PORT }
PusherFake.configuration.socket_options = { host: PUSHER_WS_HOST, port: PUSHER_WS_PORT, secure: false }

require "pusher-fake/support/base"

---Log---
No logging after boot until the 44 second mark.

=> Booting Thin
=> Rails 4.2.5 application starting in development on http://0.0.0.0:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
PusherFake socket_options
{:host=>"localhost", :port=>"50389", :secure=>false}
PusherFake web_options
{:host=>"localhost", :port=>"39381"}
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

Gemfile in pusher-fake-example:
source "https://rubygems.org"

gem "pusher", "0.17.0"
gem "pusher-fake", "1.5.0"
gem "rails", "4.2.5"
gem "thin", "1.6.4"
gem "eventmachine", "1.0.9.1"

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.