Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes spec_helper require calls

  • Loading branch information...
commit 0aa7e05620b88d365b12ee11f7ce5d5a6fdb3e12 1 parent 7ef401b
@langalex langalex authored
View
10 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- slanger (0.3.2)
+ slanger (0.3.4)
activesupport (~> 3.1.0)
em-hiredis (~> 0.1.0)
em-http-request (~> 0.3.0)
@@ -21,7 +21,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.8)
crack (0.1.8)
- daemons (1.1.8)
+ daemons (1.1.9)
diff-lcs (1.1.3)
em-hiredis (0.1.1)
hiredis (~> 0.4.0)
@@ -29,18 +29,20 @@ GEM
addressable (>= 2.0.0)
escape_utils
eventmachine (>= 0.12.9)
- em-websocket (0.3.6)
+ em-websocket (0.3.8)
addressable (>= 2.1.1)
eventmachine (>= 0.12.9)
escape_utils (0.2.4)
eventmachine (0.12.10)
+ eventmachine (0.12.10-java)
glamazon (0.3.1)
activesupport (>= 3.1.0)
i18n (~> 0.6.0)
yajl-ruby (>= 0.7.7)
haml (3.1.5)
hiredis (0.4.5)
- i18n (0.6.0)
+ hiredis (0.4.5-java)
+ i18n (0.6.1)
metaclass (0.0.1)
mocha (0.12.0)
metaclass (~> 0.0.1)
View
2,154 coverage/index.html
@@ -4,20 +4,20 @@
<title>Code coverage for Slanger</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src='./assets/0.5.3/jquery-1.6.2.min.js' type='text/javascript'></script>
- <script src='./assets/0.5.3/jquery.dataTables.min.js' type='text/javascript'></script>
- <script src='./assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js' type='text/javascript'></script>
- <script src='./assets/0.5.3/jquery.timeago.js' type='text/javascript'></script>
- <script src='./assets/0.5.3/jquery.url.js' type='text/javascript'></script>
- <script src='./assets/0.5.3/highlight.pack.js' type='text/javascript'></script>
- <script src='./assets/0.5.3/app.js' type='text/javascript'></script>
+ <script src='./assets/0.5.3/jquery.dataTables.min.js' type='text/javascript'></script>
+ <script src='./assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js' type='text/javascript'></script>
+ <script src='./assets/0.5.3/jquery.timeago.js' type='text/javascript'></script>
+ <script src='./assets/0.5.3/jquery.url.js' type='text/javascript'></script>
+ <script src='./assets/0.5.3/highlight.pack.js' type='text/javascript'></script>
+ <script src='./assets/0.5.3/app.js' type='text/javascript'></script>
<link href='./assets/0.5.3/stylesheet.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
<link href='./assets/0.5.3/highlight.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
<link href='./assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
- <link href='./assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
+ <link href='./assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" type="image/png" href="./assets/0.5.3/favicon_yellow.png" />
<link rel="icon" type="image/png" href="./assets/0.5.3/favicon.png" />
</head>
-
+
<body>
<div id="loading">
<img src="./assets/0.5.3/loading.gif" alt="loading"/>
@@ -41,7 +41,7 @@
<a name="AllFiles"></a>
<div>
<b>6</b> files in total.
- <b>174</b> relevant lines.
+ <b>174</b> relevant lines.
<span class="green"><b>146</b> lines covered</span> and
<span class="red"><b>28</b> lines missed </span>
</div>
@@ -58,7 +58,7 @@
</tr>
</thead>
<tbody>
-
+
<tr>
<td class="strong"><a href="#787b80103a80ab0eb3ae7bbc5e53c63bc3f24f3e" class="src_link" title="lib/slanger/handler.rb">lib/slanger/handler.rb</a></td>
<td class="red strong">42.22 %</td>
@@ -68,7 +68,7 @@
<td>26</td>
<td>0.4</td>
</tr>
-
+
<tr>
<td class="strong"><a href="#b09d5d3581ebe42f88f9eba7e18cb80cee007e35" class="src_link" title="spec/integration/integration_spec.rb">spec/integration/integration_spec.rb</a></td>
<td class="green strong">100.0 %</td>
@@ -78,7 +78,7 @@
<td>0</td>
<td>1.5</td>
</tr>
-
+
<tr>
<td class="strong"><a href="#9475f908a4ca4dae3d435c8070e444582a98d0a7" class="src_link" title="spec/integration/presence_channel_spec.rb">spec/integration/presence_channel_spec.rb</a></td>
<td class="green strong">100.0 %</td>
@@ -88,7 +88,7 @@
<td>0</td>
<td>2.4</td>
</tr>
-
+
<tr>
<td class="strong"><a href="#2991da51d3ad09b3c19d5d3a1cd38abcc91ace33" class="src_link" title="spec/integration/private_channel_spec.rb">spec/integration/private_channel_spec.rb</a></td>
<td class="green strong">100.0 %</td>
@@ -98,7 +98,7 @@
<td>0</td>
<td>1.4</td>
</tr>
-
+
<tr>
<td class="strong"><a href="#e1e3f2be3aec3da763cc1e77b34c4989c0340d72" class="src_link" title="spec/integration/replaced_handler_spec.rb">spec/integration/replaced_handler_spec.rb</a></td>
<td class="yellow strong">84.62 %</td>
@@ -108,7 +108,7 @@
<td>2</td>
<td>0.9</td>
</tr>
-
+
<tr>
<td class="strong"><a href="#6c32f8e16c3e5229150575f2eadd566e40cf1048" class="src_link" title="spec/integration/ssl_spec.rb">spec/integration/ssl_spec.rb</a></td>
<td class="green strong">100.0 %</td>
@@ -118,2483 +118,2483 @@
<td>0</td>
<td>1.0</td>
</tr>
-
+
</tbody>
</table>
</div>
-
+
</div>
-
+
<div id="footer">
- Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.6.4
+ Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.6.4
and simplecov-html v0.5.3<br/>
using RSpec
</div>
-
+
<div class="source_files">
-
+
<div class="source_table" id="787b80103a80ab0eb3ae7bbc5e53c63bc3f24f3e">
<div class="header">
<h3>lib/slanger/handler.rb</h3>
<h4><span class="red">42.22 %</span> covered</h4>
<div>
- <b>45</b> relevant lines.
+ <b>45</b> relevant lines.
<span class="green"><b>19</b> lines covered</span> and
<span class="red"><b>26</b> lines missed.</span>
</div>
</div>
-
+
<pre>
<ol>
-
+
<li class="never" data-hits="" data-linenumber="1">
-
-
+
+
<code class="ruby"># Handler class.</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="2">
-
-
+
+
<code class="ruby"># Handles a client connected via a websocket connection.</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="3">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
-
+
<code class="ruby">require 'active_support/core_ext/hash'</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
-
+
<code class="ruby">require 'securerandom'</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
-
+
<code class="ruby">require 'signature'</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
-
+
<code class="ruby">require 'fiber'</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="8">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
-
+
<code class="ruby">module Slanger</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
-
+
<code class="ruby"> class Handler</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="11">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
-
+
<code class="ruby"> attr_accessor :connection</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
-
+
<code class="ruby"> delegate :error, :send_payload, to: :connection</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="14">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
-
+
<code class="ruby"> def initialize(socket)</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="16">
-
-
+
+
<code class="ruby"> @socket = socket</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="17">
-
-
+
+
<code class="ruby"> @connection = Connection.new(@socket)</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="18">
-
-
+
+
<code class="ruby"> @subscriptions = {}</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="19">
-
-
+
+
<code class="ruby"> authenticate</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="20">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="21">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="22">
-
-
+
+
<code class="ruby"> # Dispatches message handling to method with same name as</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="23">
-
-
+
+
<code class="ruby"> # the event name</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
-
+
<code class="ruby"> def onmessage(msg)</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="25">
-
-
+
+
<code class="ruby"> msg = JSON.parse msg</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="26">
-
-
+
+
<code class="ruby"> event = msg['event'].gsub(/^pusher:/, 'pusher_')</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="27">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="28">
-
-
+
+
<code class="ruby"> if event =~ /^client-/</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="29">
-
-
+
+
<code class="ruby"> msg['socket_id'] = connection.socket_id</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="30">
-
-
+
+
<code class="ruby"> Channel.send_client_message msg</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="31">
-
-
+
+
<code class="ruby"> elsif respond_to? event, true</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="32">
-
-
+
+
<code class="ruby"> send event, msg</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="33">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="34">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="35">
-
-
+
+
<code class="ruby"> rescue JSON::ParserError</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="36">
-
-
+
+
<code class="ruby"> error({ code: 5001, message: &quot;Invalid JSON&quot; })</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="37">
-
-
+
+
<code class="ruby"> rescue Exception =&gt; e</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="38">
-
-
+
+
<code class="ruby"> error({ code: 500, message: &quot;#{e.message}\n #{e.backtrace}&quot; })</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="39">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="40">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
-
+
<code class="ruby"> def onclose</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="42">
-
-
+
+
<code class="ruby"> @subscriptions.each { |c, s| Channel.unsubscribe c, s }</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="43">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="44">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
-
+
<code class="ruby"> def authenticate</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="46">
-
-
+
+
<code class="ruby"> return connection.establish if valid_app_key?</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="47">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="48">
-
-
+
+
<code class="ruby"> error({ code: 4001, message: &quot;Could not find app by key #{app_key}&quot; })</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="49">
-
-
+
+
<code class="ruby"> @socket.close_websocket</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="50">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="51">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
-
+
<code class="ruby"> def pusher_ping(msg)</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="53">
-
-
+
+
<code class="ruby"> send_payload nil, 'pusher:ping'</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="54">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="55">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
-
+
<code class="ruby"> def pusher_pong msg; end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="57">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="58">
<span class="hits">1</span>
-
+
<code class="ruby"> def pusher_subscribe(msg)</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="59">
-
-
+
+
<code class="ruby"> channel_id = msg['data']['channel']</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="60">
-
-
+
+
<code class="ruby"> klass = subscription_klass channel_id</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="61">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="62">
-
-
+
+
<code class="ruby"> @subscriptions[channel_id] = klass.new(connection.socket, connection.socket_id, msg).subscribe</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="63">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="64">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="65">
<span class="hits">1</span>
-
+
<code class="ruby"> private</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="66">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="67">
<span class="hits">1</span>
-
+
<code class="ruby"> def app_key</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="68">
-
-
+
+
<code class="ruby"> @socket.request['path'].split(/\W/)[2]</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="69">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="70">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="71">
<span class="hits">1</span>
-
+
<code class="ruby"> def valid_app_key?</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="72">
-
-
+
+
<code class="ruby"> Slanger::Config.app_key == app_key</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="73">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="74">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="75">
<span class="hits">1</span>
-
+
<code class="ruby"> def subscription_klass channel_id</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="76">
-
-
+
+
<code class="ruby"> klass = channel_id.match(/^(private|presence)-/) do |match|</code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="77">
-
-
+
+
<code class="ruby"> Slanger.const_get &quot;#{match[1]}_subscription&quot;.classify</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="78">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="79">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="missed" data-hits="0" data-linenumber="80">
-
-
+
+
<code class="ruby"> klass || Slanger::Subscription</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="81">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="82">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="83">
-
-
+
+
<code class="ruby">end</code>
</li>
-
+
</ol>
</pre>
</div>
-
+
<div class="source_table" id="b09d5d3581ebe42f88f9eba7e18cb80cee007e35">
<div class="header">
<h3>spec/integration/integration_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
- <b>16</b> relevant lines.
+ <b>16</b> relevant lines.
<span class="green"><b>16</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
-
+
<pre>
<ol>
-
+
<li class="never" data-hits="" data-linenumber="1">
-
-
+
+
<code class="ruby">#encoding: utf-8</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="2">
<span class="hits">1</span>
-
- <code class="ruby">require 'spec/spec_helper'</code>
+
+ <code class="ruby">require 'spec_helper'</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="3">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
-
+
<code class="ruby">describe 'Integration' do</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="5">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="3" data-linenumber="6">
<span class="hits">3</span>
-
+
<code class="ruby"> before(:each) { start_slanger }</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="7">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
-
+
<code class="ruby"> context &quot;connecting with invalid credentials&quot; do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
-
+
<code class="ruby"> it &quot;sends an error message&quot; do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
-
+
<code class="ruby"> messages = em_stream(key: 'bogus_key') do |websocket, messages|</code>
</li>
-
+
<li class="covered" data-hits="2" data-linenumber="11">
<span class="hits">2</span>
-
+
<code class="ruby"> websocket.callback { EM.stop }</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="12">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="13">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.should have_attributes count: 1, last_event: 'pusher:error',</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="14">
-
-
+
+
<code class="ruby"> connection_established: false, id_present: false</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.first['data'] == 'Could not find app by key bogus_key'</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="16">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="17">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="18">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="19">
<span class="hits">1</span>
-
+
<code class="ruby"> context &quot;given invalid JSON as input&quot; do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="20">
<span class="hits">1</span>
-
+
<code class="ruby"> it 'should not crash' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
-
+
<code class="ruby"> messages = em_stream do |websocket, messages|</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="22">
<span class="hits">1</span>
-
+
<code class="ruby"> websocket.callback do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="23">
<span class="hits">1</span>
-
+
<code class="ruby"> websocket.send(&quot;{ event: 'pusher:subscribe', data: { channel: 'MY_CHANNEL'} }23123&quot;)</code>
</li>
-
+
<li class="covered" data-hits="2" data-linenumber="24">
<span class="hits">2</span>
-
+
<code class="ruby"> EM.next_tick { EM.stop }</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="25">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="26">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="27">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="5" data-linenumber="28">
<span class="hits">5</span>
-
+
<code class="ruby"> EM.run { new_websocket.tap { |u| u.stream { EM.next_tick { EM.stop } } }}</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="29">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="30">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="31">
-
-
+
+
<code class="ruby">end</code>
</li>
-
+
</ol>
</pre>
</div>
-
+
<div class="source_table" id="9475f908a4ca4dae3d435c8070e444582a98d0a7">
<div class="header">
<h3>spec/integration/presence_channel_spec.rb</h3>
<h4><span class="green">100.0 %</span> covered</h4>
<div>
- <b>55</b> relevant lines.
+ <b>55</b> relevant lines.
<span class="green"><b>55</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
</div>
-
+
<pre>
<ol>
-
+
<li class="never" data-hits="" data-linenumber="1">
-
-
+
+
<code class="ruby">#encoding: utf-8</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="2">
<span class="hits">1</span>
-
+
<code class="ruby">require 'spec/spec_helper'</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="3">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="4">
<span class="hits">1</span>
-
+
<code class="ruby">describe 'Integration' do</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="5">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="6" data-linenumber="6">
<span class="hits">6</span>
-
+
<code class="ruby"> before(:each) { start_slanger }</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="7">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="8">
<span class="hits">1</span>
-
+
<code class="ruby"> describe 'presence channels:' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="9">
<span class="hits">1</span>
-
+
<code class="ruby"> context 'subscribing without channel data' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
-
+
<code class="ruby"> context 'and bogus authentication credentials' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
-
+
<code class="ruby"> it 'sends back an error message' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="12">
<span class="hits">1</span>
-
+
<code class="ruby"> messages = em_stream do |websocket, messages|</code>
</li>
-
+
<li class="covered" data-hits="2" data-linenumber="13">
<span class="hits">2</span>
-
+
<code class="ruby"> case messages.length</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="14">
-
-
+
+
<code class="ruby"> when 1</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="15">
<span class="hits">1</span>
-
+
<code class="ruby"> websocket.send({ event: 'pusher:subscribe', data: { channel: 'presence-channel', auth: 'bogus' } }.to_json)</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="16">
-
-
+
+
<code class="ruby"> else</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
-
+
<code class="ruby"> EM.stop</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="18">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="19">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="20">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="21">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.should have_attributes connection_established: true, id_present: true,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="22">
-
-
+
+
<code class="ruby"> count: 2,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="23">
-
-
+
+
<code class="ruby"> last_event: 'pusher:error'</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="24">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.last['data']['message'].=~(/^Invalid signature: Expected HMAC SHA256 hex digest of/).should be_true</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="26">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="27">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="28">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="29">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
-
+
<code class="ruby"> context 'subscribing with channel data' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="31">
<span class="hits">1</span>
-
+
<code class="ruby"> context 'and bogus authentication credentials' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="32">
<span class="hits">1</span>
-
+
<code class="ruby"> it 'sends back an error message' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="33">
<span class="hits">1</span>
-
+
<code class="ruby"> messages = em_stream do |websocket, messages|</code>
</li>
-
+
<li class="covered" data-hits="2" data-linenumber="34">
<span class="hits">2</span>
-
+
<code class="ruby"> case messages.length</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="35">
-
-
+
+
<code class="ruby"> when 1</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="36">
-
-
+
+
<code class="ruby"> send_subscribe( user: websocket,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="37">
-
-
+
+
<code class="ruby"> user_id: '0f177369a3b71275d25ab1b44db9f95f',</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="38">
-
-
+
+
<code class="ruby"> name: 'SG',</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="39">
<span class="hits">1</span>
-
+
<code class="ruby"> message: {data: {socket_id: 'bogus'}}.with_indifferent_access)</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="40">
-
-
+
+
<code class="ruby"> else</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="41">
<span class="hits">1</span>
-
+
<code class="ruby"> EM.stop</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="42">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="43">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="44">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="45">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.should have_attributes first_event: 'pusher:connection_established', count: 2,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="46">
-
-
+
+
<code class="ruby"> id_present: true</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="47">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="48">
-
-
+
+
<code class="ruby"> # Channel id should be in the payload</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="49">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.last['event'].should == 'pusher:error'</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="50">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.last['data']['message'].=~(/^Invalid signature: Expected HMAC SHA256 hex digest of/).should be_true</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="51">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="52">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="53">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="54">
<span class="hits">1</span>
-
+
<code class="ruby"> context 'with genuine authentication credentials' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="55">
<span class="hits">1</span>
-
+
<code class="ruby"> it 'sends back a success message' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="56">
<span class="hits">1</span>
-
+
<code class="ruby"> messages = em_stream do |websocket, messages|</code>
</li>
-
+
<li class="covered" data-hits="2" data-linenumber="57">
<span class="hits">2</span>
-
+
<code class="ruby"> case messages.length</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="58">
-
-
+
+
<code class="ruby"> when 1</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="59">
-
-
+
+
<code class="ruby"> send_subscribe( user: websocket,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="60">
-
-
+
+
<code class="ruby"> user_id: '0f177369a3b71275d25ab1b44db9f95f',</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="61">
-
-
+
+
<code class="ruby"> name: 'SG',</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="62">
<span class="hits">1</span>
-
+
<code class="ruby"> message: messages.first)</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="63">
-
-
+
+
<code class="ruby"> else</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="64">
<span class="hits">1</span>
-
+
<code class="ruby"> EM.stop</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="65">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="66">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="67">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="68">
<span class="hits">1</span>
-
+
<code class="ruby"> messages.should have_attributes connection_established: true, count: 2</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="69">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="70">
-
-
+
+
<code class="ruby"> messages.last.should == {&quot;channel&quot;=&gt;&quot;presence-channel&quot;,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="71">
-
-
+
+
<code class="ruby"> &quot;event&quot;=&gt;&quot;pusher_internal:subscription_succeeded&quot;,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="72">
-
-
- <code class="ruby"> &quot;data&quot;=&gt;{&quot;presence&quot;=&gt;</code>
+
+
+ <code class="ruby"> &quot;data&quot;=&gt;{&quot;presence&quot;=&gt;</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="73">
-
-
+
+
<code class="ruby"> {&quot;count&quot;=&gt;1,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="74">
-
-
+
+
<code class="ruby"> &quot;ids&quot;=&gt;[&quot;0f177369a3b71275d25ab1b44db9f95f&quot;],</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="75">
-
-
+
+
<code class="ruby"> &quot;hash&quot;=&gt;</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="76">
<span class="hits">1</span>
-
+
<code class="ruby"> {&quot;0f177369a3b71275d25ab1b44db9f95f&quot;=&gt;{&quot;name&quot;=&gt;&quot;SG&quot;}}}}}</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="77">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="78">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="79">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="80">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="81">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="82">
<span class="hits">1</span>
-
+
<code class="ruby"> context 'with more than one subscriber subscribed to the channel' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="83">
<span class="hits">1</span>
-
+
<code class="ruby"> it 'sends a member added message to the existing subscribers' do</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="84">
<span class="hits">1</span>
-
+
<code class="ruby"> messages = em_stream do |user1, messages|</code>
</li>
-
+
<li class="covered" data-hits="3" data-linenumber="85">
<span class="hits">3</span>
-
+
<code class="ruby"> case messages.length</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="86">
-
-
+
+
<code class="ruby"> when 1</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="87">
-
-
+
+
<code class="ruby"> send_subscribe(user: user1,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="88">
-
-
+
+
<code class="ruby"> user_id: '0f177369a3b71275d25ab1b44db9f95f',</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="89">
-
-
+
+
<code class="ruby"> name: 'SG',</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="90">
<span class="hits">1</span>
-
+
<code class="ruby"> message: messages.first</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="91">
-
-
+
+
<code class="ruby"> )</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="92">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="93">
-
-
+
+
<code class="ruby"> when 2</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="94">
<span class="hits">1</span>
-
+
<code class="ruby"> new_websocket.tap do |u|</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="95">
<span class="hits">1</span>
-
+
<code class="ruby"> u.stream do |message|</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="96">
-
-
+
+
<code class="ruby"> send_subscribe({user: u,</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="97">
-
-
+
+
<code class="ruby"> user_id: '37960509766262569d504f02a0ee986d',</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="98">
-
-
+
+
<code class="ruby"> name: 'CHROME',</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="99">
<span class="hits">1</span>
-
+
<code class="ruby"> message: JSON.parse(message)})</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="100">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="101">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="102">
-
-
+
+
<code class="ruby"> else</code>
</li>
-
+
<li class="covered" data-hits="1" data-linenumber="103">
<span class="hits">1</span>
-
+
<code class="ruby"> EM.stop</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="104">
-
-
+
+
<code class="ruby"> end</code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="105">
-
-
+
+
<code class="ruby"></code>
</li>
-
+
<li class="never" data-hits="" data-linenumber="106">