Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding Specs #104

Merged
merged 3 commits into from
Aug 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/neography/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Railtie < Rails::Railtie
# See: http://api.rubyonrails.org/classes/Rails/Railtie.html
initializer 'neography.configure' do
# Provides a hook so people implementing the gem can do this in a railtie of their own:
# initializer "my_thing.neography_initialization", before: 'neography_railtie.configure_rails_initialization' do
# initializer "my_thing.neography_initialization", before: 'neography.configure' do
# require 'my_thing/neography'
# end
end
Expand Down
71 changes: 71 additions & 0 deletions spec/integration/node_encoding_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# encoding: utf-8
require 'spec_helper'

describe Neography::Node do

describe "create and new" do

it "can create a node with UTF-8 encoded properties" do
new_node = Neography::Node.create("name" => "美都池水")
new_node.name.should == "美都池水"
end

it "can create a node with more than one UTF-8 encoded properties" do
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
new_node.first_name.should == "美都"
new_node.last_name.should == "池水"
end

end

describe "load" do
it "can get a node with UTF-8 encoded properties that exists" do
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
existing_node = Neography::Node.load(new_node)
existing_node.should_not be_nil
existing_node.neo_id.should_not be_nil
existing_node.neo_id.should == new_node.neo_id
existing_node.first_name.should == "美都"
existing_node.last_name.should == "池水"
end

it "can get a node with UTF-8 encoded properties from an index" do
@neo = Neography::Rest.new
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
key = generate_text(6)
value = generate_text
@neo.add_node_to_index("test_node_index", key, value, new_node)
node_from_index = @neo.get_node_index("test_node_index", key, value)
existing_node = Neography::Node.load(node_from_index)
existing_node.should_not be_nil
existing_node.neo_id.should_not be_nil
existing_node.neo_id.should == new_node.neo_id
existing_node.first_name.should == "美都"
existing_node.last_name.should == "池水"
end

it "can get a node with UTF-8 encoded properties that exists via cypher" do
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
cypher = "START n = node({id}) return n"
@neo = Neography::Rest.new
results = @neo.execute_query(cypher, {:id => new_node.neo_id.to_i})
existing_node = Neography::Node.load(results)
existing_node.should_not be_nil
existing_node.neo_id.should_not be_nil
existing_node.neo_id.should == new_node.neo_id
existing_node.first_name.should == "美都"
existing_node.last_name.should == "池水"
end

it "can get columns of data from a node with UTF-8 encoded properties that exists via cypher" do
new_node = Neography::Node.create("first_name" => "美都", "last_name" => "池水")
cypher = "START me = node({id})
RETURN me.first_name, me.last_name"
@neo = Neography::Rest.new
results = @neo.execute_query(cypher, {:id => new_node.neo_id.to_i})
results['data'][0].should == ["美都","池水"]
end

end

end