vx-builder 0.1.8 → 0.2.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/lib/vx/builder/build_configuration.rb +9 -6
  4. data/lib/vx/builder/build_configuration/deploy.rb +22 -13
  5. data/lib/vx/builder/build_configuration/deploy/provider.rb +58 -0
  6. data/lib/vx/builder/configuration.rb +1 -1
  7. data/lib/vx/builder/matrix.rb +14 -0
  8. data/lib/vx/builder/script.rb +32 -7
  9. data/lib/vx/builder/script/artifacts.rb +1 -3
  10. data/lib/vx/builder/script/base.rb +56 -0
  11. data/lib/vx/builder/script/clojure.rb +5 -9
  12. data/lib/vx/builder/script/deploy.rb +40 -0
  13. data/lib/vx/builder/script/env.rb +1 -3
  14. data/lib/vx/builder/script/java.rb +5 -5
  15. data/lib/vx/builder/script/ruby.rb +20 -15
  16. data/lib/vx/builder/script/scala.rb +11 -13
  17. data/lib/vx/builder/script/script.rb +19 -8
  18. data/lib/vx/builder/script/services.rb +1 -3
  19. data/lib/vx/builder/task.rb +5 -0
  20. data/lib/vx/builder/version.rb +1 -1
  21. data/spec/fixtures/integration/ruby/deploy/config.yml +12 -0
  22. data/spec/fixtures/integration/ruby/deploy/d.after_script.sh +10 -0
  23. data/spec/fixtures/integration/ruby/deploy/d.before_script.sh +61 -0
  24. data/spec/fixtures/integration/ruby/deploy/d.script.sh +4 -0
  25. data/spec/fixtures/integration/ruby/language/after_script.sh +10 -0
  26. data/spec/fixtures/integration/ruby/language/before_script.sh +59 -0
  27. data/spec/fixtures/integration/ruby/language/config.yml +1 -0
  28. data/spec/fixtures/integration/ruby/language/script.sh +8 -0
  29. data/spec/fixtures/integration/ruby/matrix/0.after_script.sh +10 -0
  30. data/spec/fixtures/integration/ruby/matrix/0.before_script.sh +61 -0
  31. data/spec/fixtures/integration/ruby/matrix/0.script.sh +6 -0
  32. data/spec/fixtures/integration/ruby/matrix/1.after_script.sh +10 -0
  33. data/spec/fixtures/integration/ruby/matrix/1.before_script.sh +61 -0
  34. data/spec/fixtures/integration/ruby/matrix/1.script.sh +6 -0
  35. data/spec/fixtures/integration/ruby/matrix/config.yml +11 -0
  36. data/spec/fixtures/integration/ruby/matrix/d.after_script.sh +10 -0
  37. data/spec/fixtures/integration/ruby/matrix/d.before_script.sh +59 -0
  38. data/spec/fixtures/integration/ruby/matrix/d.script.sh +4 -0
  39. data/spec/fixtures/travis.yml +3 -0
  40. data/spec/integration/ruby_spec.rb +159 -0
  41. data/spec/lib/builder/build_configuration_spec.rb +31 -0
  42. data/spec/lib/builder/matrix_spec.rb +59 -0
  43. data/spec/lib/builder/task_spec.rb +2 -1
  44. data/spec/support/create.rb +14 -11
  45. data/vx-builder.gemspec +1 -1
  46. metadata +48 -7
@@ -0,0 +1,6 @@
1
+
2
+ # script
3
+ echo \$\ rake
4
+ rake
5
+
6
+ # after success
@@ -0,0 +1,10 @@
1
+
2
+ # after script init
3
+ export CI_JOB_ID=1
4
+ export CI_BUILD_ID=12
5
+ export CI_BRANCH=master
6
+ export VX_ROOT=$(pwd)
7
+ cd ${VX_ROOT}/code/name
8
+
9
+ # after script
10
+ test -f $HOME/.casher/bin/casher && /opt/rbenv/versions/1.9.3-p547/bin/ruby $HOME/.casher/bin/casher push http://example.com/master/rvm-2.0.0-gemfile.tgz
@@ -0,0 +1,61 @@
1
+
2
+ # init
3
+ set -e
4
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5
+ export LC_ALL=en_US.UTF8
6
+ export DEBIAN_FRONTEND=noninteractive
7
+ export CI_JOB_ID=1
8
+ export CI_BUILD_ID=12
9
+ export CI_BRANCH=master
10
+ export VX_ROOT=$(pwd)
11
+ mkdir -p ${VX_ROOT}/data/name
12
+ mkdir -p ${VX_ROOT}/code/name
13
+ (echo LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSU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UTd4VDFZL250WE5wM3BkYlljNDdOVVE9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= | base64 --decode) > ${VX_ROOT}/data/name/key
14
+ chmod 0600 ${VX_ROOT}/data/name/key
15
+ export VX_PRIVATE_KEY=${VX_ROOT}/data/name/key
16
+ (echo IyEvYmluL3NoCi91c3IvYmluL3NzaCAtQSAtbyBMb2dMZXZlbD1xdWlldCAtbyBTdHJpY3RIb3N0S2V5Q2hlY2tpbmc9bm8gLW8gVXNlcktub3duSG9zdHNGaWxlPS9kZXYvbnVsbCAtaSAke1ZYX1JPT1R9L2RhdGEvbmFtZS9rZXkgJEAK | base64 --decode) > ${VX_ROOT}/data/name/git_ssh
17
+ chmod 0750 ${VX_ROOT}/data/name/git_ssh
18
+ export GIT_SSH=${VX_ROOT}/data/name/git_ssh
19
+ echo "$ git clone --depth=50 --branch=master git@github.com:dima-exe/ci-worker-test-repo.git ${VX_ROOT}/code/name"
20
+ git clone --depth=50 --branch=master git@github.com:dima-exe/ci-worker-test-repo.git ${VX_ROOT}/code/name
21
+ echo "$ git checkout -qf b665f90239563c030f1b280a434b3d84daeda1bd"
22
+ ( cd ${VX_ROOT}/code/name && git checkout -qf b665f90239563c030f1b280a434b3d84daeda1bd )
23
+ unset GIT_SSH
24
+ echo "Starting SSH Agent"
25
+ eval "$(ssh-agent)"
26
+ ssh-add $VX_PRIVATE_KEY
27
+ cd ${VX_ROOT}/code/name
28
+ export CASHER_DIR=$HOME/.casher && ( mkdir -p $CASHER_DIR/bin && /usr/bin/curl https://raw2.github.com/dima-exe/casher/master/bin/casher -s -o $HOME/.casher/bin/casher && chmod +x $HOME/.casher/bin/casher ) || true
29
+ test -f $HOME/.casher/bin/casher && /opt/rbenv/versions/1.9.3-p547/bin/ruby $HOME/.casher/bin/casher fetch http://example.com/master/rvm-2.0.0-gemfile.tgz || true
30
+ test -f $HOME/.casher/bin/casher && /opt/rbenv/versions/1.9.3-p547/bin/ruby $HOME/.casher/bin/casher add ~/.rubygems || true
31
+ unset CASHER_DIR
32
+
33
+ # before install
34
+ eval "$(rbenv init -)" || true
35
+ rbenv shell $(rbenv versions | sed -e 's/^*/ /' | awk '{print $1}' | grep -v 'system' | grep '2.0.0' | tail -n1)
36
+ echo \$\ export\ BUNDLE_GEMFILE\=\$\{PWD\}/Gemfile
37
+ export BUNDLE_GEMFILE=${PWD}/Gemfile
38
+ echo \$\ export\ GEM_HOME\=\~/.rubygems
39
+ export GEM_HOME=~/.rubygems
40
+
41
+ # announce
42
+ echo \$\ ruby\ --version
43
+ ruby --version
44
+ echo \$\ gem\ --version
45
+ gem --version
46
+ echo \$\ bundle\ --version
47
+ bundle --version
48
+
49
+ # install
50
+ echo \$\ bundle\ install\
51
+ bundle install
52
+ echo \$\ bundle\ clean\ --force
53
+ bundle clean --force
54
+ echo \$\ bundle\ install
55
+ bundle install
56
+ echo \$\ bundle\ clean\ --force
57
+ bundle clean --force
58
+
59
+ # before script
60
+ echo \$\ echo\ before\ script
61
+ echo before script
@@ -0,0 +1,6 @@
1
+
2
+ # script
3
+ echo \$\ rake
4
+ rake
5
+
6
+ # after success
@@ -0,0 +1,11 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+
5
+ before_script: echo before script
6
+
7
+ script: rake
8
+
9
+ after_script: echo after script
10
+
11
+ deploy: cap staging deploy
@@ -0,0 +1,10 @@
1
+
2
+ # after script init
3
+ export CI_JOB_ID=1
4
+ export CI_BUILD_ID=12
5
+ export CI_BRANCH=master
6
+ export VX_ROOT=$(pwd)
7
+ cd ${VX_ROOT}/code/name
8
+
9
+ # after deploy
10
+ test -f $HOME/.casher/bin/casher && /opt/rbenv/versions/1.9.3-p547/bin/ruby $HOME/.casher/bin/casher push http://example.com/master/rvm-1.9.3-gemfile.tgz
@@ -0,0 +1,59 @@
1
+
2
+ # init
3
+ set -e
4
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5
+ export LC_ALL=en_US.UTF8
6
+ export DEBIAN_FRONTEND=noninteractive
7
+ export CI_JOB_ID=1
8
+ export CI_BUILD_ID=12
9
+ export CI_BRANCH=master
10
+ export VX_ROOT=$(pwd)
11
+ mkdir -p ${VX_ROOT}/data/name
12
+ mkdir -p ${VX_ROOT}/code/name
13
+ (echo LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcEFJQkFBS0NBUUVBdmVpcXpyMG54SkE0OGZrL1Q3cUZyT0RtZFQ5NGx2dDdvbnRHTGhxTlQ3WitHYnFMCnQ0NUY0LzVCeE5neU1iU1FmYUp3MXNHTXVuUWZqS1JkV2Z1S1VRcDB5NmJOaEFqdG5Dbm9WZWwzU01CYVhFMnIKODk2R2toTlhjMS9sejF2LzFUOGJsYy9jaFZlS1p2UVQraER2Qy9LRUNGLyt2ZDd5TDZOUmxvYXlaZHYwa3M3egpDd29JZWVUZkV1MmhkM3JYREVMZ29pTStBQUVjaVllMDhWdXl0RmpiT055MjhFeTNTR0hVUk40MThGSnJKSERzCjdCNXgzUDg5Z2xrU3RhMVRZNEpPUXRvV3V4emE3eWxTOEcxaytzcytUREIrRVQzc3FqRGUxbXhvc1JBZnFTQTcKYXBFWkszQUxiWnJ1M25ZZDI2eCtDRTg0ZHZIN0dpS29CbDBUU1FJREFRQUJBb0lCQUVFQWduYUJDRHVmb2Q0eApFaHFZSFdrdkViTFFKdGFHL2FwL3gyWEFjTjMzK1BHVmlIMHJsWUNVWnE2WjBaUngyWU1uTnJoTFI0QUtmMElFCmdHOXNTY3V6YUliTWNVdmdRblJSWTlVRU5IQVNadHR4T29vZWdMRS9MWSt3STFqMmhIclpQdmZvVGZMV0krbFoKWWYwV0RyeG9KZ2szMGxuckZicDRqRlNaaGphV21zbTFYUTRodHQ5YmZHT0JsZS9nSjZVVHIzMndGMEV5T3B2NAplcmNpMVJTVXp5RFd6MHE3VGphcTZTSGx3UTJKd2NMRzB2bnJacStZbk1KVXdqTGhDNEpBTVpFS0Y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ranpVCmEyUGlwd0tCZ1FDQ0x1T3JoTzM3VW92TW5tTnJSelhud3U5QytWQ0I0b0dmNlF0akVlaE14L0orNmVodlNZdWIKbExPeGVaUUh6VmtDM0k2clZNYksxcXgwdDhRbmIrNWpIUkFrUjR4L0phVG9qcFpZcW5nZExydFk0L3FMS0pxNwo0YU9MWWpKeUwzWUIwOWczcjY4d2NuVFVIYmNaWWorUTd4VDFZL250WE5wM3BkYlljNDdOVVE9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= | base64 --decode) > ${VX_ROOT}/data/name/key
14
+ chmod 0600 ${VX_ROOT}/data/name/key
15
+ export VX_PRIVATE_KEY=${VX_ROOT}/data/name/key
16
+ (echo IyEvYmluL3NoCi91c3IvYmluL3NzaCAtQSAtbyBMb2dMZXZlbD1xdWlldCAtbyBTdHJpY3RIb3N0S2V5Q2hlY2tpbmc9bm8gLW8gVXNlcktub3duSG9zdHNGaWxlPS9kZXYvbnVsbCAtaSAke1ZYX1JPT1R9L2RhdGEvbmFtZS9rZXkgJEAK | base64 --decode) > ${VX_ROOT}/data/name/git_ssh
17
+ chmod 0750 ${VX_ROOT}/data/name/git_ssh
18
+ export GIT_SSH=${VX_ROOT}/data/name/git_ssh
19
+ echo "$ git clone --depth=50 --branch=master git@github.com:dima-exe/ci-worker-test-repo.git ${VX_ROOT}/code/name"
20
+ git clone --depth=50 --branch=master git@github.com:dima-exe/ci-worker-test-repo.git ${VX_ROOT}/code/name
21
+ echo "$ git checkout -qf b665f90239563c030f1b280a434b3d84daeda1bd"
22
+ ( cd ${VX_ROOT}/code/name && git checkout -qf b665f90239563c030f1b280a434b3d84daeda1bd )
23
+ unset GIT_SSH
24
+ echo "Starting SSH Agent"
25
+ eval "$(ssh-agent)"
26
+ ssh-add $VX_PRIVATE_KEY
27
+ cd ${VX_ROOT}/code/name
28
+ export CASHER_DIR=$HOME/.casher && ( mkdir -p $CASHER_DIR/bin && /usr/bin/curl https://raw2.github.com/dima-exe/casher/master/bin/casher -s -o $HOME/.casher/bin/casher && chmod +x $HOME/.casher/bin/casher ) || true
29
+ test -f $HOME/.casher/bin/casher && /opt/rbenv/versions/1.9.3-p547/bin/ruby $HOME/.casher/bin/casher fetch http://example.com/master/rvm-1.9.3-gemfile.tgz || true
30
+ test -f $HOME/.casher/bin/casher && /opt/rbenv/versions/1.9.3-p547/bin/ruby $HOME/.casher/bin/casher add ~/.rubygems || true
31
+ unset CASHER_DIR
32
+
33
+ # before install
34
+ eval "$(rbenv init -)" || true
35
+ rbenv shell $(rbenv versions | sed -e 's/^*/ /' | awk '{print $1}' | grep -v 'system' | grep '1.9.3' | tail -n1)
36
+ echo \$\ export\ BUNDLE_GEMFILE\=\$\{PWD\}/Gemfile
37
+ export BUNDLE_GEMFILE=${PWD}/Gemfile
38
+ echo \$\ export\ GEM_HOME\=\~/.rubygems
39
+ export GEM_HOME=~/.rubygems
40
+
41
+ # announce
42
+ echo \$\ ruby\ --version
43
+ ruby --version
44
+ echo \$\ gem\ --version
45
+ gem --version
46
+ echo \$\ bundle\ --version
47
+ bundle --version
48
+
49
+ # install
50
+ echo \$\ bundle\ install\
51
+ bundle install
52
+ echo \$\ bundle\ clean\ --force
53
+ bundle clean --force
54
+ echo \$\ bundle\ install
55
+ bundle install
56
+ echo \$\ bundle\ clean\ --force
57
+ bundle clean --force
58
+
59
+ # before deploy
@@ -0,0 +1,4 @@
1
+
2
+ # deploy
3
+ echo \$\ cap\ staging\ deploy
4
+ cap staging deploy
@@ -38,4 +38,7 @@ artifacts:
38
38
 
39
39
  deploy: "cap deploy production"
40
40
 
41
+ after_deploy: echo after deploy
42
+ before_deploy: echo before deploy
43
+
41
44
  bundler_args: --without development
@@ -0,0 +1,159 @@
1
+ require 'spec_helper'
2
+
3
+ describe "(integration) ruby" do
4
+ let(:build_configuration) {
5
+ Vx::Builder::BuildConfiguration.from_yaml(config)
6
+ }
7
+ let(:matrix) { Vx::Builder::Matrix.new build_configuration }
8
+ let(:task) { create :task }
9
+ let(:script) { Vx::Builder::Script.new(task, source) }
10
+ subject { matrix }
11
+
12
+ context "language" do
13
+ let(:config) { fixture("integration/ruby/language/config.yml") }
14
+
15
+ its(:build_configurations) { should have(1).item }
16
+
17
+ context "first configuration" do
18
+ let(:source) { matrix.build_configurations.first }
19
+ subject { script }
20
+
21
+
22
+ before do
23
+ =begin
24
+ File.open(fixture_path("integration/ruby/language/before_script.sh"), 'w') do |io|
25
+ io << script.to_before_script
26
+ end
27
+ File.open(fixture_path("integration/ruby/language/after_script.sh"), 'w') do |io|
28
+ io << script.to_after_script
29
+ end
30
+ File.open(fixture_path("integration/ruby/language/script.sh"), 'w') do |io|
31
+ io << script.to_script
32
+ end
33
+ =end
34
+ end
35
+
36
+ it { should_not be_deploy }
37
+ its(:to_before_script) { should eq fixture("integration/ruby/language/before_script.sh") }
38
+ its(:to_script) { should eq fixture("integration/ruby/language/script.sh") }
39
+ its(:to_after_script) { should eq fixture("integration/ruby/language/after_script.sh") }
40
+ end
41
+ end
42
+
43
+ context "deploy" do
44
+ let(:config) { fixture("integration/ruby/deploy/config.yml") }
45
+
46
+ context "configuration" do
47
+ let(:task) { create :task, deploy: true }
48
+ let(:source) { matrix.deploy_configuration("master") }
49
+ subject { script }
50
+
51
+ before do
52
+ =begin
53
+ File.open(fixture_path("integration/ruby/deploy/d.before_script.sh"), 'w') do |io|
54
+ io << script.to_before_script
55
+ end
56
+ File.open(fixture_path("integration/ruby/deploy/d.after_script.sh"), 'w') do |io|
57
+ io << script.to_after_script
58
+ end
59
+ File.open(fixture_path("integration/ruby/deploy/d.script.sh"), 'w') do |io|
60
+ io << script.to_script
61
+ end
62
+ =end
63
+ end
64
+
65
+ it "should have source" do
66
+ expect(source).to be
67
+ end
68
+
69
+ it { should be_deploy }
70
+ its(:to_before_script) { should eq fixture("integration/ruby/deploy/d.before_script.sh") }
71
+ its(:to_script) { should eq fixture("integration/ruby/deploy/d.script.sh") }
72
+ its(:to_after_script) { should eq fixture("integration/ruby/deploy/d.after_script.sh") }
73
+ end
74
+ end
75
+
76
+ context "matrix" do
77
+ let(:config) { fixture("integration/ruby/matrix/config.yml") }
78
+
79
+ its(:build_configurations) { should have(2).item }
80
+
81
+ context "0th configuration" do
82
+ let(:source) { matrix.build_configurations[0] }
83
+ subject { script }
84
+
85
+ before do
86
+ =begin
87
+ File.open(fixture_path("integration/ruby/matrix/0.before_script.sh"), 'w') do |io|
88
+ io << script.to_before_script
89
+ end
90
+ File.open(fixture_path("integration/ruby/matrix/0.after_script.sh"), 'w') do |io|
91
+ io << script.to_after_script
92
+ end
93
+ File.open(fixture_path("integration/ruby/matrix/0.script.sh"), 'w') do |io|
94
+ io << script.to_script
95
+ end
96
+ =end
97
+ end
98
+
99
+ it { should_not be_deploy }
100
+ its(:to_before_script) { should eq fixture("integration/ruby/matrix/0.before_script.sh") }
101
+ its(:to_script) { should eq fixture("integration/ruby/matrix/0.script.sh") }
102
+ its(:to_after_script) { should eq fixture("integration/ruby/matrix/0.after_script.sh") }
103
+ end
104
+
105
+ context "1th configuration" do
106
+ let(:source) { matrix.build_configurations[1] }
107
+ subject { script }
108
+
109
+ before do
110
+ =begin
111
+ File.open(fixture_path("integration/ruby/matrix/1.before_script.sh"), 'w') do |io|
112
+ io << script.to_before_script
113
+ end
114
+ File.open(fixture_path("integration/ruby/matrix/1.after_script.sh"), 'w') do |io|
115
+ io << script.to_after_script
116
+ end
117
+ File.open(fixture_path("integration/ruby/matrix/1.script.sh"), 'w') do |io|
118
+ io << script.to_script
119
+ end
120
+ =end
121
+ end
122
+
123
+ it { should_not be_deploy }
124
+ its(:to_before_script) { should eq fixture("integration/ruby/matrix/1.before_script.sh") }
125
+ its(:to_script) { should eq fixture("integration/ruby/matrix/1.script.sh") }
126
+ its(:to_after_script) { should eq fixture("integration/ruby/matrix/1.after_script.sh") }
127
+ end
128
+
129
+ context "deploy configuration" do
130
+ let(:task) { create :task, deploy: true }
131
+ let(:source) { matrix.deploy_configuration("master") }
132
+ subject { script }
133
+
134
+ before do
135
+ =begin
136
+ File.open(fixture_path("integration/ruby/matrix/d.before_script.sh"), 'w') do |io|
137
+ io << script.to_before_script
138
+ end
139
+ File.open(fixture_path("integration/ruby/matrix/d.after_script.sh"), 'w') do |io|
140
+ io << script.to_after_script
141
+ end
142
+ File.open(fixture_path("integration/ruby/matrix/d.script.sh"), 'w') do |io|
143
+ io << script.to_script
144
+ end
145
+ =end
146
+ end
147
+
148
+ it "should have source" do
149
+ expect(source).to be
150
+ end
151
+
152
+ it { should be_deploy }
153
+ its(:to_before_script) { should eq fixture("integration/ruby/matrix/d.before_script.sh") }
154
+ its(:to_script) { should eq fixture("integration/ruby/matrix/d.script.sh") }
155
+ its(:to_after_script) { should eq fixture("integration/ruby/matrix/d.after_script.sh") }
156
+
157
+ end
158
+ end
159
+ end
@@ -46,6 +46,8 @@ describe Vx::Builder::BuildConfiguration do
46
46
  "artifacts" => ["app/foo.txt", "app/*.txt", "app/", {"prefix"=>"$CI_JOB_ID/"}],
47
47
  "deploy" => [{"command"=>"cap deploy production", "provider"=>"shell"}],
48
48
  "bundler_args" => ["--without development"],
49
+ "before_deploy" => ["echo before deploy"],
50
+ "after_deploy" => ["echo after deploy"]
49
51
  }
50
52
  ) }
51
53
  end
@@ -152,6 +154,35 @@ describe Vx::Builder::BuildConfiguration do
152
154
  expect(config).to be_deploy
153
155
  end
154
156
  end
157
+
158
+ context "with on:" do
159
+ subject { config.deploy.providers.first.on }
160
+
161
+ context "when is string" do
162
+ let(:content) { {
163
+ "deploy" => {
164
+ "provider" => "some",
165
+ "branch" => "production"
166
+ }
167
+ } }
168
+
169
+ it "should be branch" do
170
+ expect(subject).to eq(["production"])
171
+ end
172
+ end
173
+
174
+ context "when is array" do
175
+ let(:content) { {
176
+ "deploy" => {
177
+ "provider" => "some",
178
+ "branch" => %w{ production master }
179
+ }
180
+ } }
181
+
182
+ it { should eq %w{ production master } }
183
+ end
184
+
185
+ end
155
186
  end
156
187
 
157
188
  end
@@ -30,6 +30,65 @@ describe Vx::Builder::Matrix do
30
30
  end
31
31
  end
32
32
 
33
+ context "deploy_configuration" do
34
+ let(:branch) { 'master' }
35
+ subject { matrix.deploy_configuration branch }
36
+
37
+ it "should be nil without :deploy key" do
38
+ expect(subject).to be_nil
39
+ end
40
+
41
+ context "with single deploy without condifitions" do
42
+ let(:attributes) { {
43
+ "deploy" => "cap deploy production"
44
+ } }
45
+
46
+ it { should be }
47
+ its("deploy.attributes"){ should eq(
48
+ [{"command"=>"cap deploy production", "provider"=>"shell", "branch"=>[]}]
49
+ ) }
50
+ end
51
+
52
+ context "with single deploy and condititions" do
53
+ let(:attributes) { {
54
+ "deploy" => {
55
+ "command" => "cap deploy production",
56
+ "branch" => ["master"]
57
+ }
58
+ } }
59
+
60
+ it { should be }
61
+ its("deploy.attributes"){ should eq(
62
+ [{"command"=>"cap deploy production", "provider"=>"shell", "branch"=>["master"]}]
63
+ ) }
64
+ end
65
+
66
+ context "with multiple deploys and condititions" do
67
+ let(:attributes) { {
68
+ "deploy" => [
69
+ {
70
+ "command" => "cap deploy staging",
71
+ "branch" => ["master"]
72
+ },
73
+ {
74
+ "command" => "cap deploy production",
75
+ "branch" => ["production"]
76
+ }
77
+ ]
78
+ } }
79
+
80
+ it { should be }
81
+ its("deploy.attributes"){ should eq(
82
+ [{"command"=>"cap deploy staging", "provider"=>"shell", "branch"=>["master"]}]
83
+ ) }
84
+
85
+ context "when no one matched" do
86
+ let(:branch) { 'staging' }
87
+ it { should be_nil }
88
+ end
89
+ end
90
+ end
91
+
33
92
  context 'build_configurations' do
34
93
 
35
94
  subject { matrix.build_configurations }