Permalink
Browse files

Switch from Object#to_json to MultiJson.dump.

  • Loading branch information...
tristandunn committed Dec 9, 2012
1 parent bbe4751 commit 2e9c1d3bcf38b3ee7c0e1861e4683d5053b9fac2
@@ -10,7 +10,7 @@
end
When %{I subscribe to the "$channel" channel} do |channel|
- page.execute_script("Pusher.instance.subscribe(#{channel.to_json})")
+ page.execute_script("Pusher.instance.subscribe(#{MultiJson.dump(channel)})")
end
When %{I subscribe to the "$channel" channel with presence events} do |channel|
@@ -30,7 +30,7 @@
count.innerHTML = parseInt(count.innerHTML, 10) + delta;
};
- Pusher.instance.subscribe(#{channel.to_json})
+ Pusher.instance.subscribe(#{MultiJson.dump(channel)})
.bind("pusher:subscription_succeeded", function(clients) {
clients.each(addClient);
@@ -51,7 +51,7 @@
end
When %{I unsubscribe from the "$channel" channel} do |channel|
- page.execute_script("Pusher.instance.unsubscribe(#{channel.to_json})")
+ page.execute_script("Pusher.instance.unsubscribe(#{MultiJson.dump(channel)})")
end
When %{$name unsubscribes from the "$channel" channel} do |name, channel|
@@ -64,7 +64,7 @@
Capybara.timeout do
subscribed = page.evaluate_script(%{
var
- channel = Pusher.instance.channel(#{channel.to_json});
+ channel = Pusher.instance.channel(#{MultiJson.dump(channel)});
channel && channel.subscribed;
})
subscribed == true
@@ -75,7 +75,7 @@
wait do
subscribed = page.evaluate_script(%{
var
- channel = Pusher.instance.channel(#{channel.to_json});
+ channel = Pusher.instance.channel(#{MultiJson.dump(channel)});
channel && channel.subscribed;
})
subscribed.should be_false
@@ -5,21 +5,21 @@
When %{I trigger the "$event" event on the "$channel" channel} do |event, channel|
page.execute_script(%{
var
- channel = Pusher.instance.channel(#{channel.to_json});
- channel.trigger(#{event.to_json}, {});
+ channel = Pusher.instance.channel(#{MultiJson.dump(channel)});
+ channel.trigger(#{MultiJson.dump(event)}, {});
})
end
When %{I manually trigger the "$event" event on the "$channel" channel} do |event, channel|
- page.execute_script(%{Pusher.instance.send_event(#{event.to_json}, {}, #{channel.to_json})})
+ page.execute_script(%{Pusher.instance.send_event(#{MultiJson.dump(event)}, {}, #{MultiJson.dump(channel)})})
end
Then /^([^ ]+) should receive a "([^"]+)" event on the "([^"]+)" channel$/ do |name, event, channel|
name = nil if name == "I"
using_session(name) do
wait do
- events = page.evaluate_script("Pusher.instance.events[#{[channel, event].join(":").to_json}]")
+ events = page.evaluate_script("Pusher.instance.events[#{MultiJson.dump([channel, event].join(":"))}]")
events.length.should == 1
end
end
@@ -30,7 +30,7 @@
using_session(name) do
wait do
- events = page.evaluate_script("Pusher.instance.events[#{[channel, event].join(":").to_json}]")
+ events = page.evaluate_script("Pusher.instance.events[#{MultiJson.dump([channel, event].join(":"))}]")
events.should be_nil
end
end
@@ -22,6 +22,6 @@ class Sinatra::Application
data = { user_id: params[:socket_id], user_info: { name: "Alan Turing" } }
end
- channel.authenticate(params[:socket_id], data).to_json
+ MultiJson.dump(channel.authenticate(params[:socket_id], data))
end
end
@@ -17,11 +17,11 @@
<script>
window.addEventListener("DOMContentLoaded", function() {
// Use the PusherFake server.
- Pusher.host = <%= PusherFake.configuration.socket_host.to_json %>;
- Pusher.ws_port = <%= PusherFake.configuration.socket_port.to_json %>;
+ Pusher.host = <%= MultiJson.dump(PusherFake.configuration.socket_host) %>;
+ Pusher.ws_port = <%= MultiJson.dump(PusherFake.configuration.socket_port) %>;
// Create the client instance.
- Pusher.instance = new Pusher(<%= PusherFake.configuration.key.to_json %>);
+ Pusher.instance = new Pusher(<%= MultiJson.dump(PusherFake.configuration.key) %>);
Pusher.instance.events = {};
// Force the connection to go unavailable after a single attempt.
@@ -16,7 +16,7 @@
end
describe PusherFake::Channel::Presence, "#add" do
- let(:data) { { auth: authentication, channel_data: channel_data.to_json } }
+ let(:data) { { auth: authentication, channel_data: MultiJson.dump(channel_data) } }
let(:name) { "name" }
let(:user_id) { "1234" }
let(:connection) { stub(emit: nil) }

0 comments on commit 2e9c1d3

Please sign in to comment.