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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 846eca2bba6266d70bc2238dd6bafd85257314e0
4
- data.tar.gz: f8804952b0756317edfd7c79e1dd80a3bf8206a7
3
+ metadata.gz: f2294bb93b469bfefc0a36b829f1d30a6c85d43a
4
+ data.tar.gz: 4b0a2c6565a3ae523bb748a4e3e1d00c84b4bb3b
5
5
  SHA512:
6
- metadata.gz: a3182e3bc85cdabb365541063bd7ca5a403537be8661e55bdb12001fba6f583587157663323d54bf66f485a0ab277f3d026a3e09cce4adf5751c50aee6249b67
7
- data.tar.gz: 00ff2db2662c9bf8a46c6ac426850453ddbe9e74d027ed36f35475cf3116f193cef0d6cc2bf2c0caadfa553c6e5559f6ceab22c460014259c61e6033a8a507a9
6
+ metadata.gz: ab140228326d5dc93958a6fc0b995e6dc6ab24b1ba390b7d8df48ae4d489a63f02cadee12a1030e9abad0a0467216a34a24fabaab787fdb30e3bd6e6247d47e5
7
+ data.tar.gz: 50d4691c8d0de15de244f1b3083d7ca4327c10ab6df4ccb01e9ef13eefdc3654234781f3012171458aa107ec05d0692dc200abe3d9d30362d222d60e7ba38c92
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chicanery (0.1.4)
4
+ chicanery (0.1.5)
5
5
  nokogiri (~> 1)
6
6
 
7
7
  GEM
data/lib/chicanery.rb CHANGED
@@ -16,7 +16,7 @@ module Chicanery
16
16
  include Repos
17
17
  include Sites
18
18
 
19
- VERSION = "0.1.4"
19
+ VERSION = "0.1.5"
20
20
 
21
21
  def poll_period seconds=nil
22
22
  @poll_period = seconds if seconds
@@ -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 uri.path
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) { stub 'file' }
5
- let(:state) { stub 'state', to_yaml: :yaml }
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! :notify_failed_handlers
27
- stub! :notify_succeeded_handlers
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 }
@@ -1,34 +1,36 @@
1
1
  describe Chicanery do
2
- include Chicanery
2
+ subject { Object.new.extend Chicanery }
3
3
 
4
4
  describe '#execute' do
5
- before { %w{load restore persist}.each {|m| stub! m } }
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
- include Chicanery
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 { stub!("restore").and_return({})}
18
- before { %w{persist}.each {|m| stub! m } }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chicanery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall