chicanery 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/chicanery.rb +1 -1
- data/lib/chicanery/site.rb +5 -2
- data/spec/chicanery/persistence_spec.rb +2 -2
- data/spec/chicanery/servers_spec.rb +2 -2
- data/spec/chicanery_spec.rb +15 -13
- data/spec/embedded_chicanery_spec.rb +12 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2294bb93b469bfefc0a36b829f1d30a6c85d43a
|
4
|
+
data.tar.gz: 4b0a2c6565a3ae523bb748a4e3e1d00c84b4bb3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab140228326d5dc93958a6fc0b995e6dc6ab24b1ba390b7d8df48ae4d489a63f02cadee12a1030e9abad0a0467216a34a24fabaab787fdb30e3bd6e6247d47e5
|
7
|
+
data.tar.gz: 50d4691c8d0de15de244f1b3083d7ca4327c10ab6df4ccb01e9ef13eefdc3654234781f3012171458aa107ec05d0692dc200abe3d9d30362d222d60e7ba38c92
|
data/Gemfile.lock
CHANGED
data/lib/chicanery.rb
CHANGED
data/lib/chicanery/site.rb
CHANGED
@@ -10,9 +10,12 @@ module Chicanery
|
|
10
10
|
@name, @uri, @options = name, URI(url), options
|
11
11
|
end
|
12
12
|
|
13
|
+
def path
|
14
|
+
uri.query ? "#{uri.path}?#{uri.query}" : uri.path
|
15
|
+
end
|
16
|
+
|
13
17
|
def get
|
14
|
-
req = Net::HTTP::Get.new
|
15
|
-
req += "?#{uri.query}" if uri.query
|
18
|
+
req = Net::HTTP::Get.new path
|
16
19
|
req.basic_auth options[:user], options[:password] if options[:user] and options[:password]
|
17
20
|
http_opts = { use_ssl: uri.scheme == 'https' }
|
18
21
|
http_opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless options[:verify_ssl]
|
@@ -1,8 +1,8 @@
|
|
1
1
|
describe Chicanery::Persistence do
|
2
2
|
include Chicanery::Persistence
|
3
3
|
|
4
|
-
let(:file) {
|
5
|
-
let(:state) {
|
4
|
+
let(:file) { double 'file' }
|
5
|
+
let(:state) { double 'state', to_yaml: :yaml }
|
6
6
|
|
7
7
|
describe '#persist' do
|
8
8
|
it 'should write state to disk as yaml' do
|
@@ -23,8 +23,8 @@ describe Chicanery::Servers do
|
|
23
23
|
let(:previous_job) { { activity: :sleeping, last_build_time: 5 } }
|
24
24
|
|
25
25
|
before {
|
26
|
-
stub
|
27
|
-
stub
|
26
|
+
subject.stub :notify_failed_handlers
|
27
|
+
subject.stub :notify_succeeded_handlers
|
28
28
|
}
|
29
29
|
|
30
30
|
after { compare_job 'name', current_job, previous_job }
|
data/spec/chicanery_spec.rb
CHANGED
@@ -1,34 +1,36 @@
|
|
1
1
|
describe Chicanery do
|
2
|
-
|
2
|
+
subject { Object.new.extend Chicanery }
|
3
3
|
|
4
4
|
describe '#execute' do
|
5
|
-
before
|
5
|
+
before do
|
6
|
+
%w{load restore persist}.each {|m| subject.stub m }
|
7
|
+
end
|
6
8
|
|
7
|
-
after { execute ['configuration'] }
|
9
|
+
after { subject.execute ['configuration'] }
|
8
10
|
|
9
11
|
it 'should load configuration and exit immediately when nothing is configured no poll period is provided' do
|
10
|
-
should_receive(:load).with 'configuration'
|
12
|
+
subject.should_receive(:load).with 'configuration'
|
11
13
|
end
|
12
14
|
|
13
15
|
it 'should restore previous state' do
|
14
|
-
should_receive(:restore)
|
16
|
+
subject.should_receive(:restore)
|
15
17
|
end
|
16
18
|
|
17
19
|
it 'should persist new state' do
|
18
|
-
should_receive(:persist).with servers: {}, repos: {}, sites: {}
|
20
|
+
subject.should_receive(:persist).with servers: {}, repos: {}, sites: {}
|
19
21
|
end
|
20
22
|
|
21
23
|
it 'should sleep for specified time when poll period is provided' do
|
22
|
-
should_receive(:sleep).with(10).and_raise Interrupt
|
23
|
-
poll_period 10
|
24
|
+
subject.should_receive(:sleep).with(10).and_raise Interrupt
|
25
|
+
subject.poll_period 10
|
24
26
|
end
|
25
27
|
|
26
28
|
it "polls with a specified period" do
|
27
|
-
should_receive(:run).exactly(3).times
|
28
|
-
should_receive(:sleep).with(10).ordered
|
29
|
-
should_receive(:sleep).with(10).ordered
|
30
|
-
should_receive(:sleep).with(10).ordered.and_raise Interrupt
|
31
|
-
poll_period 10
|
29
|
+
subject.should_receive(:run).exactly(3).times
|
30
|
+
subject.should_receive(:sleep).with(10).ordered
|
31
|
+
subject.should_receive(:sleep).with(10).ordered
|
32
|
+
subject.should_receive(:sleep).with(10).ordered.and_raise Interrupt
|
33
|
+
subject.poll_period 10
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -1,30 +1,31 @@
|
|
1
1
|
describe Chicanery do
|
2
|
-
|
2
|
+
subject { Object.new.extend Chicanery }
|
3
3
|
|
4
4
|
describe '#run' do
|
5
|
-
|
6
5
|
before do
|
7
|
-
server double("Server A", :name => "A", :jobs => "A jobs")
|
8
|
-
server double("Server B", :name => "B", :jobs => "B jobs")
|
9
|
-
repo double("repo X", :name => "X", :state => "X state")
|
10
|
-
repo double("repo Y", :name => "Y", :state => "Y state")
|
11
|
-
when_run do |current_state|
|
6
|
+
subject.server double("Server A", :name => "A", :jobs => "A jobs")
|
7
|
+
subject.server double("Server B", :name => "B", :jobs => "B jobs")
|
8
|
+
subject.repo double("repo X", :name => "X", :state => "X state")
|
9
|
+
subject.repo double("repo Y", :name => "Y", :state => "Y state")
|
10
|
+
subject.when_run do |current_state|
|
12
11
|
@current_state = current_state
|
13
12
|
end
|
14
13
|
@current_state = nil
|
15
14
|
end
|
16
15
|
|
17
|
-
before
|
18
|
-
|
16
|
+
before do
|
17
|
+
subject.stub("restore") { {} }
|
18
|
+
subject.stub("persist")
|
19
|
+
end
|
19
20
|
|
20
21
|
it "notifies when_run listeners of the current state of the servers jobs" do
|
21
|
-
run
|
22
|
+
subject.run
|
22
23
|
@current_state[:servers]["A"].should == "A jobs"
|
23
24
|
@current_state[:servers]["B"].should == "B jobs"
|
24
25
|
end
|
25
26
|
|
26
27
|
it "notifies when_run listeners of the current state of the repos" do
|
27
|
-
run
|
28
|
+
subject.run
|
28
29
|
@current_state[:repos]["X"].should == "X state"
|
29
30
|
@current_state[:repos]["Y"].should == "Y state"
|
30
31
|
end
|
@@ -33,6 +34,5 @@ describe Chicanery do
|
|
33
34
|
# it restores previous state and records current state
|
34
35
|
# it compares current state and previous state for each server
|
35
36
|
# it compares current state and previous state for each server
|
36
|
-
|
37
37
|
end
|
38
38
|
end
|