capistrano-spec 0.5.1 → 0.6.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.
- data/Rakefile +1 -1
- data/capistrano-spec.gemspec +3 -2
- data/lib/capistrano/spec.rb +32 -0
- data/spec/capistrano-spec_spec.rb +22 -0
- data/spec/downloaded_spec.rb +50 -0
- data/spec/recipe/fakerecipe.rb +1 -0
- metadata +4 -3
data/Rakefile
CHANGED
data/capistrano-spec.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "capistrano-spec"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joshua Nichols", "Karl Matthias", "Peter M Souter", "Jan Graichen"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-08-15"
|
13
13
|
s.description = "Helpers and matchers for testing capistrano"
|
14
14
|
s.email = "josh@technicalpickles.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/capistrano-spec.rb",
|
29
29
|
"lib/capistrano/spec.rb",
|
30
30
|
"spec/capistrano-spec_spec.rb",
|
31
|
+
"spec/downloaded_spec.rb",
|
31
32
|
"spec/recipe/fakerecipe.rb",
|
32
33
|
"spec/spec.opts",
|
33
34
|
"spec/spec_helper.rb",
|
data/lib/capistrano/spec.rb
CHANGED
@@ -34,6 +34,14 @@ module Capistrano
|
|
34
34
|
@uploads ||= {}
|
35
35
|
end
|
36
36
|
|
37
|
+
def download(from, to, options={}, &block)
|
38
|
+
downloads[to] = {:from => from, :options => options, :block => block}
|
39
|
+
end
|
40
|
+
|
41
|
+
def downloads
|
42
|
+
@downloads ||= {}
|
43
|
+
end
|
44
|
+
|
37
45
|
def stubbed_commands
|
38
46
|
@stubbed_commands ||= {}
|
39
47
|
end
|
@@ -182,6 +190,30 @@ module Capistrano
|
|
182
190
|
end
|
183
191
|
end
|
184
192
|
|
193
|
+
define :have_downloaded do |path|
|
194
|
+
@from = nil # Reset `to` because it will influence next match otherwise.
|
195
|
+
|
196
|
+
match do |configuration|
|
197
|
+
downloads = configuration.downloads
|
198
|
+
downloads = downloads.select { |f, d| f == path } if path
|
199
|
+
downloads = downloads.select { |f, d| d[:from] == @from } if @from
|
200
|
+
downloads.any?
|
201
|
+
end
|
202
|
+
|
203
|
+
def from(from)
|
204
|
+
@from = from
|
205
|
+
self
|
206
|
+
end
|
207
|
+
|
208
|
+
failure_message_for_should do |actual|
|
209
|
+
if @from
|
210
|
+
"expected configuration to download #{path} from #{@from}, but did not"
|
211
|
+
else
|
212
|
+
"expected configuration to download #{path}, but did not"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
185
217
|
define :have_run do |cmd|
|
186
218
|
|
187
219
|
match do |configuration|
|
@@ -40,6 +40,28 @@ describe Capistrano::Spec do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe 'have_downloaded' do
|
44
|
+
let(:error_message) do
|
45
|
+
/expected configuration to download .*\s* from .*\s* but did not/
|
46
|
+
end
|
47
|
+
|
48
|
+
before do
|
49
|
+
fake_recipe.find_and_execute_task('fake:thing')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "will not raise error when download is in recipe" do
|
53
|
+
expect {
|
54
|
+
expect(fake_recipe).to have_downloaded('foo').from('/tmp/foo')
|
55
|
+
}.to_not raise_error(RSpec::Expectations::ExpectationNotMetError, error_message)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "will raise error when run download not in recipe" do
|
59
|
+
expect {
|
60
|
+
expect(fake_recipe).to have_downloaded('bar').from('/tmp/bar')
|
61
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, error_message)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
43
65
|
describe 'have_gotten' do
|
44
66
|
it "will not raise error when get is in recipe" do
|
45
67
|
fake_recipe.find_and_execute_task('fake:thing')
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'capistrano'
|
3
|
+
|
4
|
+
describe 'Capistrano has downloaded' do
|
5
|
+
include Capistrano::Spec::Matchers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@configuration = Capistrano::Configuration.new
|
9
|
+
@configuration.extend Capistrano::Spec::ConfigurationExtension
|
10
|
+
@configuration.load do
|
11
|
+
def download_from_to
|
12
|
+
download 'source.file', 'target.file'
|
13
|
+
end
|
14
|
+
|
15
|
+
def download_to
|
16
|
+
download 'temp.XC3PO.file', 'target.file' # E.g. downloading generated tar
|
17
|
+
end
|
18
|
+
|
19
|
+
def download_from
|
20
|
+
download 'source.file', 'temp.XC3PO.file' # E.g. downloading to temp file
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
subject(:configuration) { @configuration }
|
26
|
+
|
27
|
+
it 'some file' do
|
28
|
+
configuration.download 'source.file', 'target.file'
|
29
|
+
|
30
|
+
expect(configuration).to have_downloaded
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'a specific file from a specific location' do
|
34
|
+
configuration.download_from_to
|
35
|
+
|
36
|
+
expect(configuration).to have_downloaded('target.file').from('source.file')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'a specific file to some location' do
|
40
|
+
configuration.download_from
|
41
|
+
|
42
|
+
expect(configuration).to have_downloaded.from('source.file')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'some file to a specific location' do
|
46
|
+
configuration.download_to
|
47
|
+
|
48
|
+
expect(configuration).to have_downloaded('target.file')
|
49
|
+
end
|
50
|
+
end
|
data/spec/recipe/fakerecipe.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/capistrano-spec.rb
|
50
50
|
- lib/capistrano/spec.rb
|
51
51
|
- spec/capistrano-spec_spec.rb
|
52
|
+
- spec/downloaded_spec.rb
|
52
53
|
- spec/recipe/fakerecipe.rb
|
53
54
|
- spec/spec.opts
|
54
55
|
- spec/spec_helper.rb
|
@@ -69,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
70
|
version: '0'
|
70
71
|
segments:
|
71
72
|
- 0
|
72
|
-
hash:
|
73
|
+
hash: 2219320887055981214
|
73
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
75
|
none: false
|
75
76
|
requirements:
|