borg-rb 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,34 +2,48 @@ require 'spec_helper'
2
2
  require 'borg/configuration/assimilator'
3
3
 
4
4
  describe Borg::Configuration::Assimilator do
5
- it "should be included into Capistrano::Configuration" do
6
- Capistrano::Configuration.new.should respond_to :assimilate
5
+ before :all do
6
+ class MockConfiguration < Capistrano::Configuration
7
+ include Borg::Configuration::Assimilator
8
+ end
7
9
  end
8
10
 
9
- context "when #assimilate('borg-rb') is called" do
10
- subject { Capistrano::Configuration.new }
11
- it "should add to the to_assimilate list" do
12
- lambda {subject.assimilate('borg-rb')}.should change {subject.instance_eval("@to_assimilate")}.from(nil).to({'borg-rb' => Gem::Specification.find_by_name('borg-rb').gem_dir})
13
- end
11
+ after :all do
12
+ Object.send(:remove_const, :MockConfiguration)
14
13
  end
15
14
 
16
- context "when #assimilate! is called" do
17
- before do
18
- @config = Capistrano::Configuration.new
19
- @config.assimilate('borg-rb')
15
+ before do
16
+ @config = MockConfiguration.new
17
+ end
18
+ describe '#assimilate' do
19
+ it 'adds to the to_assimilate array' do
20
+ expect {
21
+ @config.assimilate('borg-rb')
22
+ }.to change {
23
+ @config.instance_eval('@to_assimilate')
24
+ }.from(nil).to({'borg-rb' => Gem::Specification.find_by_name('borg-rb').gem_dir})
20
25
  end
26
+ end
21
27
 
22
- subject { @config }
23
- it "should loads all the initializers" do
24
- Dir["cap/initializers/**/*.rb"].each do |file|
25
- subject.should_receive(:load).with(File.expand_path(file))
28
+ describe '#assimilate!' do
29
+ context 'given we already called assimilate with: `borg-rb`' do
30
+ before do
31
+ @config.assimilate('borg-rb')
32
+ end
33
+
34
+ it 'loads all the initializers' do
35
+ Dir['cap/initializers/**/*.rb'].each do |file|
36
+ @config.should_receive(:load).with(File.expand_path(file))
37
+ end
38
+ @config.assimilate!
26
39
  end
27
- subject.assimilate!
28
- end
29
40
 
30
- it "should add the cap directory to teh load path" do
31
- Dir.stub("[]").and_return([])
32
- lambda { subject.assimilate! }.should change(subject.load_paths, :count).by 1
41
+ it 'adds the cap directory to the load path' do
42
+ Dir.stub('[]').and_return([])
43
+ expect {
44
+ @config.assimilate!
45
+ }.to change(@config.load_paths, :count).by 1
46
+ end
33
47
  end
34
48
  end
35
49
  end
@@ -3,68 +3,65 @@ require 'borg/configuration/applications'
3
3
  require 'borg/configuration/stages'
4
4
 
5
5
  describe Borg::Configuration::Stages do
6
- it "should be included into Capistrano::Configuration" do
7
- Capistrano::Configuration.ancestors.should include Borg::Configuration::Stages
6
+ before :all do
7
+ class MockConfiguration < Capistrano::Configuration
8
+ # TODO: Stages has a dependency on Applications module, is that bad?
9
+ include Borg::Configuration::Applications
10
+ include Borg::Configuration::Stages
11
+ end
12
+ end
13
+
14
+ after :all do
15
+ Object.send(:remove_const, :MockConfiguration)
8
16
  end
9
17
 
10
- context "when an applications is defined" do
18
+ let(:config) { MockConfiguration.new }
19
+
20
+ context 'when an application with a stage is defined' do
11
21
  before do
12
- @config = Capistrano::Configuration.new
13
- @config.load do
14
- stage "app1", "stg1" do
15
- test_notice "You have called app1 stg1"
22
+ config.load do
23
+ stage 'app1', 'stg1' do
24
+ test_notice 'You have called app1 stg1'
16
25
  end
17
26
  end
18
27
  end
19
- subject { @config }
20
28
 
21
- it "should create application since it does not exist" do
22
- expect(subject.applications[:app1]).to be_true
23
- end
24
-
25
- it "should symobolize the name" do
26
- expect(subject.applications[:app1].stages.keys.first).to eq :stg1
27
- end
28
-
29
- it "should create a namespace app1 with task stg1 and a description" do
30
- expect(subject.namespaces[:app1]).to be_true
31
- expect(subject.namespaces[:app1].tasks[:stg1]).to be_true
32
- expect(subject.namespaces[:app1].tasks[:stg1].desc).to be_true
33
- end
29
+ it_behaves_like 'an application configuration'
34
30
 
35
- it "should add it to applications hash and have a block" do
36
- expect(subject.applications[:app1].stages[:stg1].class).to eq Borg::Configuration::Stages::Stage
37
- expect(subject.applications[:app1].stages[:stg1].execution_blocks.count).to eq 1
31
+ it 'creates and stores a new Stage object with a name and execution block' do
32
+ expect(config.applications[:app1].stages[:stg1].class).to eq Borg::Configuration::Stages::Stage
33
+ expect(config.applications[:app1].stages[:stg1].name).to eq 'app1:stg1'
34
+ expect(config.applications[:app1].stages[:stg1].execution_blocks.count).to eq 1
38
35
  end
39
36
  end
40
37
  end
41
38
 
42
39
  describe Borg::Configuration::Stages::Stage do
43
- it "should be initialize all variables" do
44
- parent = double "app1"
45
- parent.stub(:name).and_return :app1
40
+ it 'initializes: name, parent and execution_blocks' do
41
+ parent = double('app1')
42
+ parent.stub(:name).and_return(:app1)
46
43
  stg1 = Borg::Configuration::Stages::Stage.new(:stg1, parent)
47
- expect(stg1.name).to eq("app1:stg1")
44
+ expect(stg1.name).to eq('app1:stg1')
48
45
  expect(stg1.parent).to eq(parent)
49
46
  expect(stg1.execution_blocks).to eq([])
50
47
  end
51
48
 
52
- context "a stage with 2 blocks" do
49
+ context 'a stage with 2 blocks' do
53
50
  before do
54
- @stg1 = Borg::Configuration::Stages::Stage.new(:stg1, double("app1"))
51
+ @stg1 = Borg::Configuration::Stages::Stage.new(:stg1, double('app1'))
55
52
  @stg1.execution_blocks << -> {
56
- raise "block 1 called"
53
+ raise 'block 1 called'
57
54
  }
58
55
  @stg1.execution_blocks << -> {
59
- raise "block 2 called"
56
+ raise 'block 2 called'
60
57
  }
61
58
  end
62
- context "when #load_into is called" do
63
- it "should all blocks into the provided config" do
64
- config = double("test config")
59
+ context 'when #load_into is called' do
60
+ it 'should all blocks into the provided config' do
61
+ config = double('test config')
65
62
  @stg1.parent.should_receive(:load_into).with(config)
66
63
  config.should_receive(:load).twice
67
- @stg1.load_into config
64
+ @stg1.load_into(config)
68
65
  end
69
66
  end
70
67
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'borg/configuration'
3
+
4
+ describe Borg::Configuration do
5
+ it 'includes Applications, Assimilator, Stages, and UpstartTasks' do
6
+ expect(
7
+ Borg::Configuration.ancestors
8
+ ).to include(Borg::Configuration::Applications,
9
+ Borg::Configuration::Assimilator,
10
+ Borg::Configuration::Stages)
11
+
12
+ end
13
+
14
+ describe '#_cset' do
15
+ it 'does something' do
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ shared_examples 'an application configuration' do
2
+ context 'upon loading' do
3
+ it 'creates and stores a new Application object with a name and execution block' do
4
+ expect(config.applications[:app1].class).to eq Borg::Configuration::Applications::Application
5
+ expect(config.applications[:app1].name).to eq :app1
6
+ end
7
+
8
+ it 'creates a new namespace value with a default task/description' do
9
+ expect(config.namespaces[:app1]).to be_true
10
+ expect(config.namespaces[:app1].tasks[:default]).to be_true
11
+ expect(config.namespaces[:app1].tasks[:default].desc).to be_true
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: borg-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Identified
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-27 00:00:00.000000000 Z
11
+ date: 2013-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -113,14 +113,15 @@ files:
113
113
  - bin/borg
114
114
  - bin/borgify
115
115
  - borg.gemspec
116
- - cap/applications/app1.rb
117
- - cap/initializers/output.rb
118
116
  - cap/initializers/performance.rb
119
117
  - cap/initializers/role_reset.rb
120
118
  - cap/initializers/sigint.rb
121
119
  - lib/borg-rb.rb
120
+ - lib/borg.rb
121
+ - lib/borg/cli.rb
122
122
  - lib/borg/cli/applications.rb
123
123
  - lib/borg/cli/assimilator.rb
124
+ - lib/borg/configuration.rb
124
125
  - lib/borg/configuration/applications.rb
125
126
  - lib/borg/configuration/assimilator.rb
126
127
  - lib/borg/configuration/stages.rb
@@ -140,14 +141,17 @@ files:
140
141
  - spec/acceptance/borgify_spec.rb
141
142
  - spec/acceptance/stage_spec.rb
142
143
  - spec/lib/borg/cli/applications_spec.rb
144
+ - spec/lib/borg/cli_spec.rb
143
145
  - spec/lib/borg/configuration/applications_spec.rb
144
146
  - spec/lib/borg/configuration/assimilator_spec.rb
145
147
  - spec/lib/borg/configuration/stages_spec.rb
148
+ - spec/lib/borg/configuration_spec.rb
146
149
  - spec/spec_helper.rb
147
150
  - spec/support/isolated_environment.rb
148
151
  - spec/support/matchers/succeed.rb
149
152
  - spec/support/platform.rb
150
153
  - spec/support/shared_contexts/acceptance.rb
154
+ - spec/support/shared_examples/application_configuration.rb
151
155
  - spec/support/subprocess.rb
152
156
  - spec/support/temp_dir.rb
153
157
  homepage: https://github.com/B0RG/borg
@@ -162,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
166
  requirements:
163
167
  - - ! '>='
164
168
  - !ruby/object:Gem::Version
165
- version: '0'
169
+ version: 1.9.2
166
170
  required_rubygems_version: !ruby/object:Gem::Requirement
167
171
  requirements:
168
172
  - - ! '>='
@@ -180,14 +184,17 @@ test_files:
180
184
  - spec/acceptance/borgify_spec.rb
181
185
  - spec/acceptance/stage_spec.rb
182
186
  - spec/lib/borg/cli/applications_spec.rb
187
+ - spec/lib/borg/cli_spec.rb
183
188
  - spec/lib/borg/configuration/applications_spec.rb
184
189
  - spec/lib/borg/configuration/assimilator_spec.rb
185
190
  - spec/lib/borg/configuration/stages_spec.rb
191
+ - spec/lib/borg/configuration_spec.rb
186
192
  - spec/spec_helper.rb
187
193
  - spec/support/isolated_environment.rb
188
194
  - spec/support/matchers/succeed.rb
189
195
  - spec/support/platform.rb
190
196
  - spec/support/shared_contexts/acceptance.rb
197
+ - spec/support/shared_examples/application_configuration.rb
191
198
  - spec/support/subprocess.rb
192
199
  - spec/support/temp_dir.rb
193
200
  has_rdoc:
@@ -1,15 +0,0 @@
1
- application :app1 do
2
- puts "application = app1"
3
- end
4
-
5
- stage :app1, :prd do
6
- puts "stage = prd"
7
- end
8
-
9
- stage :app1, :stg do
10
- puts "stage = stg"
11
- end
12
-
13
- stage :app1, :alf do
14
- puts "stage = alf"
15
- end
@@ -1,4 +0,0 @@
1
- # Colors
2
- require 'colored'
3
- require 'term/ansicolor'
4
- require 'capistrano_colors'