safety_pin 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -2,12 +2,12 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
- nyan-cat-formatter (0.0.7)
5
+ nyan-cat-formatter (0.2.0)
6
6
  rspec (2.10.0)
7
7
  rspec-core (~> 2.10.0)
8
8
  rspec-expectations (~> 2.10.0)
9
9
  rspec-mocks (~> 2.10.0)
10
- rspec-core (2.10.0)
10
+ rspec-core (2.10.1)
11
11
  rspec-expectations (2.10.0)
12
12
  diff-lcs (~> 1.1.3)
13
13
  rspec-mocks (2.10.1)
@@ -97,6 +97,17 @@ module SafetyPin
97
97
  def session
98
98
  @session ||= JCR.session
99
99
  end
100
+
101
+ def ==(other_node)
102
+ return false if other_node.nil?
103
+ return false unless other_node.respond_to?(:path)
104
+ self.path == other_node.path
105
+ end
106
+
107
+ def parent
108
+ raise NodeError.new("Root node does not have parent") if path == "/"
109
+ Node.new(j_node.parent)
110
+ end
100
111
 
101
112
  def children
102
113
  child_nodes = []
@@ -3,7 +3,7 @@ module SafetyPin
3
3
  attr_accessor :path, :primary_type, :properties
4
4
 
5
5
  def initialize(opts)
6
- raise NodeBlueprintError.new("No path specified") unless opts[:path]
6
+ raise NodeBlueprintError.new("No path specified") unless opts.has_key?(:path)
7
7
  @path = opts[:path]
8
8
  @primary_type = opts[:primary_type] || "nt:unstructured"
9
9
  @properties = opts[:properties] || {}
@@ -1,3 +1,3 @@
1
1
  module SafetyPin
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -25,7 +25,7 @@ describe SafetyPin::NodeBlueprint do
25
25
 
26
26
  describe "#path" do
27
27
  it "requires a path" do
28
- lambda { SafetyPin::NodeBlueprint.new({}).path }.should raise_error(NodeBlueprintError)
28
+ expect { SafetyPin::NodeBlueprint.new({}).path }.to raise_error(SafetyPin::NodeBlueprintError)
29
29
  end
30
30
 
31
31
  it "has a path" do
data/spec/node_spec.rb CHANGED
@@ -99,7 +99,7 @@ describe SafetyPin::Node do
99
99
  end
100
100
  end
101
101
 
102
- describe ".create_or_update", :focus => true do
102
+ describe ".create_or_update" do
103
103
  let(:node_blueprint) { SafetyPin::NodeBlueprint.new(:path => "/content/foo") }
104
104
 
105
105
  it "calls Node.create with arg when nothing exists at path" do
@@ -666,4 +666,47 @@ describe SafetyPin::Node do
666
666
  child_node.properties.should == {"foo" => "bar"}
667
667
  end
668
668
  end
669
+
670
+ describe "#==" do
671
+ it "finds two nodes with the same path to be the same" do
672
+ node1 = SafetyPin::Node.new(double(:j_node))
673
+ node1.should_receive(:path).and_return("/content/foo")
674
+ node2 = SafetyPin::Node.new(double(:j_node))
675
+ node2.should_receive(:path).and_return("/content/foo")
676
+
677
+ node1.should == node2
678
+ end
679
+
680
+ it "finds two nodes with different paths to be different" do
681
+ node1 = SafetyPin::Node.new(double(:j_node))
682
+ node1.should_receive(:path).and_return("/content/foo")
683
+ node2 = SafetyPin::Node.new(double(:j_node))
684
+ node2.should_receive(:path).and_return("/content/foo/bar")
685
+
686
+ node1.should_not == node2
687
+ end
688
+
689
+ it "returns false when passed an object that doesn't response to path" do
690
+ node1 = SafetyPin::Node.new(double(:j_node))
691
+ node1.stub(:path => "foo")
692
+ node1.should_not == Object.new
693
+ end
694
+
695
+ it "returns false when passed a nil object" do
696
+ node1 = SafetyPin::Node.new(double(:j_node))
697
+ node1.should_not == nil
698
+ end
699
+ end
700
+
701
+ describe "#parent", :focus => true do
702
+ let(:node) { SafetyPin::Node.create(SafetyPin::NodeBlueprint.new(:path => "/content/foo")) }
703
+
704
+ it "returns the parent node" do
705
+ node.parent.should == SafetyPin::Node.find("/content")
706
+ end
707
+
708
+ it "raises an error when called on the root node" do
709
+ expect { SafetyPin::Node.find("/").parent }.to raise_error(SafetyPin::NodeError)
710
+ end
711
+ end
669
712
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safety_pin
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.6
4
+ version: 0.0.7
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jordan Raine
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-15 00:00:00.000000000 Z
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: An easy-to-use JCR connector for JRuby
15
15
  email:
@@ -45,26 +45,26 @@ files:
45
45
  - spec/where_condition_spec.rb
46
46
  homepage: ''
47
47
  licenses: []
48
- post_install_message:
48
+ post_install_message:
49
49
  rdoc_options: []
50
50
  require_paths:
51
51
  - lib
52
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
53
54
  requirements:
54
55
  - - ! '>='
55
56
  - !ruby/object:Gem::Version
56
57
  version: '0'
57
- none: false
58
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
59
60
  requirements:
60
61
  - - ! '>='
61
62
  - !ruby/object:Gem::Version
62
63
  version: '0'
63
- none: false
64
64
  requirements: []
65
- rubyforge_project:
66
- rubygems_version: 1.8.24
67
- signing_key:
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.23
67
+ signing_key:
68
68
  specification_version: 3
69
69
  summary: JCR connector for JRuby
70
70
  test_files:
@@ -75,4 +75,3 @@ test_files:
75
75
  - spec/query_spec.rb
76
76
  - spec/spec_helper.rb
77
77
  - spec/where_condition_spec.rb
78
- ...