active_node 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b61a35ae17f4598504c8840a398430f85c0a6a3
4
- data.tar.gz: 4ee34af5defc7d4e94f201ffac233ff0ab30344b
3
+ metadata.gz: 45501f3e062853d5fe6ccc8c86f421db66c5cff9
4
+ data.tar.gz: 03cd4becab14827bbef0bac124fd0574d0f34b24
5
5
  SHA512:
6
- metadata.gz: 1f100b6302c72bc460b5f8149adaaf5bf179bb3dd6b2a84ad5db8bacb12db160ae4ad366243c19bb20a1bee3f90b20b0b11515f9fbd5d97f8c117bc52d5710fd
7
- data.tar.gz: 7547f7c6a17f49dc5ad264843b16007cd17a1dc28b8f785c9fdb1fb519770eee51ff73a7a4e0b15e82b1ba889a6f4efd3facb3a60bc3d159ba483fae97409c2b
6
+ metadata.gz: 1bc1bda0941bf238967605fe40083c6ad2b6315d5371b5e28667fbaef5abf01e37dde54c3cacaffbb51aa971316cf7f3c52e4e3a6fe706896b3282deea7622ef
7
+ data.tar.gz: e39299ad270597c5c36d120056322b3ba8beb8c141210c675cbbd85d127fb525f670057a7fe3f7758d55264f8c4e2bd9fe366d93bc48b7ea218ff34335f234c2
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
@@ -20,10 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_dependency "active_attr"
22
22
  s.add_dependency "neography"
23
- s.add_dependency "activesupport"
24
- s.add_dependency "activemodel"
25
- s.add_development_dependency "rspec", "<= 2.14.1"
26
- s.add_development_dependency "net-http-spy", "0.2.1"
23
+ s.add_development_dependency "rspec"
27
24
  s.add_development_dependency "rake", ">= 0.8.7"
28
25
  s.add_development_dependency "coveralls"
29
26
  s.add_development_dependency "codeclimate-test-reporter"
@@ -6,6 +6,7 @@ module ActiveNode
6
6
  include ActiveAttr::BasicModel
7
7
  include ActiveAttr::Attributes
8
8
  include ActiveAttr::MassAssignment
9
+ include ActiveAttr::AttributeDefaults
9
10
  include ActiveAttr::TypecastedAttributes
10
11
  include Typecasting
11
12
  include Dirty
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "2.2.7"
2
+ VERSION = "2.2.8"
3
3
  end
@@ -1,11 +1,9 @@
1
- require 'spec_helper'
2
-
3
1
  describe ActiveNode::Associations do
4
2
  describe "#save" do
5
3
  it "should have empty association" do
6
4
  client = Client.new(name: 'a')
7
5
  client.save
8
- client.users.should be_empty
6
+ expect(client.users).to be_empty
9
7
  end
10
8
 
11
9
  it "should not have empty association" do
@@ -13,21 +11,21 @@ describe ActiveNode::Associations do
13
11
  user.save
14
12
  client = Client.new(name: 'a', users: [user])
15
13
  client.save
16
- client.users.should == [user]
14
+ expect(client.users).to eq([user])
17
15
  end
18
16
 
19
17
  it "can set association by id" do
20
18
  user = NeoUser.create!(name: 'Heinrich')
21
19
  client = Client.create!(name: 'a', user_ids: [user.id])
22
- client.users.to_a.should == [user]
23
- client.user_ids.should == [user.id]
24
- client.users.first.clients.first.should == client
20
+ expect(client.users.to_a).to eq([user])
21
+ expect(client.user_ids).to eq([user.id])
22
+ expect(client.users.first.clients.first).to eq(client)
25
23
  client.user_ids = []
26
24
  client.save
27
- Client.find(client.id).users.should == []
25
+ expect(Client.find(client.id).users).to eq([])
28
26
  client.user_ids = [user.id]
29
27
  client.save
30
- Client.find(client.id).users.should == [user]
28
+ expect(Client.find(client.id).users).to eq([user])
31
29
  end
32
30
 
33
31
  it "can remove associated objects" do
@@ -37,18 +35,18 @@ describe ActiveNode::Associations do
37
35
  client.save
38
36
  client.user_ids = []
39
37
  client.save
40
- client.users.should be_empty
41
- client.user_ids.should be_empty
38
+ expect(client.users).to be_empty
39
+ expect(client.user_ids).to be_empty
42
40
  end
43
41
 
44
42
  it "returns nil on a has_one association for a brand spanking new model object" do
45
43
  person = Person.new
46
- person.father.should be_nil
44
+ expect(person.father).to be_nil
47
45
  end
48
46
 
49
47
  it "returns nil on a has_one association where nothing is associated" do
50
48
  person = Person.create!
51
- person.father.should be_nil
49
+ expect(person.father).to be_nil
52
50
  end
53
51
 
54
52
  it "can remove some of the associated objects" do
@@ -56,10 +54,10 @@ describe ActiveNode::Associations do
56
54
  child2 = Person.create!
57
55
  person = Person.create! child_ids: [child1.id, child2.id]
58
56
  person = Person.find(person.id)
59
- person.children.count.should == 2
57
+ expect(person.children.count).to eq(2)
60
58
  person.child_ids = [child2.id]
61
59
  person.save
62
- Person.find(person.id).children.should == [child2]
60
+ expect(Person.find(person.id).children).to eq([child2])
63
61
  end
64
62
 
65
63
  it "can remove and add some of the associated objects" do
@@ -67,11 +65,11 @@ describe ActiveNode::Associations do
67
65
  child2 = Person.create!
68
66
  person = Person.create! child_ids: [child1.id, child2.id]
69
67
  person = Person.find(person.id)
70
- person.children.count.should == 2
68
+ expect(person.children.count).to eq(2)
71
69
  child3 = Person.create!
72
70
  person.child_ids = [child2.id, child3.id]
73
71
  person.save
74
- Person.find(person.id).children.should == [child2, child3]
72
+ expect(Person.find(person.id).children).to eq([child2, child3])
75
73
  end
76
74
 
77
75
  it 'can handle self referencing' do
@@ -80,12 +78,12 @@ describe ActiveNode::Associations do
80
78
  person.people = [person]
81
79
  person.save
82
80
  person.people.first == person
83
- Person.count.should == 1
81
+ expect(Person.count).to eq(1)
84
82
  end
85
83
 
86
84
  it 'can handle reference to the same class' do
87
85
  id = Person.create!(children: [Person.create!, Person.create!]).id
88
- Person.find(id).children.size.should == 2
86
+ expect(Person.find(id).children.size).to eq(2)
89
87
  end
90
88
 
91
89
  it 'can set has_one relation' do
@@ -93,7 +91,7 @@ describe ActiveNode::Associations do
93
91
  child = Person.create!
94
92
  child.father = father
95
93
  child.save
96
- father.children.should == [child]
94
+ expect(father.children).to eq([child])
97
95
  end
98
96
 
99
97
  it 'can set has_one relation by id' do
@@ -101,19 +99,19 @@ describe ActiveNode::Associations do
101
99
  child = Person.create!
102
100
  child.father_id = father.id
103
101
  child.save
104
- father.children.should == [child]
102
+ expect(father.children).to eq([child])
105
103
  end
106
104
 
107
105
  it 'can set has_one relationship by id at creation time' do
108
106
  father = Person.create!
109
107
  child = Person.create! father_id: father.id
110
- father.children.should == [child]
108
+ expect(father.children).to eq([child])
111
109
  end
112
110
 
113
111
  it 'does not set has_one relationship by id if id is blank' do
114
112
  father = Person.create!
115
113
  child = Person.create! father_id: nil
116
- father.children.should be_empty
114
+ expect(father.children).to be_empty
117
115
  end
118
116
 
119
117
  it 'can remove has_one relationship' do
@@ -121,7 +119,7 @@ describe ActiveNode::Associations do
121
119
  child = Person.create! father: father
122
120
  child.father = nil
123
121
  child.save
124
- Person.find(child.id).father.should be_nil
122
+ expect(Person.find(child.id).father).to be_nil
125
123
  end
126
124
 
127
125
  it 'can read has_one relation by id' do
@@ -129,19 +127,19 @@ describe ActiveNode::Associations do
129
127
  child = Person.create!
130
128
  child.father = father
131
129
  child.save
132
- child.father_id.should == father.id
130
+ expect(child.father_id).to eq(father.id)
133
131
  end
134
132
 
135
133
  it "can access new association without being saved" do
136
134
  father = Person.create!
137
135
  child = Person.new
138
136
  child.father = father
139
- child.father.should == father
137
+ expect(child.father).to eq(father)
140
138
  end
141
139
 
142
140
  it 'can handle has_one reverse relationship' do
143
141
  father = Person.create!(children: [Person.create!])
144
- father.children.first.father.should == father
142
+ expect(father.children.first.father).to eq(father)
145
143
  end
146
144
 
147
145
  it 'returns relationships to related nodes' do
@@ -150,7 +148,7 @@ describe ActiveNode::Associations do
150
148
  person = Person.create! child_ids: [child1.id, child2.id]
151
149
  person.save
152
150
  person = Person.find(person.id)
153
- person.child_rels.map(&:other).should == person.children
151
+ expect(person.child_rels.map(&:other)).to eq(person.children)
154
152
  end
155
153
 
156
154
  it 'relationship should include property' do
@@ -158,7 +156,7 @@ describe ActiveNode::Associations do
158
156
  client.address_rel=ActiveNode::Relationship.new(Address.create!, address_type: 'home')
159
157
  client.save
160
158
  client = Client.find(client.id)
161
- client.address_rel[:address_type].should == 'home'
159
+ expect(client.address_rel[:address_type]).to eq('home')
162
160
  end
163
161
 
164
162
  it 'should save updated property on relationship' do
@@ -170,13 +168,13 @@ describe ActiveNode::Associations do
170
168
  client.save
171
169
  client=Client.find(client.id)
172
170
  ar=client.address_rel
173
- ar[:address_type].should == 'office'
171
+ expect(ar[:address_type]).to eq('office')
174
172
  end
175
173
 
176
174
  it 'should retrieve multiple relationships at once' do
177
175
  address = Address.create!
178
176
  person = Person.create! children: [Person.create!(address: address)]
179
- Person.find(person.id).children(:address).first.address.should == address
177
+ expect(Person.find(person.id).children(:address).first.address).to eq(address)
180
178
  end
181
179
 
182
180
  it 'should handle simultaneous updates to father and children' do
@@ -186,7 +184,7 @@ describe ActiveNode::Associations do
186
184
  father = Person.includes(:children).find(father.id)
187
185
  father.children.first.update_attributes(father: nil)
188
186
  father.update_attributes(name: "John")
189
- Person.find(father.id).children.should be_empty?
187
+ expect(Person.find(father.id).children).to be_empty?
190
188
  end
191
189
  end
192
190
  end
@@ -1,18 +1,16 @@
1
- require 'spec_helper'
2
-
3
1
  describe ActiveNode::Base do
4
2
  describe ".subclass" do
5
3
  it "should be ActiveNode::Base" do
6
- ActiveNode::Base.subclass('Abc').should <= ActiveNode::Base
4
+ expect(ActiveNode::Base.subclass('Abc')).to be <= ActiveNode::Base
7
5
  end
8
6
 
9
7
  it "should have the right label" do
10
- ActiveNode::Base.subclass('Abc').label.should == 'Abc'
8
+ expect(ActiveNode::Base.subclass('Abc').label).to eq('Abc')
11
9
  end
12
10
 
13
11
  it "should find object via subclass" do
14
12
  p = Person.create! name: 'Heinrich'
15
- ActiveNode::Base.subclass('Person').find(p.id)[:name].should == p.name
13
+ expect(ActiveNode::Base.subclass('Person').find(p.id)[:name]).to eq(p.name)
16
14
  end
17
15
  end
18
16
 
@@ -1,13 +1,11 @@
1
- require 'spec_helper'
2
-
3
1
  describe ActiveNode::QueryMethods do
4
2
  describe "#order" do
5
3
  it "should order" do
6
4
  p1=Person.create!(name: 'abc')
7
5
  p2=Person.create!(name: 'def')
8
- Person.order(:name).should == [p1, p2]
9
- Person.order(name: :desc).should == [p2, p1]
10
- Person.order('name asc').reverse_order.should == [p2, p1]
6
+ expect(Person.order(:name)).to eq([p1, p2])
7
+ expect(Person.order(name: :desc)).to eq([p2, p1])
8
+ expect(Person.order('name asc').reverse_order).to eq([p2, p1])
11
9
  end
12
10
  end
13
11
 
@@ -15,7 +13,7 @@ describe ActiveNode::QueryMethods do
15
13
  it "should limt" do
16
14
  p1=Person.create!(name: 'abc')
17
15
  p2=Person.create!(name: 'def')
18
- Person.limit(1).should == [p1]
16
+ expect(Person.limit(1)).to eq([p1])
19
17
  end
20
18
  end
21
19
  end
@@ -1,62 +1,60 @@
1
- require 'spec_helper'
2
-
3
1
  describe ActiveNode::Graph do
4
2
  describe "#path" do
5
3
  it "should parse includes" do
6
- ActiveNode::Graph.new(Person, :father).send(:query).should == "optional match (n0)<-[r1:child]-(n1:`Person`)"
7
- ActiveNode::Graph.new(Person, :father, :children).send(:query).should == "optional match (n0)<-[r1:child]-(n1:`Person`) optional match (n0)-[r2:child]->(n2:`Person`)"
8
- ActiveNode::Graph.new(Person, children: 2).send(:query).should == "optional match (n0)-[r1:child*1..2]->(n1:`Person`)"
9
- ActiveNode::Graph.new(Person, {children: :address}, :address).send(:query).should == "optional match (n0)-[r1:child]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n0)-[r3:address]->(n3:`Address`)"
10
- ActiveNode::Graph.new(Person, children: [:address, :father]).send(:query).should == "optional match (n0)-[r1:child]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n1)<-[r3:child]-(n3:`Person`)"
11
- ActiveNode::Graph.new(Person, {children: 2} => [:address, :father]).send(:query).should == "optional match (n0)-[r1:child*1..2]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n1)<-[r3:child]-(n3:`Person`)"
12
- ActiveNode::Graph.new(Person, {children: '*'} => [:address, :father]).send(:query).should == "optional match (n0)-[r1:child*]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n1)<-[r3:child]-(n3:`Person`)"
4
+ expect(ActiveNode::Graph.new(Person, :father).send(:query)).to eq("optional match (n0)<-[r1:child]-(n1:`Person`)")
5
+ expect(ActiveNode::Graph.new(Person, :father, :children).send(:query)).to eq("optional match (n0)<-[r1:child]-(n1:`Person`) optional match (n0)-[r2:child]->(n2:`Person`)")
6
+ expect(ActiveNode::Graph.new(Person, children: 2).send(:query)).to eq("optional match (n0)-[r1:child*1..2]->(n1:`Person`)")
7
+ expect(ActiveNode::Graph.new(Person, {children: :address}, :address).send(:query)).to eq("optional match (n0)-[r1:child]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n0)-[r3:address]->(n3:`Address`)")
8
+ expect(ActiveNode::Graph.new(Person, children: [:address, :father]).send(:query)).to eq("optional match (n0)-[r1:child]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n1)<-[r3:child]-(n3:`Person`)")
9
+ expect(ActiveNode::Graph.new(Person, {children: 2} => [:address, :father]).send(:query)).to eq("optional match (n0)-[r1:child*1..2]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n1)<-[r3:child]-(n3:`Person`)")
10
+ expect(ActiveNode::Graph.new(Person, {children: '*'} => [:address, :father]).send(:query)).to eq("optional match (n0)-[r1:child*]->(n1:`Person`) optional match (n1)-[r2:address]->(n2:`Address`) optional match (n1)<-[r3:child]-(n3:`Person`)")
13
11
  end
14
12
 
15
13
  it "should build graph" do
16
14
  person = Person.create! children: [c1=Person.create!, c2=Person.create!(address: a=Address.create!)]
17
15
  g_person = person.includes!({children: '*'} => [:address, :father])
18
16
  g_person = ActiveNode::Graph.new(Person, {children: '*'} => [:address, :father]).build(person).first
19
- g_person.should == person
20
- g_person.object_id.should == person.object_id
21
- ActiveNode::Neo.should_not_receive(:db)
22
- g_person.children.last.address.should == a
17
+ expect(g_person).to eq(person)
18
+ expect(g_person.object_id).to eq(person.object_id)
19
+ expect(ActiveNode::Neo).not_to receive(:db)
20
+ expect(g_person.children.last.address).to eq(a)
23
21
  g_person.children.first.father = person
24
- g_person.children.should == [c1, c2]
22
+ expect(g_person.children).to eq([c1, c2])
25
23
  end
26
24
 
27
25
  it "should not query db twice" do
28
26
  pending
29
27
  person = Person.create!
30
28
  person.includes! :children
31
- ActiveNode::Neo.should_not_receive(:db)
29
+ expect(ActiveNode::Neo).not_to receive(:db)
32
30
  person.children
33
31
  end
34
32
  end
35
33
 
36
34
  describe '#empty?' do
37
35
  it 'should return true' do
38
- Person.all.should be_empty
36
+ expect(Person.all).to be_empty
39
37
  end
40
38
  end
41
39
 
42
40
  describe '#detect' do
43
41
  it 'should return nil' do
44
- Person.all.detect { |p| true }.should be_nil
42
+ expect(Person.all.detect { |p| true }).to be_nil
45
43
  end
46
44
  end
47
45
 
48
46
  describe '#includes' do
49
47
  it 'should not throw an error' do
50
48
  p = Person.create! father: Person.create!
51
- Person.where(id: p.id).includes(:father).first.should == p
49
+ expect(Person.where(id: p.id).includes(:father).first).to eq(p)
52
50
  end
53
51
 
54
52
  it "should return correct associated objects" do
55
53
  child1 = Person.create! children: [Person.create!, Person.create!]
56
54
  person = Person.create! children: [child1]
57
- Person.includes(children: :children).find(person.id).children.should == [child1]
58
- Person.includes(children: 2).find(person.id).children.should == [child1]
59
- Person.includes(children: '*').find(person.id).children.should == [child1]
55
+ expect(Person.includes(children: :children).find(person.id).children).to eq([child1])
56
+ expect(Person.includes(children: 2).find(person.id).children).to eq([child1])
57
+ expect(Person.includes(children: '*').find(person.id).children).to eq([child1])
60
58
  end
61
59
  end
62
60
  end
@@ -1,22 +1,20 @@
1
- require 'spec_helper'
2
-
3
1
  describe ActiveNode::Persistence do
4
2
  describe "#save" do
5
3
  it "should save an object" do
6
4
  a=Address.create!
7
- Address.find(a.id).should == a
5
+ expect(Address.find(a.id)).to eq(a)
8
6
  end
9
7
 
10
8
  it "should not set id property" do
11
9
  a = Address.create!
12
- ActiveNode::Neo.db.get_node_properties(a.id).should be_nil
10
+ expect(ActiveNode::Neo.db.get_node_properties(a.id)['id']).to be_nil
13
11
  a.save
14
- ActiveNode::Neo.db.get_node_properties(a.id).should be_nil
12
+ expect(ActiveNode::Neo.db.get_node_properties(a.id)['id']).to be_nil
15
13
  end
16
14
 
17
15
  it "should save unconventionally named object" do
18
- NeoUser.new(name: 'Heinrich').save.should be_true
19
- NeoUser.all.map(&:name).should == ['Heinrich']
16
+ expect(NeoUser.new(name: 'Heinrich').save).to be_truthy
17
+ expect(NeoUser.all.map(&:name)).to eq(['Heinrich'])
20
18
  end
21
19
 
22
20
  it "should save object with non attribute properties with a name of a relationship" do
@@ -25,44 +23,44 @@ describe ActiveNode::Persistence do
25
23
  person[:children] = "Bob"
26
24
  person.save
27
25
  person = Person.find person.id
28
- person[:children].should == "Bob"
29
- person.children.should == [child]
26
+ expect(person[:children]).to eq("Bob")
27
+ expect(person.children).to eq([child])
30
28
  end
31
29
 
32
30
  it 'should destroy node' do
33
31
  user = NeoUser.create!(name: 'abc')
34
- NeoUser.count.should == 1
35
- user.destroy.should be_true
36
- NeoUser.count.should == 0
32
+ expect(NeoUser.count).to eq(1)
33
+ expect(user.destroy).to be_truthy
34
+ expect(NeoUser.count).to eq(0)
37
35
  end
38
36
 
39
37
  it 'should not destroy node with relationships' do
40
38
  person = Person.create! children: [Person.create!, Person.create!]
41
- person.destroy.should be_false
42
- Person.count.should == 3
39
+ expect(person.destroy).to be_falsey
40
+ expect(Person.count).to eq(3)
43
41
  end
44
42
 
45
43
  it 'should destroy! node with relationships' do
46
44
  person = Person.create! children: [Person.create!, Person.create!]
47
- person.destroy!.should be_true
48
- Person.count.should == 2
45
+ expect(person.destroy!).to be_truthy
46
+ expect(Person.count).to eq(2)
49
47
  end
50
48
 
51
49
  it 'should record timestamp' do
52
50
  now = Time.now
53
51
  person = Person.create!
54
- person.created_at.should_not be_nil
52
+ expect(person.created_at).not_to be_nil
55
53
  person = Person.find(person.id)
56
- person.created_at.should_not be_nil
57
- person.updated_at.should_not be_nil
54
+ expect(person.created_at).not_to be_nil
55
+ expect(person.updated_at).not_to be_nil
58
56
  allow(Time).to receive(:now) { now + 1.second }
59
57
  person.name = 'abc'
60
58
  person.save
61
- (person.created_at < person.updated_at).should be_true
59
+ expect(person.created_at < person.updated_at).to be_truthy
62
60
  end
63
61
 
64
62
  it 'should not record timestamp if not specified' do
65
- Client.create!(name: 'abc').respond_to?(:created_at).should be_false
63
+ expect(Client.create!(name: 'abc').respond_to?(:created_at)).to be_falsey
66
64
  end
67
65
  end
68
66
 
@@ -82,47 +80,47 @@ describe ActiveNode::Persistence do
82
80
 
83
81
  describe "#create!" do
84
82
  it "should persist attributes" do
85
- Person.create!(name: 'abc').name.should == 'abc'
83
+ expect(Person.create!(name: 'abc').name).to eq('abc')
86
84
  end
87
85
 
88
86
  it "should persist array properties" do
89
87
  person = Person.create!(multi: [1, 2, 3])
90
- Person.find(person.id).multi.should == [1, 2, 3]
88
+ expect(Person.find(person.id).multi).to eq([1, 2, 3])
91
89
  end
92
90
  end
93
91
 
94
92
  describe "#find" do
95
93
  it 'should find an object by id' do
96
94
  person = Person.create!
97
- Person.find(person.id).should == person
95
+ expect(Person.find(person.id)).to eq(person)
98
96
  end
99
97
 
100
98
  it 'should find objects passing multiple ids' do
101
99
  person1 = Person.create!
102
100
  person2 = Person.create!
103
- Person.find([person1.id, person2.id]).to_a.should == [person1, person2]
101
+ expect(Person.find([person1.id, person2.id]).to_a).to eq([person1, person2])
104
102
  end
105
103
 
106
104
  it 'should find an object with id of an unknown model' do
107
- ActiveNode::Base.find(Person.create!.id).class.should == Person
105
+ expect(ActiveNode::Base.find(Person.create!.id).class).to eq(Person)
108
106
  end
109
107
  end
110
108
 
111
109
  describe "#attributes" do
112
110
  it "should include id" do
113
- Person.create!(name: 'abc').attributes['id'].should_not be_nil
111
+ expect(Person.create!(name: 'abc').attributes['id']).not_to be_nil
114
112
  end
115
113
  end
116
114
 
117
115
  describe "#to_param" do
118
116
  it "should return a string version of the id" do
119
117
  person = Person.create!
120
- person.to_param.should == person.id.to_s
118
+ expect(person.to_param).to eq(person.id.to_s)
121
119
  end
122
120
 
123
121
  it "should return nil if the id is nil" do
124
122
  person = Person.new
125
- person.to_param.should be_nil
123
+ expect(person.to_param).to be_nil
126
124
  end
127
125
  end
128
126
 
@@ -149,7 +147,7 @@ describe ActiveNode::Persistence do
149
147
  a = Address.create!
150
148
  p=Person.create!(name: 'abc', address: a)
151
149
  c=Client.create!(name: 'client', address: a)
152
- a.incoming(:address).should include(p, c)
150
+ expect(a.incoming(:address)).to include(p, c)
153
151
  end
154
152
  end
155
153
 
@@ -157,13 +155,23 @@ describe ActiveNode::Persistence do
157
155
  it "should update atribute without validation" do
158
156
  client = Client.create!(name: 'abc')
159
157
  client.update_attribute(:name, nil)
160
- Client.find(client.id).name.should be_nil
158
+ expect(Client.find(client.id).name).to be_nil
161
159
  end
162
160
  end
163
161
 
164
162
  describe "#wrap" do
165
163
  it "should wrap nil as nil" do
166
- Client.wrap(nil).should be_nil
164
+ expect(Client.wrap(nil)).to be_nil
165
+ end
166
+ end
167
+
168
+ describe "default" do
169
+ it "should default new object" do
170
+ expect(Address.new.city).to eq "New York"
171
+ end
172
+
173
+ it "should default created object" do
174
+ expect(Address.create!.city).to eq "New York"
167
175
  end
168
176
  end
169
177
  end
@@ -1,32 +1,30 @@
1
- require 'spec_helper'
2
-
3
1
  describe ActiveNode::Validations do
4
2
  describe "#save" do
5
3
  it "should not save invalid object" do
6
- Client.new.save.should be_false
4
+ expect(Client.new.save).to be_falsey
7
5
  end
8
6
 
9
7
  it "should save valid object" do
10
- Client.new(name: 'abc7').save.should be_true
11
- Client.all.first.name.should == 'abc7'
8
+ expect(Client.new(name: 'abc7').save).to be_truthy
9
+ expect(Client.all.first.name).to eq('abc7')
12
10
  end
13
11
 
14
12
  describe "with uniqueness constraint" do
15
13
  it "should validate uniqueness" do
16
14
  Person.create! name: 'abc'
17
- Person.new(name: 'abc').should_not be_valid
15
+ expect(Person.new(name: 'abc')).not_to be_valid
18
16
  end
19
17
 
20
18
  it "should still be valid after save" do
21
19
  person = Person.create! name: "abc"
22
- person.should be_valid
20
+ expect(person).to be_valid
23
21
  end
24
22
  end
25
23
 
26
24
  it "should validate presence on has_one" do
27
- House.new.should_not be_valid
25
+ expect(House.new).not_to be_valid
28
26
  house = House.create! address_id: Address.create!.id
29
- House.find(house.id).should be_valid
27
+ expect(House.find(house.id)).to be_valid
30
28
  end
31
29
  end
32
30
  end
@@ -1,2 +1,3 @@
1
1
  class Address < ActiveNode::Base
2
+ attribute :city, type: String, default: "New York"
2
3
  end
@@ -42,12 +42,12 @@ end
42
42
 
43
43
  def error_response(attributes)
44
44
  request_uri = double()
45
- request_uri.stub(:request_uri).and_return("")
45
+ allow(request_uri).to receive(:request_uri).and_return("")
46
46
 
47
47
  http_header = double()
48
- http_header.stub(:request_uri).and_return(request_uri)
48
+ allow(http_header).to receive(:request_uri).and_return(request_uri)
49
49
 
50
- stub(
50
+ double(
51
51
  http_header: http_header,
52
52
  code: attributes[:code],
53
53
  body: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_node
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -39,61 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: activemodel
42
+ name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
60
46
  - !ruby/object:Gem::Version
61
47
  version: '0'
62
- type: :runtime
48
+ type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - ">="
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "<="
74
- - !ruby/object:Gem::Version
75
- version: 2.14.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "<="
81
- - !ruby/object:Gem::Version
82
- version: 2.14.1
83
- - !ruby/object:Gem::Dependency
84
- name: net-http-spy
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 0.2.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 0.2.1
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: rake
99
57
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +102,7 @@ extensions: []
144
102
  extra_rdoc_files: []
145
103
  files:
146
104
  - ".gitignore"
105
+ - ".rspec"
147
106
  - ".travis.yml"
148
107
  - Gemfile
149
108
  - LICENSE