chicanery 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chicanery (0.0.7)
4
+ chicanery (0.0.8)
5
5
  nokogiri (~> 1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.1.3)
11
+ fakeweb (1.3.0)
11
12
  multi_json (1.3.7)
12
- nokogiri (1.5.5)
13
+ nokogiri (1.5.6)
13
14
  rake (0.9.2.2)
14
15
  rspec (2.11.0)
15
16
  rspec-core (~> 2.11.0)
@@ -25,13 +26,16 @@ GEM
25
26
  simplecov-gem-adapter (1.0.1)
26
27
  simplecov
27
28
  simplecov-html (0.7.1)
29
+ vcr (2.3.0)
28
30
 
29
31
  PLATFORMS
30
32
  ruby
31
33
 
32
34
  DEPENDENCIES
33
35
  chicanery!
36
+ fakeweb
34
37
  rake (~> 0)
35
38
  rspec (~> 2)
36
39
  simplecov
37
40
  simplecov-gem-adapter
41
+ vcr
data/README.md CHANGED
@@ -56,12 +56,16 @@ Now you can schedule the following command with cron:
56
56
 
57
57
  chicanery myconfiguration
58
58
 
59
- Or continuously poll every 10 seconds:
59
+ Or to continuously poll every 10 seconds, add the following line to the configuration:
60
60
 
61
- chicanery myconfiguration 10
61
+ poll_period 10
62
62
 
63
63
  You'll notice a file called 'state' is created which represents the state at the last execution. This is then restored during the next execution to detect events such as a new build succeeding/failing.
64
64
 
65
+ If you want to specify an alternate location for this state file, add the following line to your configuration file:
66
+
67
+ persist_state_to '/tmp/build_state'
68
+
65
69
  ## Supported CI servers
66
70
 
67
71
  Currently only ci servers that can provide [cctray reporting format](http://confluence.public.thoughtworks.org/display/CI/Multiple+Project+Summary+Reporting+Standard) are supported.
data/chicanery.gemspec CHANGED
@@ -23,4 +23,6 @@ Gem::Specification.new do |gem|
23
23
  gem.add_development_dependency 'rspec', '~>2'
24
24
  gem.add_development_dependency 'simplecov'
25
25
  gem.add_development_dependency 'simplecov-gem-adapter'
26
+ gem.add_development_dependency 'vcr'
27
+ gem.add_development_dependency 'fakeweb'
26
28
  end
@@ -2,7 +2,9 @@ require 'chicanery/git'
2
2
 
3
3
  include Chicanery::Git
4
4
 
5
- git_repo 'chicanery', '.', branches: [:master]
5
+ git 'chicanery', '.', branches: [:master]
6
+
7
+ poll_period 10
6
8
 
7
9
  def now
8
10
  Time.now.to_i
@@ -0,0 +1,14 @@
1
+ require 'blinky'
2
+ require 'chicanery/cctray'
3
+
4
+ include Chicanery::Cctray
5
+
6
+ cctray 'travis', 'https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml'
7
+
8
+ when_run do |state|
9
+ if state.has_failure?
10
+ Blinky.new.light.failure!
11
+ else
12
+ Blinky.new.light.success!
13
+ end
14
+ end
@@ -2,12 +2,15 @@ require 'chicanery/cctray'
2
2
  require 'chicanery/git'
3
3
 
4
4
  include Chicanery::Git
5
+ include Chicanery::Cctray
5
6
 
6
- git_repo 'chicanery', '.', branches: [:master], remotes: {
7
+ git 'chicanery', '.', branches: [:master], remotes: {
7
8
  github: { url: 'git://github.com/markryall/chicanery.git' }
8
9
  }
9
10
 
10
- server Chicanery::Cctray.new 'travis', 'https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml'
11
+ cctray 'travis', 'https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml'
12
+
13
+ poll_period 10
11
14
 
12
15
  def growlnotify message
13
16
  `growlnotify -t "some new chicanery ..." --image ~/icons/chicanery.png -m \"#{message}\"`
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ access-control-allow-credentials:
20
+ - 'true'
21
+ access-control-allow-origin:
22
+ - ! '*'
23
+ access-control-expose-headers:
24
+ - Content-Type, Cache-Control, Expires, Etag, Last-Modified
25
+ cache-control:
26
+ - no-cache
27
+ content-type:
28
+ - application/json;charset=utf-8
29
+ date:
30
+ - Sat, 15 Dec 2012 02:41:37 GMT
31
+ etag:
32
+ - ! '"715c01a97e6124876f63088110deeafd"'
33
+ status:
34
+ - 200 OK
35
+ strict-transport-security:
36
+ - max-age=31536000
37
+ vary:
38
+ - Accept,Accept-Encoding
39
+ x-accepted-oauth-scopes:
40
+ - public
41
+ x-oauth-scopes:
42
+ - public
43
+ content-length:
44
+ - '245'
45
+ connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ! "<Projects>\n <Project\n name=\"markryall/chicanery\"\n activity=\"Sleeping\"\n
50
+ \ lastBuildStatus=\"Failure\"\n lastBuildLabel=\"50\"\n lastBuildTime=\"2012-12-15T02:41:20.000+0000\"\n
51
+ \ webUrl=\"api.travis-ci.org/markryall/chicanery\" />\n</Projects>"
52
+ http_version: '1.1'
53
+ recorded_at: Sat, 15 Dec 2012 02:41:42 GMT
54
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ access-control-allow-credentials:
20
+ - 'true'
21
+ access-control-allow-origin:
22
+ - ! '*'
23
+ access-control-expose-headers:
24
+ - Content-Type, Cache-Control, Expires, Etag, Last-Modified
25
+ cache-control:
26
+ - no-cache
27
+ content-type:
28
+ - application/json;charset=utf-8
29
+ date:
30
+ - Sat, 15 Dec 2012 02:36:15 GMT
31
+ etag:
32
+ - ! '"0bb76c5892b2ce7a7efafc2b41bc2512"'
33
+ status:
34
+ - 200 OK
35
+ strict-transport-security:
36
+ - max-age=31536000
37
+ vary:
38
+ - Accept,Accept-Encoding
39
+ x-accepted-oauth-scopes:
40
+ - public
41
+ x-oauth-scopes:
42
+ - public
43
+ content-length:
44
+ - '245'
45
+ connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ! "<Projects>\n <Project\n name=\"markryall/chicanery\"\n activity=\"Sleeping\"\n
50
+ \ lastBuildStatus=\"Success\"\n lastBuildLabel=\"48\"\n lastBuildTime=\"2012-12-15T02:18:28.000+0000\"\n
51
+ \ webUrl=\"api.travis-ci.org/markryall/chicanery\" />\n</Projects>"
52
+ http_version: '1.1'
53
+ recorded_at: Sat, 15 Dec 2012 02:36:20 GMT
54
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ access-control-allow-credentials:
20
+ - 'true'
21
+ access-control-allow-origin:
22
+ - ! '*'
23
+ access-control-expose-headers:
24
+ - Content-Type, Cache-Control, Expires, Etag, Last-Modified
25
+ cache-control:
26
+ - no-cache
27
+ content-type:
28
+ - application/json;charset=utf-8
29
+ date:
30
+ - Sat, 15 Dec 2012 02:39:04 GMT
31
+ etag:
32
+ - ! '"aa451983b94cbec99aa94346f358b5b0"'
33
+ status:
34
+ - 200 OK
35
+ strict-transport-security:
36
+ - max-age=31536000
37
+ vary:
38
+ - Accept,Accept-Encoding
39
+ x-accepted-oauth-scopes:
40
+ - public
41
+ x-oauth-scopes:
42
+ - public
43
+ content-length:
44
+ - '217'
45
+ connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ! "Nothing here but us chickens"
50
+ http_version: '1.1'
51
+ recorded_at: Sat, 15 Dec 2012 02:39:09 GMT
52
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 301
17
+ message: Redirect
18
+ headers:
19
+ access-control-allow-credentials:
20
+ - 'true'
21
+ access-control-allow-origin:
22
+ - ! '*'
23
+ access-control-expose-headers:
24
+ - Content-Type, Cache-Control, Expires, Etag, Last-Modified
25
+ cache-control:
26
+ - no-cache
27
+ content-type:
28
+ - application/json;charset=utf-8
29
+ date:
30
+ - Sat, 15 Dec 2012 02:39:04 GMT
31
+ etag:
32
+ - ! '"aa451983b94cbec99aa94346f358b5b0"'
33
+ status:
34
+ - 200 OK
35
+ strict-transport-security:
36
+ - max-age=31536000
37
+ vary:
38
+ - Accept,Accept-Encoding
39
+ x-accepted-oauth-scopes:
40
+ - public
41
+ x-oauth-scopes:
42
+ - public
43
+ content-length:
44
+ - '217'
45
+ connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ! "hhh"
50
+ http_version: '1.1'
51
+ recorded_at: Sat, 15 Dec 2012 02:39:09 GMT
52
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ access-control-allow-credentials:
20
+ - 'true'
21
+ access-control-allow-origin:
22
+ - ! '*'
23
+ access-control-expose-headers:
24
+ - Content-Type, Cache-Control, Expires, Etag, Last-Modified
25
+ cache-control:
26
+ - no-cache
27
+ content-type:
28
+ - application/json;charset=utf-8
29
+ date:
30
+ - Sat, 15 Dec 2012 02:39:04 GMT
31
+ etag:
32
+ - ! '"aa451983b94cbec99aa94346f358b5b0"'
33
+ status:
34
+ - 200 OK
35
+ strict-transport-security:
36
+ - max-age=31536000
37
+ vary:
38
+ - Accept,Accept-Encoding
39
+ x-accepted-oauth-scopes:
40
+ - public
41
+ x-oauth-scopes:
42
+ - public
43
+ content-length:
44
+ - '217'
45
+ connection:
46
+ - keep-alive
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ! "<Projects>\n <Project\n name=\"markryall/chicanery\"\n activity=\"Building\"\n
50
+ \ lastBuildStatus=\"Unknown\"\n lastBuildLabel=\"49\"\n lastBuildTime=\"\"\n
51
+ \ webUrl=\"api.travis-ci.org/markryall/chicanery\" />\n</Projects>"
52
+ http_version: '1.1'
53
+ recorded_at: Sat, 15 Dec 2012 02:39:09 GMT
54
+ recorded_with: VCR 2.3.0
data/lib/chicanery.rb CHANGED
@@ -16,29 +16,26 @@ module Chicanery
16
16
  include Handlers
17
17
  include StateComparison
18
18
 
19
- VERSION = "0.0.7"
19
+ VERSION = "0.0.8"
20
20
 
21
- def execute args
22
- load args.shift
23
- poll_period = args.shift
24
- if poll_period
25
- run_every poll_period.to_i
26
- else
27
- run
28
- end
21
+ def poll_period seconds=nil
22
+ @poll_period = seconds if seconds
23
+ @poll_period
29
24
  end
30
25
 
31
- def run_every poll_period
26
+ def execute args
27
+ load args.shift
32
28
  begin
33
29
  loop do
34
30
  run
31
+ break unless poll_period
35
32
  sleep poll_period
36
33
  end
37
34
  rescue Interrupt
38
35
  end
39
36
  end
40
37
 
41
- def run
38
+ def run
42
39
  previous_state = restore
43
40
  current_state = {
44
41
  servers: {},
@@ -55,8 +52,8 @@ module Chicanery
55
52
  current_state[:servers][server.name] = current_jobs
56
53
  end
57
54
  current_state.extend Chicanery::Summary
58
- run_handlers.each {|handler| handler.call current_state }
59
- persist current_state
55
+ run_handlers.each {|handler| handler.call current_state, previous_state }
56
+ persist current_state
60
57
  end
61
58
 
62
59
  end
@@ -3,48 +3,61 @@ require 'nokogiri'
3
3
  require 'date'
4
4
 
5
5
  module Chicanery
6
- class Cctray
7
- attr_reader :name, :uri, :options
6
+ module Cctray
7
+ def self.new *args
8
+ Cctray::Server.new *args
9
+ end
8
10
 
9
- def initialize name, url, options={}
10
- @name, @uri, @options = name, URI(url), options
11
+ def cctray *args
12
+ server Cctray::Server.new *args
11
13
  end
12
14
 
13
- def get
14
- req = Net::HTTP::Get.new(uri.path)
15
- req.basic_auth user, password if options[:user] and options[:password]
16
- res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE) do |https|
17
- https.request(req)
15
+ class Server
16
+ attr_reader :name, :uri, :options
17
+
18
+ def initialize name, url, options={}
19
+ @name, @uri, @options = name, URI(url), options
18
20
  end
19
- res.body
20
- end
21
21
 
22
- def jobs
23
- jobs = {}
24
- Nokogiri::XML(get).css("Project").each do |project|
25
- job = {
26
- activity: project[:activity] == 'Sleeping' ? :sleeping : :building,
27
- last_build_status: parse_build_status(project[:lastBuildStatus]),
28
- last_build_time: project[:lastBuildTime].empty? ? nil : DateTime.parse(project[:lastBuildTime]).to_time.to_i,
29
- url: project[:webUrl],
30
- last_label: project[:lastBuildLabel]
31
- }
32
- jobs[project[:name]] = job unless filtered project[:name]
22
+ def get
23
+ req = Net::HTTP::Get.new(uri.path)
24
+ req.basic_auth user, password if options[:user] and options[:password]
25
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE) do |https|
26
+ https.request(req)
27
+ end
28
+ res.value #check for success via a spectactulalry poorly named method
29
+ res.body
33
30
  end
34
- jobs
35
- end
36
31
 
37
- def parse_build_status status
38
- case status
39
- when /^Success/ then :success
40
- when /^Unknown/ then :unknown
41
- else :failure
32
+ def jobs
33
+ jobs = {}
34
+ response_body = get
35
+ Nokogiri::XML(response_body).css("Project").each do |project|
36
+ job = {
37
+ activity: project[:activity] == 'Sleeping' ? :sleeping : :building,
38
+ last_build_status: parse_build_status(project[:lastBuildStatus]),
39
+ last_build_time: project[:lastBuildTime].empty? ? nil : DateTime.parse(project[:lastBuildTime]).to_time.to_i,
40
+ url: project[:webUrl],
41
+ last_label: project[:lastBuildLabel]
42
+ }
43
+ jobs[project[:name]] = job unless filtered project[:name]
44
+ end
45
+ raise "could not find any jobs in response: [#{response_body}]" if jobs.empty?
46
+ jobs
47
+ end
48
+
49
+ def parse_build_status status
50
+ case status
51
+ when /^Success/ then :success
52
+ when /^Unknown/ then :unknown
53
+ else :failure
54
+ end
42
55
  end
43
- end
44
56
 
45
- def filtered name
46
- return false unless options[:include]
47
- !options[:include].match(name)
57
+ def filtered name
58
+ return false unless options[:include]
59
+ !options[:include].match(name)
60
+ end
48
61
  end
49
62
  end
50
63
  end
data/lib/chicanery/git.rb CHANGED
@@ -54,7 +54,7 @@ module Chicanery
54
54
  end
55
55
  end
56
56
 
57
- def git_repo *args
57
+ def git *args
58
58
  repo Repo.new *args
59
59
  end
60
60
  end
@@ -3,14 +3,19 @@ require 'yaml'
3
3
  module Chicanery
4
4
  module Persistence
5
5
  def persist state
6
- File.open 'state', 'w' do |file|
6
+ File.open persist_state_to, 'w' do |file|
7
7
  file.puts state.to_yaml
8
8
  end
9
9
  end
10
10
 
11
11
  def restore
12
- return {} unless File.exist? 'state'
13
- YAML.load_file 'state'
12
+ return {} unless File.exist? persist_state_to
13
+ YAML.load_file persist_state_to
14
+ end
15
+
16
+ def persist_state_to path=nil
17
+ @state = path if path
18
+ @state || 'state'
14
19
  end
15
20
  end
16
21
  end
@@ -0,0 +1,68 @@
1
+ require 'chicanery/cctray'
2
+ require 'vcr'
3
+
4
+ VCR.configure do |c|
5
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
6
+ c.hook_into :fakeweb
7
+ end
8
+
9
+ describe Chicanery::Cctray do
10
+ let(:server) do
11
+ Chicanery::Cctray.new 'chicanery', 'https://api.travis-ci.org/repositories/markryall/chicanery/cc.xml'
12
+ end
13
+
14
+ it 'should detect idle build' do
15
+ VCR.use_cassette('idle') do
16
+ server.jobs.should == {
17
+ "markryall/chicanery" => {
18
+ activity: :sleeping,
19
+ last_build_status: :success,
20
+ last_build_time: 1355537908,
21
+ url: "api.travis-ci.org/markryall/chicanery",
22
+ last_label: "48"
23
+ }
24
+ }
25
+ end
26
+ end
27
+
28
+ it 'should detect running build' do
29
+ VCR.use_cassette('running') do
30
+ server.jobs.should == {
31
+ "markryall/chicanery" => {
32
+ activity: :building,
33
+ last_build_status: :unknown,
34
+ last_build_time: nil,
35
+ url: "api.travis-ci.org/markryall/chicanery",
36
+ last_label: "49"
37
+ }
38
+ }
39
+ end
40
+ end
41
+
42
+ it 'should detect failed build' do
43
+ VCR.use_cassette('broken') do
44
+ server.jobs.should == {
45
+ "markryall/chicanery" => {
46
+ activity: :sleeping,
47
+ last_build_status: :failure,
48
+ last_build_time: 1355539280,
49
+ url: "api.travis-ci.org/markryall/chicanery",
50
+ last_label: "50"
51
+ }
52
+ }
53
+ end
54
+ end
55
+
56
+ it 'should complain if there are no jobs in response' do
57
+ VCR.use_cassette('no_projects') do
58
+ expect{server.jobs}.to raise_error "could not find any jobs in response: [Nothing here but us chickens]"
59
+ end
60
+ end
61
+
62
+ it 'should complain if it gets a non 2xx response' do
63
+ VCR.use_cassette('redirect') do
64
+ expect{server.jobs}.to raise_error Net::HTTPRetriableError
65
+ end
66
+ end
67
+
68
+ end
@@ -1,14 +1,22 @@
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 }
6
+
4
7
  describe '#persist' do
5
8
  it 'should write state to disk as yaml' do
6
- file = stub 'file'
7
- state = stub 'state', to_yaml: :yaml
8
9
  File.should_receive(:open).with('state', 'w').and_yield file
9
10
  file.should_receive(:puts).with :yaml
10
11
  persist state
11
12
  end
13
+
14
+ it 'should persist state to where it is told' do
15
+ persist_state_to 'foo'
16
+ File.should_receive(:open).with('foo', 'w').and_yield file
17
+ file.should_receive(:puts).with :yaml
18
+ persist state
19
+ end
12
20
  end
13
21
 
14
22
  describe '#restore' do
@@ -18,10 +26,16 @@ describe Chicanery::Persistence do
18
26
  end
19
27
 
20
28
  it 'should read yaml from disk' do
21
- state = stub 'state'
22
29
  File.should_receive(:exist?).with('state').and_return true
23
30
  YAML.should_receive(:load_file).with('state').and_return state
24
31
  restore.should == state
25
32
  end
33
+
34
+ it 'should read yaml from another location if it is told to do so' do
35
+ persist_state_to 'foo'
36
+ File.should_receive(:exist?).with('foo').and_return true
37
+ YAML.should_receive(:load_file).with('foo').and_return state
38
+ restore.should == state
39
+ end
26
40
  end
27
41
  end
@@ -4,14 +4,14 @@ describe Chicanery do
4
4
  describe '#execute' do
5
5
  before { %w{load restore persist}.each {|m| stub! m } }
6
6
 
7
+ after { execute ['configuration'] }
8
+
7
9
  it 'should load configuration and exit immediately when nothing is configured no poll period is provided' do
8
10
  should_receive(:load).with 'configuration'
9
- execute %w{configuration}
10
11
  end
11
12
 
12
13
  it 'should restore previous state' do
13
14
  should_receive(:restore)
14
- execute %w{configuration}
15
15
  end
16
16
 
17
17
  it 'should persist new state' do
@@ -19,12 +19,19 @@ describe Chicanery do
19
19
  servers: {},
20
20
  repos: {}
21
21
  })
22
- execute %w{configuration}
23
22
  end
24
23
 
25
24
  it 'should sleep for specified time when poll period is provided' do
26
25
  should_receive(:sleep).with(10).and_raise Interrupt
27
- execute %w{configuration 10}
26
+ poll_period 10
27
+ end
28
+
29
+ it "polls with a specified period" do
30
+ should_receive(:run).exactly(3).times
31
+ should_receive(:sleep).with(10).ordered
32
+ should_receive(:sleep).with(10).ordered
33
+ should_receive(:sleep).with(10).ordered.and_raise Interrupt
34
+ poll_period 10
28
35
  end
29
36
  end
30
37
  end
@@ -1,8 +1,8 @@
1
1
  describe Chicanery do
2
2
  include Chicanery
3
-
3
+
4
4
  describe '#run' do
5
-
5
+
6
6
  before do
7
7
  server double("Server A", :name => "A", :jobs => "A jobs")
8
8
  server double("Server B", :name => "B", :jobs => "B jobs")
@@ -13,37 +13,26 @@ describe Chicanery do
13
13
  end
14
14
  @current_state = nil
15
15
  end
16
-
16
+
17
17
  before { stub!("restore").and_return({})}
18
18
  before { %w{persist}.each {|m| stub! m } }
19
-
19
+
20
20
  it "notifies when_run listeners of the current state of the servers jobs" do
21
- run
21
+ run
22
22
  @current_state[:servers]["A"].should == "A jobs"
23
23
  @current_state[:servers]["B"].should == "B jobs"
24
24
  end
25
-
25
+
26
26
  it "notifies when_run listeners of the current state of the repos" do
27
- run
27
+ run
28
28
  @current_state[:repos]["X"].should == "X state"
29
29
  @current_state[:repos]["Y"].should == "Y state"
30
30
  end
31
-
31
+
32
32
  #TESTS TODO
33
33
  # it restores previous state and records current state
34
34
  # it compares current state and previous state for each server
35
35
  # it compares current state and previous state for each server
36
-
37
- end
38
-
39
- describe '#run_every' do
40
- it "polls with a specified period" do
41
- should_receive(:run).exactly(3).times
42
- should_receive(:sleep).with(10).ordered
43
- should_receive(:sleep).with(10).ordered
44
- should_receive(:sleep).with(10).ordered.and_raise Interrupt
45
- run_every 10
46
- end
36
+
47
37
  end
48
-
49
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.0.7
4
+ version: 0.0.8
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-12-14 00:00:00.000000000 Z
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -91,6 +91,38 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: vcr
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: fakeweb
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
94
126
  description: trigger various events related to a continuous integration environment
95
127
  email:
96
128
  - mark@ryall.name
@@ -109,7 +141,13 @@ files:
109
141
  - bin/chicanery
110
142
  - chicanery.gemspec
111
143
  - examples/baby_steps.rb
144
+ - examples/blinky.rb
112
145
  - examples/chicanery.rb
146
+ - fixtures/vcr_cassettes/broken.yml
147
+ - fixtures/vcr_cassettes/idle.yml
148
+ - fixtures/vcr_cassettes/no_projects.yml
149
+ - fixtures/vcr_cassettes/redirect.yml
150
+ - fixtures/vcr_cassettes/running.yml
113
151
  - lib/chicanery.rb
114
152
  - lib/chicanery/cctray.rb
115
153
  - lib/chicanery/collections.rb
@@ -118,6 +156,7 @@ files:
118
156
  - lib/chicanery/persistence.rb
119
157
  - lib/chicanery/state_comparison.rb
120
158
  - lib/chicanery/summary.rb
159
+ - spec/chicanery/cctray_spec.rb
121
160
  - spec/chicanery/collections_spec.rb
122
161
  - spec/chicanery/persistence_spec.rb
123
162
  - spec/chicanery/state_comparison_spec.rb
@@ -138,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
177
  version: '0'
139
178
  segments:
140
179
  - 0
141
- hash: 3593176938821015770
180
+ hash: 3689538563081558467
142
181
  required_rubygems_version: !ruby/object:Gem::Requirement
143
182
  none: false
144
183
  requirements:
@@ -147,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
186
  version: '0'
148
187
  segments:
149
188
  - 0
150
- hash: 3593176938821015770
189
+ hash: 3689538563081558467
151
190
  requirements: []
152
191
  rubyforge_project:
153
192
  rubygems_version: 1.8.23
@@ -155,6 +194,7 @@ signing_key:
155
194
  specification_version: 3
156
195
  summary: polls various resources related to a ci environment and performs custom notifications
157
196
  test_files:
197
+ - spec/chicanery/cctray_spec.rb
158
198
  - spec/chicanery/collections_spec.rb
159
199
  - spec/chicanery/persistence_spec.rb
160
200
  - spec/chicanery/state_comparison_spec.rb