diff --git a/CHANGELOG.md b/CHANGELOG.md index beba702..2dd1a73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ #### Features #### -* Added ability to set zoom_factor(Dmytro Budnyk) +* Added ability to set zoom_factor (Dmytro Budnyk) +* Write JSON to the logger, rather than Ruby [Issue #430] #### Bug fixes #### @@ -12,6 +13,7 @@ ### 1.5.0 ### #### Features #### + * Added ability to clear network traffic (Vick Vu) * Added ability to set paper_size via a driver setter (Philippe Lehoux) * Can support Basic HTTP authentication @@ -20,6 +22,7 @@ element and Capybara 2.2 support (Pedro CarriƧo) #### Bug fixes #### + * Use `Capybara::Helpers.normalize_whitespace` in filter_text to strip unicode whitespace (Wataru Miyaguni) * Fix missed interpolation on deprecated error classes @@ -32,6 +35,7 @@ ### 1.4.1 ### #### Bug fixes #### + * Kill thread first off and then close IO [Issue #385] ### 1.4.0 ### @@ -100,7 +104,7 @@ ### 1.1.2 ### -#### Bug fixes ##### +#### Bug fixes #### * Tie to faye-websocket 0.4 as 0.5 introduces incompatibilities. @@ -246,7 +250,7 @@ [Issue #83] * Added status code support. (Dmitriy Nesteryuk and Jon Leighton) [Issue #37] -#### Bug fixes ### +#### Bug fixes #### * Fix issue with `ClickFailed` exception happening with a negative co-ordinate (which should be impossible). (Jon Leighton, Gabriel diff --git a/lib/capybara/poltergeist/browser.rb b/lib/capybara/poltergeist/browser.rb index 2d5985d..7ee0593 100644 --- a/lib/capybara/poltergeist/browser.rb +++ b/lib/capybara/poltergeist/browser.rb @@ -268,11 +268,13 @@ module Capybara::Poltergeist end def command(name, *args) - message = { 'name' => name, 'args' => args } - log message.inspect + message = JSON.dump({ 'name' => name, 'args' => args }) + log message - json = JSON.load(server.send(JSON.dump(message))) - log json.inspect + response = server.send(message) + log response + + json = JSON.load(response) if json['error'] klass = ERROR_MAPPINGS[json['error']['name']] || BrowserError diff --git a/spec/integration/session_spec.rb b/spec/integration/session_spec.rb index 0087e53..67a5993 100644 --- a/spec/integration/session_spec.rb +++ b/spec/integration/session_spec.rb @@ -540,7 +540,7 @@ describe Capybara::Session do @session.visit("/") @session.find(:css, "a").click - position = eval(TestSessions.logger.messages.last)["response"]["position"] + position = JSON.load(TestSessions.logger.messages.last)["response"]["position"] expect(position["x"]).to_not be_nil expect(position["y"]).to_not be_nil end diff --git a/spec/unit/browser_spec.rb b/spec/unit/browser_spec.rb index fac56d2..bff0128 100644 --- a/spec/unit/browser_spec.rb +++ b/spec/unit/browser_spec.rb @@ -11,13 +11,13 @@ module Capybara::Poltergeist subject { Browser.new(server, client, logger) } it 'logs requests and responses to the client' do - request = { 'name' => 'where is', 'args' => ["the love?"] } - response = { 'response' => '<3' } - server.stub(:send).with(MultiJson.dump(request)).and_return(JSON.dump(response)) + request = %({"name":"where is","args":["the love?"]}) + response = %({"response":"<3"}) + server.stub(:send).with(request).and_return(response) subject.command('where is', 'the love?') - expect(logger.string).to eq("#{request.inspect}\n#{response.inspect}\n") + expect(logger.string).to eq("#{request}\n#{response}\n") end end end