From 28313e1e07c8c799ad5b6c1130342c66566406b8 Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Tue, 17 Jul 2012 14:53:01 -0500 Subject: [PATCH] using strict mode on Oj gem, so we don't convert to strings with colons to symbols --- lib/neography/oj_parser.rb | 4 ++-- spec/integration/parsing_spec.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 spec/integration/parsing_spec.rb diff --git a/lib/neography/oj_parser.rb b/lib/neography/oj_parser.rb index 94ebd82..fe27953 100644 --- a/lib/neography/oj_parser.rb +++ b/lib/neography/oj_parser.rb @@ -1,8 +1,8 @@ class OjParser < HTTParty::Parser - + Oj.default_options = { :mode => :strict } + protected def json - #Oj::Doc.parse(body) Oj.load(body) end end \ No newline at end of file diff --git a/spec/integration/parsing_spec.rb b/spec/integration/parsing_spec.rb new file mode 100644 index 0000000..a73846b --- /dev/null +++ b/spec/integration/parsing_spec.rb @@ -0,0 +1,13 @@ +require File.join(File.dirname(__FILE__), '..', 'spec_helper') + +describe Neography do + subject { Neography::Rest.new } + describe 'create_node' do + it 'should not convert strings to symbol' do + node = subject.create_node({:text => ':1456'}) + + node['data']['text'].class.should == String # fails! expected: String got: Symbol (using ==) + node['data']['text'].should == ':1456' + end + end +end \ No newline at end of file