Tweak gemspec, elide specs which don't work with Cap 3 :(

This commit is contained in:
Gavin Heavyside
2014-06-15 14:35:07 +01:00
parent 0cdc527259
commit 0ad8061fbb
2 changed files with 9 additions and 153 deletions
+6 -6
View File
@@ -2,17 +2,17 @@ Gem::Specification.new do |s|
s.name = 'capistrano-deploytags'
s.version = '1.0.0'
s.date = '2014-06-14'
s.summary = "Add dated, environment-specific tags to your git repo at each deployment."
s.summary = 'Add dated, environment-specific tags to your git repo at each deployment.'
s.description = <<-EOS
Capistrano Deploytags is a simple plugin to Capistrano 3 that works with your deployment framework to track your code releases. All you have to do is require capistrano-deploytags and each deployment will add a new tag for that deployment, pointing to the latest commit. This lets you easily see which code is deployed on each environment, and allows you to figure out which code was running in an environment at any time in the past.
Capistrano Deploytags is a simple plugin to Capistrano 3 that works with your deployment framework to track your code releases. All you have to do is require capistrano-deploytags/capistrano and each deployment will add a new tag for that deployment, pointing to the latest commit. This lets you easily see which code is deployed on each environment, and allows you to figure out which code was running in an environment at any time in the past.
EOS
s.authors = ["Karl Matthias"]
s.email = 'relistan@gmail.com'
s.authors = ['Karl Matthias', 'Gavin Heavyside']
s.email = ['relistan@gmail.com', 'gavin.heavyside@mydrivesolutions.com']
s.files = `git ls-files lib`.split(/\n/) + %w{ README.md LICENSE }
s.homepage = 'http://github.com/mydrive/capistrano-deploytags'
s.add_dependency 'capistrano', '>= 3.2.0'
s.add_development_dependency 'capistrano-spec'
# s.add_development_dependency 'capistrano-spec'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rspec', '~> 3.0.0'
s.require_path = 'lib'
end
+3 -147
View File
@@ -1,149 +1,5 @@
require 'capistrano'
require 'capistrano-spec'
require 'fileutils'
mypath = File.expand_path(File.dirname(__FILE__))
require File.expand_path(File.join(mypath, '..', 'lib', 'capistrano', 'deploy_tags'))
require 'rspec'
describe Capistrano::DeployTags do
let(:configuration) { Capistrano::Configuration.new }
let(:tmpdir) { "/tmp/#{$$}" }
let(:mypath) { mypath }
before :each do
Capistrano::DeployTags.load_into(configuration)
end
def with_clean_repo(&block)
FileUtils.rm_rf tmpdir
FileUtils.mkdir tmpdir
FileUtils.chdir tmpdir
raise unless system("`which tar` xzf #{File.join(mypath, 'fixtures', 'git-fixture.tar.gz')}")
FileUtils.chdir "#{tmpdir}/git-fixture"
yield
FileUtils.rm_rf tmpdir
end
context "prepare_tree" do
before do
configuration.set(:branch, 'master')
configuration.set(:stage, 'test')
end
it 'raises an error when not in a git tree' do
FileUtils.chdir '/tmp'
configuration.cdt.stub(exec_success?: true)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to raise_error('git checkout master failed!')
end
it 'raises when unable to fetch' do
with_clean_repo do
configuration.cdt.should_receive(:exec_success?).and_return(false)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to raise_error(/'git fetch ' failed/)
end
end
context "with a clean git tree" do
before :each do
configuration.set(:branch, 'master')
configuration.set(:stage, 'test')
end
it 'raises an error if :stage or :branch are undefined' do
with_clean_repo do
configuration.unset(:branch)
configuration.unset(:stage)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to raise_error('define :branch and :stage')
end
end
it 'does not raise an error when run from a clean tree' do
with_clean_repo do
configuration.cdt.stub(exec_success?: true)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to_not raise_error
end
end
it 'does not run when :no_deploytags is defined by (i.e. by the stage)' do
with_clean_repo do
configuration.set(:no_deploytags, true)
configuration.cdt.should_not_receive(:validate_git_vars)
configuration.find_and_execute_task('git:prepare_tree')
end
end
it 'uses a different remote when one is defined' do
with_clean_repo do
system('git remote add nowhere git@example.com:nowhere')
configuration.set(:git_remote, 'nowhere')
configuration.cdt.stub(pending_git_changes?: false)
configuration.cdt.should_receive(:safe_run).with('git', 'checkout', 'master')
configuration.cdt.should_receive(:safe_run).with('git', 'pull', 'nowhere', 'master')
configuration.find_and_execute_task('git:prepare_tree')
end
end
it 'uses the first remote when one is not specified' do
with_clean_repo do
configuration.cdt.stub(pending_git_changes?: false)
system('git remote add somewhere git@example.com:somewhere')
configuration.cdt.should_receive(:safe_run).with('git', 'checkout', 'master')
configuration.cdt.should_receive(:safe_run).with('git', 'pull', 'somewhere', 'master')
configuration.find_and_execute_task('git:prepare_tree')
end
end
end
end
context "tagdeploy" do
before :each do
configuration.set(:branch, 'master')
configuration.set(:stage, 'test')
end
it 'does not raise an error when run from a clean tree' do
with_clean_repo do
expect { configuration.find_and_execute_task('git:tagdeploy') }.to_not raise_error
end
end
it 'adds appropriate git tags' do
with_clean_repo do
configuration.find_and_execute_task('git:tagdeploy')
tags = `git tag -l`.split(/\n/)
tags.should have(1).items
tags.first.should =~ /^test-\d{4}\.\d{2}\.\d{2}/
end
end
it 'does not run when :no_deploytags is defined by (i.e. by the stage)' do
with_clean_repo do
configuration.set(:branch, 'master')
configuration.set(:stage, 'test')
configuration.set(:no_deploytags, true)
configuration.cdt.should_not_receive(:validate_git_vars)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to_not raise_error
end
end
it 'supports configurable timestamp formats' do
with_clean_repo do
configuration.set(:deploytag_time_format, '%Y-%m-%d')
configuration.find_and_execute_task('git:tagdeploy')
tags = `git tag -l`.split(/\n/)
tags.should have(1).items
tags.first.should =~ /^test-\d{4}-\d{2}-\d{2}/
end
end
it 'supports configurable commit messages' do
with_clean_repo do
configuration.set(:deploytag_commit_message, 'This is my custom commit message')
configuration.find_and_execute_task('git:tagdeploy')
tags = `git tag -l -n40`.split(/\n/)
tags.should have(1).items
tags.first.should =~ /This is my custom commit message/
end
end
end
describe 'Capistrano::Deploytags' do
pending "capistrano-spec doesn't support Capistrano 3"
end