diff --git a/lib/neography/config.rb b/lib/neography/config.rb index 3f519af..4c4b055 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -45,7 +45,7 @@ def set_defaults @authentication = nil @username = nil @password = nil - @parser = {:parser => MultiJsonParser} + @parser = MultiJsonParser end end diff --git a/lib/neography/connection.rb b/lib/neography/connection.rb index e663f1d..fa04d7e 100644 --- a/lib/neography/connection.rb +++ b/lib/neography/connection.rb @@ -27,7 +27,7 @@ def configuration end def merge_options(options) - merged_options = options.merge!(@authentication).merge!(@parser) + merged_options = options.merge!(@authentication)#.merge!(@parser) merged_options[:headers].merge!(@user_agent) if merged_options[:headers] merged_options end @@ -101,10 +101,10 @@ def evaluate_response(response) case code when 200 @logger.debug "OK" if @log_enabled - MultiJsonParser.json(body) #response.parsed_response + @parser.json(body) #response.parsed_response when 201 @logger.debug "OK, created #{body}" if @log_enabled - MultiJsonParser.json(body) #response.parsed_response + @parser.json(body) #response.parsed_response when 204 @logger.debug "OK, no content returned" if @log_enabled nil @@ -120,7 +120,7 @@ def handle_4xx_500_response(code, body) message = "No error message returned from server." stacktrace = "" else - parsed_body = JSON.parse(body) + parsed_body = @parser.json(body) message = parsed_body["message"] stacktrace = parsed_body["stacktrace"] end diff --git a/spec/integration/rest_header_spec.rb b/spec/integration/rest_header_spec.rb index 3830094..3005cf6 100644 --- a/spec/integration/rest_header_spec.rb +++ b/spec/integration/rest_header_spec.rb @@ -3,7 +3,7 @@ describe Neography::Connection do it "should not add a content-type header if there's no existing headers" do - subject.merge_options({}).keys.should == [:parser] + subject.merge_options({}).keys.should == [] end it "should add a content type if there's existing headers" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c251282..4ca9bb1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,9 +5,9 @@ Coveralls.wear! # If you want to see more, uncomment the next few lines - require 'net-http-spy' +# require 'net-http-spy' # Net::HTTP.http_logger_options = {:body => true} # just the body - Net::HTTP.http_logger_options = {:verbose => true} # see everything +# Net::HTTP.http_logger_options = {:verbose => true} # see everything def generate_text(length=8) chars = 'abcdefghjkmnpqrstuvwxyz' diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 6996489..3b6b931 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -19,7 +19,7 @@ module Neography its(:authentication) { should == nil } its(:username) { should == nil } its(:password) { should == nil } - its(:parser) { should == { :parser => MultiJsonParser } } + its(:parser) { should == MultiJsonParser} it "has a hash representation" do expected_hash = { @@ -35,7 +35,7 @@ module Neography :authentication => nil, :username => nil, :password => nil, - :parser => { :parser => MultiJsonParser } + :parser => MultiJsonParser } config.to_hash.should == expected_hash end