capistrano-spec 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "capistrano-spec"
8
- gem.version = '0.5.0'
8
+ gem.version = '0.5.1'
9
9
 
10
10
  gem.summary = %Q{Test your capistrano recipes}
11
11
  gem.description = %Q{Helpers and matchers for testing capistrano}
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{capistrano-spec}
8
- s.version = "0.5.0"
7
+ s.name = "capistrano-spec"
8
+ s.version = "0.5.1"
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 = %q{2013-06-21}
13
- s.description = %q{Helpers and matchers for testing capistrano}
14
- s.email = %q{josh@technicalpickles.com}
12
+ s.date = "2013-06-30"
13
+ s.description = "Helpers and matchers for testing capistrano"
14
+ s.email = "josh@technicalpickles.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -32,12 +32,13 @@ Gem::Specification.new do |s|
32
32
  "spec/spec.opts",
33
33
  "spec/spec_helper.rb",
34
34
  "spec/stub_commands_spec.rb",
35
+ "spec/support/shared/callback_examples.rb",
35
36
  "spec/uploaded_spec.rb"
36
37
  ]
37
- s.homepage = %q{http://github.com/technicalpickles/capistrano-spec}
38
+ s.homepage = "http://github.com/technicalpickles/capistrano-spec"
38
39
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.6.2}
40
- s.summary = %q{Test your capistrano recipes}
40
+ s.rubygems_version = "1.8.23"
41
+ s.summary = "Test your capistrano recipes"
41
42
 
42
43
  if s.respond_to? :specification_version then
43
44
  s.specification_version = 3
@@ -57,6 +57,18 @@ module Capistrano
57
57
  end
58
58
  end
59
59
 
60
+ def task_callable?(configuration, callbacks, task_name)
61
+ task = find_task(configuration, task_name) || stub_task(task_name)
62
+ callbacks.any? { |callback| callback.applies_to?(task) }
63
+ end
64
+
65
+ def find_task(configuration, task_name)
66
+ configuration.find_task(task_name)
67
+ end
68
+
69
+ def stub_task(task_name)
70
+ Struct.new(:fully_qualified_name).new(task_name)
71
+ end
60
72
  end
61
73
 
62
74
  module Matchers
@@ -66,16 +78,14 @@ module Capistrano
66
78
  extend Helpers
67
79
 
68
80
  match do |configuration|
69
- @task = configuration.find_task(task_name)
70
- callbacks = find_callback(configuration, @on, @task)
81
+ task = configuration.find_task(task_name)
82
+ callbacks = find_callback(configuration, @on, task)
71
83
 
72
84
  if callbacks
73
85
  if @after_task_name
74
- @after_task = configuration.find_task(@after_task_name)
75
- callbacks.any? { |callback| callback.applies_to?(@after_task) }
86
+ task_callable?(configuration, callbacks, @after_task_name)
76
87
  elsif @before_task_name
77
- @before_task = configuration.find_task(@before_task_name)
78
- callbacks.any? { |callback| callback.applies_to?(@before_task) }
88
+ task_callable?(configuration, callbacks, @before_task_name)
79
89
  else
80
90
  ! @callback.nil?
81
91
  end
@@ -111,6 +121,16 @@ module Capistrano
111
121
  end
112
122
  end
113
123
 
124
+ failure_message_for_should_not do |actual|
125
+ if @after_task_name
126
+ "expected configuration to not callback #{task_name.inspect} #{@on} #{@after_task_name.inspect}, but did"
127
+ elsif @before_task_name
128
+ "expected configuration to not callback #{task_name.inspect} #{@on} #{@before_task_name.inspect}, but did"
129
+ else
130
+ "expected configuration to not callback #{task_name.inspect} on #{@on}, but did"
131
+ end
132
+ end
133
+
114
134
  end
115
135
 
116
136
  define :have_gotten do |path|
@@ -53,16 +53,47 @@ describe Capistrano::Spec do
53
53
  end
54
54
 
55
55
  describe 'callback' do
56
+ context 'before callbacks' do
57
+ it_should_behave_like 'correct before callback' do
58
+ let(:task_name) { 'fake:before_this_execute_thing' }
59
+ end
60
+
61
+ it_should_behave_like 'correct before callback' do
62
+ let(:task_name) { 'fake:before_this_also_execute_thing' }
63
+ end
64
+
65
+ it_should_behave_like 'correct before callback' do
66
+ let(:task_name) { 'outside:undefined_task' }
67
+ end
68
+
69
+ it_should_behave_like 'incorrect before callback' do
70
+ let(:task_name) { 'undefined_task' }
71
+ end
56
72
 
57
- ['fake:before_this_execute_thing', "fake:before_this_also_execute_thing"].each do |task|
58
- it "will not raise error when `before` callback has occured for #{task}" do
59
- fake_recipe.should callback('fake:thing').before(task)
73
+ it_should_behave_like 'incorrect before callback' do
74
+ let(:task_name) { 'fake:before_this_dont_execute_thing' }
60
75
  end
61
76
  end
62
77
 
63
- ['fake:after_this_execute_thing', "fake:after_this_also_execute_thing"].each do |task|
64
- it "will not raise error when `after` callback has occured for #{task}" do
65
- fake_recipe.should callback('fake:thing').after(task)
78
+ context 'after callbacks' do
79
+ it_should_behave_like 'correct after callback' do
80
+ let(:task_name) { 'fake:after_this_execute_thing' }
81
+ end
82
+
83
+ it_should_behave_like 'correct after callback' do
84
+ let(:task_name) { 'fake:after_this_also_execute_thing' }
85
+ end
86
+
87
+ it_should_behave_like 'correct after callback' do
88
+ let(:task_name) { 'outside:undefined_task' }
89
+ end
90
+
91
+ it_should_behave_like 'incorrect after callback' do
92
+ let(:task_name) { 'undefined_task' }
93
+ end
94
+
95
+ it_should_behave_like 'incorrect after callback' do
96
+ let(:task_name) { 'fake:after_this_dont_execute_thing' }
66
97
  end
67
98
  end
68
99
  end
@@ -73,14 +104,20 @@ describe Capistrano::Spec do
73
104
  fake_recipe.find_and_execute_task('fake:thing')
74
105
  expect do
75
106
  should have_put('fake content').to('/tmp/put')
76
- end.to_not raise_error(RSpec::Expectations::ExpectationNotMetError, /expected configuration to put .*\s* to .*\s*, but did not/)
107
+ end.to_not raise_error(
108
+ RSpec::Expectations::ExpectationNotMetError,
109
+ /expected configuration to put .*\s* to .*\s*, but did not/
110
+ )
77
111
  end
78
112
 
79
113
  it "will raise error when put is not in recipe" do
80
114
  fake_recipe.find_and_execute_task('fake:thing')
81
115
  expect do
82
116
  should have_put('real content').to('/tmp/wherever')
83
- end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected configuration to put .*\s* to .*\s*, but did not/)
117
+ end.to raise_error(
118
+ RSpec::Expectations::ExpectationNotMetError,
119
+ /expected configuration to put .*\s* to .*\s*, but did not/
120
+ )
84
121
  end
85
122
  end
86
123
 
@@ -89,14 +126,20 @@ describe Capistrano::Spec do
89
126
  fake_recipe.find_and_execute_task('fake:thing')
90
127
  expect do
91
128
  should have_put('fake content')
92
- end.to_not raise_error(RSpec::Expectations::ExpectationNotMetError, /expected configuration to put .*\s*, but did not/)
129
+ end.to_not raise_error(
130
+ RSpec::Expectations::ExpectationNotMetError,
131
+ /expected configuration to put .*\s*, but did not/
132
+ )
93
133
  end
94
134
 
95
135
  it "will raise error when put is not in recipe" do
96
136
  fake_recipe.find_and_execute_task('fake:thing')
97
137
  expect do
98
138
  should have_put('real content')
99
- end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected configuration to put .*\s*, but did not/)
139
+ end.to raise_error(
140
+ RSpec::Expectations::ExpectationNotMetError,
141
+ /expected configuration to put .*\s*, but did not/
142
+ )
100
143
  end
101
144
  end
102
145
  end
@@ -5,8 +5,12 @@ require 'capistrano'
5
5
  configuration.load do
6
6
  before "fake:before_this_execute_thing", "fake:thing"
7
7
  before "fake:before_this_also_execute_thing", "fake:thing"
8
+ before "outside:undefined_task", "fake:thing"
9
+
8
10
  after "fake:after_this_execute_thing", "fake:thing"
9
11
  after "fake:after_this_also_execute_thing", "fake:thing"
12
+ after "outside:undefined_task", "fake:thing"
13
+
10
14
  namespace :fake do
11
15
  desc "thing and run fake manifests"
12
16
  task :thing do
@@ -24,12 +28,18 @@ require 'capistrano'
24
28
  task :before_this_also_execute_thing do
25
29
  #
26
30
  end
31
+ task :before_this_dont_execute_thing do
32
+ #
33
+ end
27
34
  task :after_this_execute_thing do
28
35
  #
29
36
  end
30
37
  task :after_this_also_execute_thing do
31
38
  #
32
39
  end
40
+ task :after_this_dont_execute_thing do
41
+ #
42
+ end
33
43
  end
34
44
  end
35
45
  end
@@ -5,7 +5,9 @@ require 'capistrano-spec'
5
5
  require 'rspec'
6
6
  require 'rspec/autorun'
7
7
 
8
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
9
+
8
10
  RSpec.configure do |config|
9
- config.include Capistrano::Spec::Matchers
10
- config.include Capistrano::Spec::Helpers
11
+ config.include Capistrano::Spec::Matchers
12
+ config.include Capistrano::Spec::Helpers
11
13
  end
@@ -0,0 +1,43 @@
1
+ shared_examples 'correct before callback' do
2
+ it "won't raise error when `before` callback has occured for the given task" do
3
+ expect do
4
+ should callback('fake:thing').before(task_name)
5
+ end.to_not raise_error(
6
+ RSpec::Expectations::ExpectationNotMetError,
7
+ /expected configuration to callback .*\s* before .*\s*, but did not/
8
+ )
9
+ end
10
+ end
11
+
12
+ shared_examples 'incorrect before callback' do
13
+ it "will raise error when `before` callback hasn't occured for the given task" do
14
+ expect do
15
+ should_not callback('fake:thing').before(task_name)
16
+ end.to_not raise_error(
17
+ RSpec::Expectations::ExpectationNotMetError,
18
+ /expected configuration to not callback .*\s* before .*\s*, but did/
19
+ )
20
+ end
21
+ end
22
+
23
+ shared_examples 'correct after callback' do
24
+ it "won't raise error when `after` callback has occured for the given task" do
25
+ expect do
26
+ should callback('fake:thing').after(task_name)
27
+ end.to_not raise_error(
28
+ RSpec::Expectations::ExpectationNotMetError,
29
+ /expected configuration to callback .*\s* after .*\s*, but did not/
30
+ )
31
+ end
32
+ end
33
+
34
+ shared_examples 'incorrect after callback' do
35
+ it "will raise error when `after` callback hasn't occured for the given task" do
36
+ expect do
37
+ should_not callback('fake:thing').after(task_name)
38
+ end.to_not raise_error(
39
+ RSpec::Expectations::ExpectationNotMetError,
40
+ /expected configuration to not callback .*\s* after .*\s*, but did/
41
+ )
42
+ end
43
+ end
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capistrano-spec
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Joshua Nichols
14
9
  - Karl Matthias
15
10
  - Peter M Souter
@@ -17,36 +12,32 @@ authors:
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2013-06-21 00:00:00 +02:00
22
- default_executable:
23
- dependencies:
24
- - !ruby/object:Gem::Dependency
25
- requirement: &id001 !ruby/object:Gem::Requirement
15
+ date: 2013-06-30 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rspec
19
+ requirement: !ruby/object:Gem::Requirement
26
20
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 15
31
- segments:
32
- - 2
33
- - 0
34
- - 0
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
35
24
  version: 2.0.0
36
25
  type: :development
37
- name: rspec
38
- version_requirements: *id001
39
26
  prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
40
33
  description: Helpers and matchers for testing capistrano
41
34
  email: josh@technicalpickles.com
42
35
  executables: []
43
-
44
36
  extensions: []
45
-
46
- extra_rdoc_files:
37
+ extra_rdoc_files:
47
38
  - LICENSE
48
39
  - README.rdoc
49
- files:
40
+ files:
50
41
  - .document
51
42
  - .travis.yml
52
43
  - Gemfile
@@ -62,40 +53,33 @@ files:
62
53
  - spec/spec.opts
63
54
  - spec/spec_helper.rb
64
55
  - spec/stub_commands_spec.rb
56
+ - spec/support/shared/callback_examples.rb
65
57
  - spec/uploaded_spec.rb
66
- has_rdoc: true
67
58
  homepage: http://github.com/technicalpickles/capistrano-spec
68
59
  licenses: []
69
-
70
60
  post_install_message:
71
61
  rdoc_options: []
72
-
73
- require_paths:
62
+ require_paths:
74
63
  - lib
75
- required_ruby_version: !ruby/object:Gem::Requirement
64
+ required_ruby_version: !ruby/object:Gem::Requirement
76
65
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ segments:
82
71
  - 0
83
- version: "0"
84
- required_rubygems_version: !ruby/object:Gem::Requirement
72
+ hash: -2637377504704629804
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
74
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
- version: "0"
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
93
79
  requirements: []
94
-
95
80
  rubyforge_project:
96
- rubygems_version: 1.6.2
81
+ rubygems_version: 1.8.23
97
82
  signing_key:
98
83
  specification_version: 3
99
84
  summary: Test your capistrano recipes
100
85
  test_files: []
101
-