harpy 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/harpy/resource.rb +10 -1
- data/lib/harpy/version.rb +1 -1
- data/spec/harpy/resource_spec.rb +26 -8
- metadata +18 -18
data/lib/harpy/resource.rb
CHANGED
@@ -179,13 +179,22 @@ module Harpy
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def inspect
|
182
|
-
"<#{self.class.name} @attrs:#{@attrs.inspect} @errors:#{errors.inspect} persisted:#{persisted?}>"
|
182
|
+
"<#{self.class.name} @attrs:#{@attrs.inspect} @errors:#{errors.full_messages.inspect} persisted:#{persisted?}>"
|
183
183
|
end
|
184
184
|
|
185
185
|
def has_key?(key)
|
186
186
|
@attrs.has_key? key.to_s
|
187
187
|
end
|
188
188
|
|
189
|
+
def hash
|
190
|
+
urn.hash
|
191
|
+
end
|
192
|
+
|
193
|
+
def ==(other)
|
194
|
+
other.equal?(self) || (urn && other.instance_of?(self.class) && other.urn == urn)
|
195
|
+
end
|
196
|
+
alias_method :eql?, :==
|
197
|
+
|
189
198
|
private
|
190
199
|
|
191
200
|
def create(json)
|
data/lib/harpy/version.rb
CHANGED
data/spec/harpy/resource_spec.rb
CHANGED
@@ -483,11 +483,7 @@ describe "class including Harpy::Resource" do
|
|
483
483
|
describe "#inspect" do
|
484
484
|
subject { Harpy::Spec::Company.new "firstname" => "Anthony" }
|
485
485
|
it "shows class name, attributes, errors and persisted state" do
|
486
|
-
|
487
|
-
subject.inspect.should == '<Harpy::Spec::Company @attrs:{"firstname"=>"Anthony"} @errors:#<OrderedHash {}> persisted:false>'
|
488
|
-
else
|
489
|
-
subject.inspect.should == '<Harpy::Spec::Company @attrs:{"firstname"=>"Anthony"} @errors:{} persisted:false>'
|
490
|
-
end
|
486
|
+
subject.inspect.should == '<Harpy::Spec::Company @attrs:{"firstname"=>"Anthony"} @errors:[] persisted:false>'
|
491
487
|
end
|
492
488
|
end
|
493
489
|
describe "#has_key?(key)" do
|
@@ -602,7 +598,7 @@ describe "class including Harpy::Resource" do
|
|
602
598
|
Harpy.client.should_receive(:post).with(url, :body => body).and_return response
|
603
599
|
subject.save.should be_false
|
604
600
|
subject.callbacks.should =~ [:save, :create]
|
605
|
-
subject.should have(
|
601
|
+
subject.should have(2).errors
|
606
602
|
subject.errors[:lastname].should =~ ["can't be blank", "must be unique"]
|
607
603
|
subject.firstname.should be_nil
|
608
604
|
subject.company_name.should == "Stark Enterprises"
|
@@ -679,7 +675,7 @@ describe "class including Harpy::Resource" do
|
|
679
675
|
Harpy.client.should_receive(:put).with(url, :body => body).and_return response
|
680
676
|
subject.save.should be_false
|
681
677
|
subject.callbacks.should =~ [:save, :update]
|
682
|
-
subject.should have(
|
678
|
+
subject.should have(2).errors
|
683
679
|
subject.errors[:lastname].should =~ ["can't be blank", "must be unique"]
|
684
680
|
lambda { subject.firstname }.should raise_error NoMethodError
|
685
681
|
subject.company_name.should == "Stark Enterprises"
|
@@ -753,7 +749,7 @@ describe "class including Harpy::Resource" do
|
|
753
749
|
Harpy.client.should_receive(:delete).with(url).and_return response
|
754
750
|
subject.destroy.should be_false
|
755
751
|
subject.callbacks.should =~ [:destroy]
|
756
|
-
subject.should have(
|
752
|
+
subject.should have(2).errors
|
757
753
|
subject.errors[:lastname].should =~ ["can't be blank", "must be unique"]
|
758
754
|
lambda { subject.firstname }.should raise_error NoMethodError
|
759
755
|
subject.company_name.should == "Stark Enterprises"
|
@@ -767,4 +763,26 @@ describe "class including Harpy::Resource" do
|
|
767
763
|
end
|
768
764
|
end
|
769
765
|
end
|
766
|
+
describe "equality" do
|
767
|
+
it "is equal to itself even without urn" do
|
768
|
+
company1 = Harpy::Spec::Company.new
|
769
|
+
company2 = company1
|
770
|
+
company1.should == company2
|
771
|
+
end
|
772
|
+
it "two instances without urn are not equal" do
|
773
|
+
company1 = Harpy::Spec::Company.new
|
774
|
+
company2 = Harpy::Spec::Company.new
|
775
|
+
company1.should_not == company2
|
776
|
+
end
|
777
|
+
it "two instances of the same class with the same urn are equal" do
|
778
|
+
company1 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
|
779
|
+
company2 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
|
780
|
+
company1.should == company2
|
781
|
+
end
|
782
|
+
it "two instances of the same class with different urns are not equal" do
|
783
|
+
company1 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:1"
|
784
|
+
company2 = Harpy::Spec::Company.new "urn" => "urn:harpy:company:2"
|
785
|
+
company1.should_not == company2
|
786
|
+
end
|
787
|
+
end
|
770
788
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harpy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-09-13 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: typhoeus
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153340700 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.2.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153340700
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153333660 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 3.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153333660
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: activemodel
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153333040 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 3.0.0
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153333040
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: hash-deep-merge
|
50
|
-
requirement: &
|
50
|
+
requirement: &2153332400 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 0.1.1
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153332400
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: yajl-ruby
|
61
|
-
requirement: &
|
61
|
+
requirement: &2153331760 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.8.2
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2153331760
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
|
-
requirement: &
|
72
|
+
requirement: &2153331060 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.8.7
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2153331060
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rspec
|
83
|
-
requirement: &
|
83
|
+
requirement: &2153330340 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 2.6.0
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2153330340
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rocco
|
94
|
-
requirement: &
|
94
|
+
requirement: &2153329620 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ~>
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: '0.7'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2153329620
|
103
103
|
description: Client for REST API with HATEOAS
|
104
104
|
email:
|
105
105
|
- joseph.halter@thetalentbox.com
|