mulder 0.3.2 → 0.4.0

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: c74bd78ed1a5b5cf346c11d3c2e40c96b3415139
4
- data.tar.gz: 86b32162edd9de13059ffbc0f52d67bf59f65447
3
+ metadata.gz: 6a53034a0cb8244e38367c1cc27b3eb0f17e6716
4
+ data.tar.gz: b88ceb563a7839f4ea91542fc4a90a1f99c19438
5
5
  SHA512:
6
- metadata.gz: 70ee6aaaebc866db3d6f7a148b8a9b3d515e5749c5ea18974573255687f3097cacd65dfe997b73c5da799362074fcc331eb5daf2e14913b0e88c213db8df2df7
7
- data.tar.gz: af7678ac094b8256d5be5e57dc3e47aeeb19b0ab7c084450578f790f292f1b13e03a89bfdfcf332b33fcbeba4e7c564d149c868b33eabc62d689e51a579e2f1c
6
+ metadata.gz: 62cde3c1e60be2a0841a6c81ab35fda37d72402fd00b5b13bc294d6408b28b7181736a87440a666e4d5a9820a6d8e714c91166760d95251f983f143a2da72fdf
7
+ data.tar.gz: 66adbf8dba59c6a7de266643055da51556f1ceff84dc82d7eead75d6f038c1afdcc63c45adf691d5ba6253f5a94f9c9fbc2bb4557ef0c1b7d63600a59a3814e7
@@ -15,7 +15,7 @@ module Mulder
15
15
  end
16
16
 
17
17
  def instances
18
- @connection.instances_by_group(group)
18
+ @connection.instances_by_group(group).select(&:exists?)
19
19
  end
20
20
 
21
21
  def id_regexp
@@ -37,6 +37,10 @@ module Mulder
37
37
  @fog_compute_instance.created_at
38
38
  end
39
39
 
40
+ def exists?
41
+ !@fog_compute_instance.nil?
42
+ end
43
+
40
44
  def as_hash
41
45
  @as_hash ||= {
42
46
  id: id,
@@ -49,4 +53,4 @@ module Mulder
49
53
  }.delete_if { |_, value| value == '' || value == nil }
50
54
  end
51
55
  end
52
- end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module Mulder
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -25,10 +25,36 @@ describe Mulder::Client do
25
25
  end
26
26
 
27
27
  describe '#instances' do
28
+ let(:mocked_connection) { mock }
29
+ let(:mocked_group) { mock }
30
+ let(:client) { described_class.new(mocked_connection, 'foo', 'bar', 'worker') }
31
+ let(:instances) { [] }
32
+
33
+ before do
34
+ mocked_connection.stubs(:instances_by_group).with(mocked_group).returns(instances)
35
+ client.stubs(:group).returns(mocked_group)
36
+ end
37
+
38
+ context 'when there are no unhealthy instances' do
39
+ let(:instances) {[mock('healthy instance', exists?: true), mock('healthy instance', exists?: true)]}
40
+
41
+ it 'returns all instances' do
42
+ client.instances.size.should == 2
43
+ end
44
+ end
45
+
46
+ context 'when there are unhealthy instances' do
47
+ let(:instances) { [mock('healthy instance', exists?: true), mock('unhealthy instance', exists?: false)] }
48
+
49
+ it 'returns only the healthy ones' do
50
+ client.instances.size.should == 1
51
+ end
52
+ end
53
+
28
54
  it 'finds the instances for the group' do
29
55
  mocked_connection = mock
30
56
  mocked_group = mock
31
- mocked_connection.expects(:instances_by_group).with(mocked_group)
57
+ mocked_connection.expects(:instances_by_group).with(mocked_group).returns([])
32
58
  client = described_class.new(mocked_connection, 'foo', 'bar', 'worker')
33
59
  client.expects(:group).returns(mocked_group)
34
60
 
@@ -72,4 +98,4 @@ describe Mulder::Client do
72
98
  end
73
99
  end
74
100
 
75
- end
101
+ end
@@ -11,6 +11,21 @@ describe Mulder::Instance do
11
11
  end
12
12
  end
13
13
 
14
+ describe '#exists?' do
15
+ context 'when there is a compute instance' do
16
+ it 'returns true' do
17
+ fog_compute_instance = mock
18
+ described_class.new(fog_compute_instance).should exist
19
+ end
20
+ end
21
+
22
+ context 'when there no compute instance' do
23
+ it 'returns false' do
24
+ described_class.new(nil).should_not exist
25
+ end
26
+ end
27
+ end
28
+
14
29
  describe '#as_hash' do
15
30
  let(:instance) { mock(attributes) }
16
31
 
@@ -31,4 +46,4 @@ describe Mulder::Instance do
31
46
  end
32
47
  end
33
48
 
34
- end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mulder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Grazier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler