Permalink
Browse files

Use `Object#respond_to?` to determine which MultiJson API to use

Closes #51.
  • Loading branch information...
1 parent b7e22aa commit 7057268fb6464c8840d6d09acc6df44eb81f5a0b @sferik committed Apr 22, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/capybara/poltergeist/browser.rb
@@ -114,7 +114,11 @@ def command(name, *args)
message = { 'name' => name, 'args' => args }
log message.inspect
- json = MultiJson.load(server.send(MultiJson.dump(message)))
+ json = if MultiJson.respond_to?(:dump) && MultiJson.respond_to?(:load)
+ MultiJson.load(server.send(MultiJson.dump(message)))
+ else
+ MultiJson.decode(server.send(MultiJson.encode(message)))
+ end
log json.inspect
if json['error']

0 comments on commit 7057268

Please sign in to comment.