Skip to content

Commit

Permalink
Test #other_node.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdvdijk committed Oct 1, 2012
1 parent 440b4bc commit 7470332
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions spec/unit/relationship_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ module Neography
}
end

describe "::create" do
let(:from) { stub(:neo_server => db) }
let(:to) { stub(:neo_server => db) }
let(:props) { { :foo => "bar" } }
let(:from) { stub(:neo_server => db) }
let(:to) { stub(:neo_server => db) }
let(:props) { { :foo => "bar" } }

describe "::create" do
it "creates a new node through Rest" do
db.should_receive(:create_relationship).with("type", from, to, props)

Expand Down Expand Up @@ -81,5 +81,32 @@ module Neography
end
end

describe "#other_node" do

let(:rel) do
{
"self" => "/1",
"start" => "/2",
"end" => "/3",
"data" => {}
}
end

before do
db.stub(:create_relationship) { rel }
end

subject(:relationship) { Relationship.create("type", from, to, props) }

it "knows the other node based on from" do
relationship.other_node(from).should == to
end

it "knows the other node based on to" do
relationship.other_node(to).should == from
end

end

end
end

0 comments on commit 7470332

Please sign in to comment.