rubolite 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,16 @@ module Rubolite
12
12
  @path = path if path && valid_path?(path)
13
13
  end
14
14
 
15
+ def reset!
16
+ @parser = nil
17
+ @writer = nil
18
+ @git = nil
19
+ @repo_origin = nil
20
+ @client = nil
21
+
22
+ self
23
+ end
24
+
15
25
  def path=(new_path)
16
26
  valid_path?(new_path)
17
27
  @path = new_path
@@ -29,12 +29,14 @@ module Rubolite
29
29
 
30
30
  def save!
31
31
  admin.writer.write!
32
+ reset!
32
33
  end
33
34
 
34
35
  def save_ssh_keys!
35
36
  ssh_keys.each do |user, key|
36
37
  key.write_for user, "#{admin.path}/keydir"
37
38
  end
39
+ reset!
38
40
  end
39
41
 
40
42
  def commit!
@@ -52,5 +54,12 @@ module Rubolite
52
54
  commit!
53
55
  push!
54
56
  end
57
+
58
+ def reset!
59
+ admin.reset!
60
+ @repos = nil
61
+ @groups = nil
62
+ @ssh_keys = {}
63
+ end
55
64
  end
56
65
  end
@@ -1,3 +1,3 @@
1
1
  module Rubolite
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -7,6 +7,40 @@ describe Rubolite::Admin do
7
7
  expect(subject.client).to be_kind_of Rubolite::Client
8
8
  end
9
9
 
10
+ context "reset!" do
11
+ let(:admin) { Rubolite::Admin.new("./spec/support/gitolite-admin") }
12
+
13
+ it "resets the parser" do
14
+ parser = admin.parser
15
+ admin.reset!
16
+ expect(admin.parser).not_to eq(parser)
17
+ end
18
+
19
+ it "resets the writer" do
20
+ writer = admin.writer
21
+ admin.reset!
22
+ expect(admin.writer).not_to eq(writer)
23
+ end
24
+
25
+ it "resets git" do
26
+ git = admin.git
27
+ admin.reset!
28
+ expect(admin.git).not_to eq(git)
29
+ end
30
+
31
+ it "resets repo_origin" do
32
+ repo_origin = admin.repo_origin
33
+ admin.reset!
34
+ expect(admin.repo_origin).not_to eq(repo_origin)
35
+ end
36
+
37
+ it "resets the client" do
38
+ client = admin.client
39
+ admin.reset!
40
+ expect(admin.client).not_to eq(client)
41
+ end
42
+ end
43
+
10
44
  context "location" do
11
45
  it "sets a location on initialization if given" do
12
46
  admin = Rubolite::Admin.new("./spec/support/gitolite-admin")
@@ -72,5 +72,40 @@ describe Rubolite::Client do
72
72
  subject.should_receive(:push!)
73
73
  subject.save_and_push!
74
74
  end
75
+
76
+ it "resets and reparses after save is called" do
77
+ subject.should_receive(:reset!)
78
+ subject.save!
79
+ end
80
+
81
+ it "resets and reparses after save_ssh_keys is called" do
82
+ subject.should_receive(:reset!)
83
+ subject.save_ssh_keys!
84
+ end
85
+ end
86
+
87
+ context "resetting" do
88
+ it "resets the admin" do
89
+ subject.admin.should_receive(:reset!)
90
+ subject.reset!
91
+ end
92
+
93
+ it "resets it's repos" do
94
+ repos = subject.repos
95
+ subject.reset!
96
+ expect(subject.repos).not_to eq(repos)
97
+ end
98
+
99
+ it "resets it's groups" do
100
+ groups = subject.groups.object_id
101
+ subject.reset!
102
+ expect(subject.groups.object_id).not_to eq(groups)
103
+ end
104
+
105
+ it "resets it's ssh keys" do
106
+ ssh_keys = subject.ssh_keys.object_id
107
+ subject.reset!
108
+ expect(subject.ssh_keys.object_id).not_to eq(ssh_keys)
109
+ end
75
110
  end
76
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubolite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-15 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec