vigetlabs-provisional 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +27 -10
- data/Rakefile +87 -0
- data/VERSION.yml +2 -2
- data/bin/provisional +7 -4
- data/lib/provisional/project.rb +25 -16
- data/lib/provisional/scm/git.rb +7 -7
- data/lib/provisional/scm/github.rb +2 -2
- data/lib/provisional/scm/unfuddle.rb +45 -0
- data/test/unit/git_test.rb +2 -3
- data/test/unit/github_test.rb +2 -3
- data/test/unit/project_test.rb +16 -21
- data/test/unit/unfuddle_test.rb +106 -0
- metadata +22 -10
data/README.rdoc
CHANGED
@@ -19,20 +19,26 @@ Provisional is only tested on Mac OS X. It should also work on Linux. It is not
|
|
19
19
|
== Usage
|
20
20
|
|
21
21
|
Options:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
--name, -n <s>: Name of the project
|
23
|
+
--scm, -s <s>: SCM to use (default: git)
|
24
|
+
--template, -t <s>: Rails template to use (default: viget)
|
25
|
+
--domain, -d <s>: Domain (for some SCMs, see below)
|
26
|
+
--username, -u <s>: Username (for some SCMs, see below)
|
27
|
+
--password, -p <s>: Password (for some SCMs, see below)
|
28
|
+
--id, -i <s>: Id (for some SCMs, see below)
|
29
|
+
--config, -c <s>: Config file (optional)
|
30
|
+
--help, -h: Show this message
|
28
31
|
|
29
32
|
The SCM option can be one of the following ("project_name" refers to the value of the --name option):
|
30
33
|
|
31
|
-
* git: creates a git repository in the project_name directory
|
32
|
-
* github: creates a git repository in the project_name directory, creates project_name on GitHub using the specified credentials,
|
34
|
+
* git: creates a git repository in the project_name directory.
|
35
|
+
* github: creates a git repository in the project_name directory, creates project_name on GitHub using the specified credentials, adds it as the "origin" remote, and pushes. (See section below about required configuration.)
|
36
|
+
* unfuddle: creates a git repository in the project_name directory, creates a repository called project_name under an existing Unfuddle project using the specified credentials, and adds it as the "origin" remote. _You must push manually_ because Unfuddle typically has a lag of a few minutes between when a repository is created and when it can be accessed. (See section below about required configuration.)
|
33
37
|
|
34
38
|
(Subversion and Viget-specific SCM's were removed in Provisional 2.0.0. They may return at a later date.)
|
35
39
|
|
40
|
+
The domain, username, password, and id options are used by certain SCMs to provide information needed to use an API. The documentation on these SCMs (below) will indicate how they are to be used.
|
41
|
+
|
36
42
|
The template option can be either a literal path to a template file, a URL for a template on a remote server, or the name of one of the templates found in lib/provisional/templates (without the .rb suffix.) The default viget template does the following:
|
37
43
|
|
38
44
|
* freezes rails from currently installed gems
|
@@ -42,11 +48,22 @@ The template option can be either a literal path to a template file, a URL for a
|
|
42
48
|
* generates Capistrano configuration with viget_deployment
|
43
49
|
* copies database.yml to database.yml-sample
|
44
50
|
* removes public/index.html, test/fixtures, prototype, and script.aculo.us
|
45
|
-
* creates
|
51
|
+
* creates an SCM repository and checks the application in (pushing to origin if GitHub is used)
|
52
|
+
|
53
|
+
All of these options can be specified either on the command line, or in a YAML file indicated by the --config option. The YAML file should be in simple key: value format:
|
54
|
+
|
55
|
+
name: awesome_project
|
56
|
+
scm: git
|
57
|
+
|
58
|
+
Options specified via the command line take precedence over options specified in a YAML file, if both are specified.
|
46
59
|
|
47
60
|
== GitHub
|
48
61
|
|
49
|
-
To use GitHub, you will need to place your GitHub username and token in your Git configuration as described here: http://github.com/guides/local-github-config
|
62
|
+
To use GitHub, you will need to place your GitHub username and token in your Git configuration as described here: http://github.com/guides/local-github-config Since there is already this established convention for GitHub credentials, to prevent redundant configuration, Provisional does not use its own configuration options for GitHub access.
|
63
|
+
|
64
|
+
== Unfuddle
|
65
|
+
|
66
|
+
To use Unfuddle, you will need to specify the --domain, --id, --username and --password options. --domain is used to specify your unfuddle.com subdomain; --id is used to specify a project ID. Using a YAML file containing these options is recommended and should be helpful.
|
50
67
|
|
51
68
|
== License
|
52
69
|
|
data/Rakefile
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "provisional"
|
8
|
+
gem.summary = "Automation for new Rails Projects"
|
9
|
+
gem.email = "mark@viget.com"
|
10
|
+
gem.homepage = "http://github.com/vigetlabs/provisional"
|
11
|
+
gem.authors = ["Mark Cornick"]
|
12
|
+
gem.rubyforge_project = "viget"
|
13
|
+
gem.add_dependency 'trollop', '>= 1.10.2'
|
14
|
+
gem.add_dependency 'rails', '>= 2.3.0'
|
15
|
+
gem.add_dependency 'git', '>= 1.0.5'
|
16
|
+
gem.add_dependency 'builder', '>= 2.1.2'
|
17
|
+
|
18
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
Rake::TestTask.new(:test) do |test|
|
26
|
+
test.libs << 'lib' << 'test'
|
27
|
+
test.pattern = 'test/**/*_test.rb'
|
28
|
+
test.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rcov/rcovtask'
|
33
|
+
Rcov::RcovTask.new do |test|
|
34
|
+
test.libs << 'test'
|
35
|
+
test.pattern = 'test/**/*_test.rb'
|
36
|
+
test.verbose = true
|
37
|
+
test.rcov_opts << '-x gems'
|
38
|
+
end
|
39
|
+
rescue LoadError
|
40
|
+
task :rcov do
|
41
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'rake/rdoctask'
|
49
|
+
Rake::RDocTask.new do |rdoc|
|
50
|
+
if File.exist?('VERSION.yml')
|
51
|
+
config = YAML.load(File.read('VERSION.yml'))
|
52
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
53
|
+
else
|
54
|
+
version = ""
|
55
|
+
end
|
56
|
+
|
57
|
+
rdoc.rdoc_dir = 'rdoc'
|
58
|
+
rdoc.title = "provisional #{version}"
|
59
|
+
rdoc.rdoc_files.include('README*')
|
60
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
require 'rake/contrib/sshpublisher'
|
65
|
+
namespace :rubyforge do
|
66
|
+
|
67
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
68
|
+
task :release => ["rubyforge:release:gem"]
|
69
|
+
|
70
|
+
namespace :release do
|
71
|
+
desc "Publish RDoc to RubyForge."
|
72
|
+
task :docs => [:rdoc] do
|
73
|
+
config = YAML.load(
|
74
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
75
|
+
)
|
76
|
+
|
77
|
+
host = "#{config['username']}@rubyforge.org"
|
78
|
+
remote_dir = "/var/www/gforge-projects/provisional/"
|
79
|
+
local_dir = 'rdoc'
|
80
|
+
|
81
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
rescue LoadError
|
86
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
87
|
+
end
|
data/VERSION.yml
CHANGED
data/bin/provisional
CHANGED
@@ -5,11 +5,14 @@ require 'provisional'
|
|
5
5
|
require 'trollop'
|
6
6
|
|
7
7
|
options = Trollop::options do
|
8
|
-
# version "1.2.4"
|
9
8
|
opt :name, "Name of the project", :type => String
|
10
|
-
opt :scm, "SCM to use", :type => String
|
11
|
-
opt :
|
12
|
-
opt :
|
9
|
+
opt :scm, "SCM to use", :type => String
|
10
|
+
opt :template, "Rails template to use", :type => String
|
11
|
+
opt :domain, "Domain (for some SCMs, see documentation)", :type => String
|
12
|
+
opt :username, "Username (for some SCMs, see documentation)", :type => String
|
13
|
+
opt :password, "Password (for some SCMs, see documentation)", :type => String
|
14
|
+
opt :id, "Id (for some SCMs, see documentation)", :type => String
|
15
|
+
opt :config, "Config file (optional)", :type => String
|
13
16
|
end
|
14
17
|
|
15
18
|
Provisional::Project.new(options)
|
data/lib/provisional/project.rb
CHANGED
@@ -1,38 +1,47 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'uri'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
module Provisional
|
5
6
|
class Project
|
6
7
|
attr_reader :options
|
7
8
|
|
8
9
|
def initialize(options)
|
9
|
-
@options =
|
10
|
+
@options = HashWithIndifferentAccess.new
|
11
|
+
if options[:config]
|
12
|
+
begin
|
13
|
+
@options = @options.merge(YAML.load_file(options[:config]))
|
14
|
+
rescue
|
15
|
+
raise ArgumentError, "could not be loaded or parsed: #{options[:config]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@options = @options.merge(options.reject{|k,v| v.nil?})
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
|
20
|
+
@options[:scm] ||= 'git'
|
21
|
+
@options[:template] ||= 'viget'
|
22
|
+
|
23
|
+
unless is_valid_url?(@options['template'])
|
24
|
+
if File.exist?(File.expand_path(@options['template']))
|
25
|
+
@options['template_path'] = File.expand_path(@options['template'])
|
14
26
|
else
|
15
|
-
@options[
|
27
|
+
@options['template_path'] = File.expand_path(File.join(File.dirname(__FILE__),'templates',"#{@options['template']}.rb"))
|
16
28
|
end
|
17
|
-
raise ArgumentError, "is not valid: #{@options[
|
29
|
+
raise ArgumentError, "is not valid: #{@options['template']}" unless File.exist?(@options['template_path'])
|
18
30
|
else
|
19
|
-
@options[
|
31
|
+
@options['template_path'] = @options['template']
|
20
32
|
end
|
21
33
|
|
22
|
-
raise ArgumentError, "must be specified" unless @options[
|
23
|
-
raise ArgumentError, "already exists: #{@options[
|
24
|
-
raise ArgumentError, "already exists: #{@options[
|
34
|
+
raise ArgumentError, "name must be specified" unless @options['name']
|
35
|
+
raise ArgumentError, "already exists: #{@options['name']}" if File.exist?(@options['name'])
|
36
|
+
raise ArgumentError, "already exists: #{@options['name']}.repo" if @options['scm'] == 'svn' && File.exist?("#{@options['name']}.repo")
|
25
37
|
|
26
38
|
begin
|
27
|
-
require "provisional/scm/#{@options[
|
39
|
+
require "provisional/scm/#{@options['scm']}"
|
28
40
|
rescue MissingSourceFile
|
29
|
-
raise ArgumentError, "is not supported: #{@options[
|
41
|
+
raise ArgumentError, "is not supported: #{@options['scm']}"
|
30
42
|
end
|
31
43
|
|
32
|
-
|
33
|
-
raise ArgumentError, "is not valid: #{@options[:rails]}" unless File.exist?(@options[:rails]) && File.executable?(@options[:rails])
|
34
|
-
|
35
|
-
scm_class = "Provisional::SCM::#{@options[:scm].classify}".constantize
|
44
|
+
scm_class = "Provisional::SCM::#{@options['scm'].classify}".constantize
|
36
45
|
scm = scm_class.new(@options)
|
37
46
|
scm.init
|
38
47
|
scm.generate_rails
|
data/lib/provisional/scm/git.rb
CHANGED
@@ -25,17 +25,17 @@ module Provisional
|
|
25
25
|
|
26
26
|
def init
|
27
27
|
rescuing_exceptions do
|
28
|
-
FileUtils.mkdir_p @options[
|
29
|
-
Dir.chdir @options[
|
30
|
-
@options[
|
28
|
+
FileUtils.mkdir_p @options['name']
|
29
|
+
Dir.chdir @options['name']
|
30
|
+
@options['path'] = Dir.getwd
|
31
31
|
::Git.init
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def generate_rails
|
36
36
|
rescuing_exceptions do
|
37
|
-
generator_options = ['.', '-m', @options[
|
38
|
-
Dir.chdir @options[
|
37
|
+
generator_options = ['.', '-m', @options['template_path']]
|
38
|
+
Dir.chdir @options['path']
|
39
39
|
Rails::Generator::Base.use_application_sources!
|
40
40
|
Rails::Generator::Scripts::Generate.new.run generator_options, :generator => 'app'
|
41
41
|
end
|
@@ -43,8 +43,8 @@ module Provisional
|
|
43
43
|
|
44
44
|
def checkin
|
45
45
|
rescuing_exceptions do
|
46
|
-
repo = ::Git.open @options[
|
47
|
-
Dir.chdir @options[
|
46
|
+
repo = ::Git.open @options['path']
|
47
|
+
Dir.chdir @options['path']
|
48
48
|
File.open('.gitignore', 'w') do |f|
|
49
49
|
f.puts gitignore
|
50
50
|
end
|
@@ -12,9 +12,9 @@ module Provisional
|
|
12
12
|
Net::HTTP.post_form URI.parse('https://github.com/api/v2/yaml/repos/create'), {
|
13
13
|
'login' => github_user,
|
14
14
|
'token' => github_token,
|
15
|
-
'name' => @options[
|
15
|
+
'name' => @options['name']
|
16
16
|
}
|
17
|
-
repo.add_remote('origin', "git@github.com:#{github_user}/#{@options[
|
17
|
+
repo.add_remote('origin', "git@github.com:#{github_user}/#{@options['name']}.git")
|
18
18
|
repo.push
|
19
19
|
rescue
|
20
20
|
raise RuntimeError, "Repository created locally, but not pushed to GitHub due to exception: #{$!}"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'provisional/scm/git'
|
2
|
+
require 'net/http'
|
3
|
+
require 'builder'
|
4
|
+
|
5
|
+
module Provisional
|
6
|
+
module SCM
|
7
|
+
class Unfuddle < Provisional::SCM::Git
|
8
|
+
def initialize(options)
|
9
|
+
%w(username password domain id).each do |opt|
|
10
|
+
raise ArgumentError, "#{opt} must be specified" unless options[opt]
|
11
|
+
end
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def checkin
|
16
|
+
begin
|
17
|
+
repo = super
|
18
|
+
|
19
|
+
xml = Builder::XmlMarkup.new
|
20
|
+
xml.repository do
|
21
|
+
xml.abbreviation @options['name']
|
22
|
+
xml.title @options['name']
|
23
|
+
xml.system 'git'
|
24
|
+
xml.projects do
|
25
|
+
xml.project(:id => @options['id'])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
http = Net::HTTP.new("#{@options['domain']}.unfuddle.com", 80)
|
30
|
+
request = Net::HTTP::Post.new('/api/v1/repositories.xml', 'Content-Type' => 'application/xml')
|
31
|
+
request.basic_auth(@options['username'], @options['password'])
|
32
|
+
request.body = xml.target!
|
33
|
+
response, data = http.request(request)
|
34
|
+
unless response.code == "201"
|
35
|
+
raise RuntimeError, "Repository created locally, but not created on Unfuddle due to HTTP error: #{response.code}"
|
36
|
+
end
|
37
|
+
|
38
|
+
repo.add_remote('origin', "git@#{@options['domain']}.unfuddle.com:#{@options['domain']}/#{@options['name']}.git")
|
39
|
+
rescue
|
40
|
+
raise RuntimeError, "Repository created locally, but not pushed to Unfuddle due to exception: #{$!}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/test/unit/git_test.rb
CHANGED
data/test/unit/github_test.rb
CHANGED
data/test/unit/project_test.rb
CHANGED
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../../lib/provisional/scm/git'
|
|
3
3
|
|
4
4
|
class ProjectTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
RAILS = `which rails`.chomp
|
7
6
|
DEFAULT_TEMPLATE_PATH = File.expand_path(File.join(File.dirname(__FILE__), '../../lib/provisional/templates/viget.rb'))
|
8
7
|
|
9
8
|
def stub_git
|
@@ -15,10 +14,25 @@ class ProjectTest < Test::Unit::TestCase
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def new_project(opts = {})
|
18
|
-
opts = {:name => 'name', :template => 'viget', :
|
17
|
+
opts = {:name => 'name', :template => 'viget', :scm => 'git'}.merge(opts)
|
19
18
|
Provisional::Project.new(opts)
|
20
19
|
end
|
21
20
|
|
21
|
+
def test_should_be_able_to_use_a_config_file
|
22
|
+
options = {'name' => 'albert', 'template' => 'viget', 'scm' => 'git'}
|
23
|
+
YAML.expects(:load_file).with('config.yml').returns(options)
|
24
|
+
stub_git
|
25
|
+
project = Provisional::Project.new(:config => 'config.yml')
|
26
|
+
assert_equal 'albert', project.options[:name]
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_should_bail_on_config_file_errors
|
30
|
+
YAML.expects(:load_file).with('config.yml').raises(Errno::ENOENT)
|
31
|
+
assert_raise ArgumentError do
|
32
|
+
Provisional::Project.new(:config => 'config.yml')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
def test_new_project_should_call_init_generate_rails_and_checkin
|
23
37
|
stub_git
|
24
38
|
new_project
|
@@ -29,7 +43,6 @@ class ProjectTest < Test::Unit::TestCase
|
|
29
43
|
path_to_my_template = File.expand_path('my_template.rb')
|
30
44
|
File.expects(:exist?).with(path_to_my_template).times(2).returns(true)
|
31
45
|
File.expects(:exist?).with('name').returns(false)
|
32
|
-
File.expects(:exist?).with(RAILS).returns(true)
|
33
46
|
project = new_project(:template => 'my_template.rb')
|
34
47
|
assert_equal path_to_my_template, project.options[:template_path]
|
35
48
|
end
|
@@ -78,24 +91,6 @@ class ProjectTest < Test::Unit::TestCase
|
|
78
91
|
end
|
79
92
|
end
|
80
93
|
|
81
|
-
def test_should_raise_argumenterror_if_no_scm_is_specified
|
82
|
-
assert_raise ArgumentError do
|
83
|
-
new_project(:scm => nil)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_should_raise_argumenterror_if_no_rails_is_specified
|
88
|
-
assert_raise ArgumentError do
|
89
|
-
new_project(:rails => nil)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_should_raise_argumenterror_if_invalid_rails_is_specified
|
94
|
-
assert_raise ArgumentError do
|
95
|
-
new_project(:rails => 'bogus')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
94
|
def test_should_raise_argumenterror_if_invalid_template_is_specified
|
100
95
|
assert_raise ArgumentError do
|
101
96
|
new_project(:template => 'bogus')
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/provisional/scm/unfuddle'
|
3
|
+
|
4
|
+
class UnfuddleTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@scm = Provisional::SCM::Unfuddle.new(
|
7
|
+
{
|
8
|
+
'name' => 'name',
|
9
|
+
'template_path' => 'template_path',
|
10
|
+
'domain' => 'domain',
|
11
|
+
'id' => 1,
|
12
|
+
'username' => 'username',
|
13
|
+
'password' => 'password'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_gitignore
|
19
|
+
assert_equal Provisional::IGNORE_FILES.join("\n"), @scm.gitignore
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_init
|
23
|
+
FileUtils.expects(:mkdir_p).with('name')
|
24
|
+
Dir.expects(:chdir).with('name')
|
25
|
+
Git.expects(:init)
|
26
|
+
@scm.init
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_generate_rails
|
30
|
+
Dir.expects(:chdir)
|
31
|
+
Rails::Generator::Base.expects(:use_application_sources!)
|
32
|
+
generator_stub = stub()
|
33
|
+
generator_stub.expects(:run).with(%w(. -m template_path), :generator => 'app')
|
34
|
+
Rails::Generator::Scripts::Generate.expects(:new).returns(generator_stub)
|
35
|
+
@scm.generate_rails
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_checkin
|
39
|
+
repo_stub = stub()
|
40
|
+
repo_stub.expects(:add).with('.')
|
41
|
+
repo_stub.expects(:commit).with('Initial commit by Provisional')
|
42
|
+
repo_stub.expects(:add_remote)
|
43
|
+
|
44
|
+
Git.expects(:open).returns(repo_stub)
|
45
|
+
Dir.expects(:chdir)
|
46
|
+
gitignore_file = stub()
|
47
|
+
gitignore_file.expects(:puts).with(@scm.gitignore)
|
48
|
+
File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
|
49
|
+
|
50
|
+
request_stub = stub()
|
51
|
+
request_stub.expects(:basic_auth).with('username', 'password')
|
52
|
+
request_stub.expects(:body=)
|
53
|
+
response_stub = stub(:code => '201')
|
54
|
+
http_stub = stub()
|
55
|
+
http_stub.expects(:request).with(request_stub).returns(response_stub, nil)
|
56
|
+
|
57
|
+
Net::HTTP::Post.expects(:new).with('/api/v1/repositories.xml', 'Content-Type' => 'application/xml').returns(request_stub)
|
58
|
+
Net::HTTP.expects(:new).with("domain.unfuddle.com", 80).returns(http_stub)
|
59
|
+
|
60
|
+
@scm.checkin
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_checkin_should_raise_RuntimeError_if_unfuddle_api_call_fails
|
64
|
+
repo_stub = stub()
|
65
|
+
repo_stub.expects(:add).with('.')
|
66
|
+
repo_stub.expects(:commit).with('Initial commit by Provisional')
|
67
|
+
|
68
|
+
Git.expects(:open).returns(repo_stub)
|
69
|
+
Dir.expects(:chdir)
|
70
|
+
gitignore_file = stub()
|
71
|
+
gitignore_file.expects(:puts).with(@scm.gitignore)
|
72
|
+
File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
|
73
|
+
|
74
|
+
request_stub = stub()
|
75
|
+
request_stub.expects(:basic_auth).with('username', 'password')
|
76
|
+
request_stub.expects(:body=)
|
77
|
+
response_stub = stub(:code => '500')
|
78
|
+
http_stub = stub()
|
79
|
+
http_stub.expects(:request).with(request_stub).returns(response_stub, nil)
|
80
|
+
|
81
|
+
Net::HTTP::Post.expects(:new).with('/api/v1/repositories.xml', 'Content-Type' => 'application/xml').returns(request_stub)
|
82
|
+
Net::HTTP.expects(:new).with("domain.unfuddle.com", 80).returns(http_stub)
|
83
|
+
|
84
|
+
assert_raise RuntimeError do
|
85
|
+
@scm.checkin
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception
|
90
|
+
repo_stub = stub()
|
91
|
+
repo_stub.expects(:add).with('.')
|
92
|
+
repo_stub.expects(:commit).with('Initial commit by Provisional')
|
93
|
+
|
94
|
+
Git.expects(:open).returns(repo_stub)
|
95
|
+
Dir.expects(:chdir)
|
96
|
+
gitignore_file = stub()
|
97
|
+
gitignore_file.expects(:puts).with(@scm.gitignore)
|
98
|
+
File.expects(:open).with('.gitignore', 'w').yields(gitignore_file)
|
99
|
+
|
100
|
+
Net::HTTP.expects(:new).with("domain.unfuddle.com", 80).raises(Net::HTTPNotFound)
|
101
|
+
|
102
|
+
assert_raise RuntimeError do
|
103
|
+
@scm.checkin
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vigetlabs-provisional
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cornick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04
|
12
|
+
date: 2009-05-04 00:00:00 -07:00
|
13
13
|
default_executable: provisional
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,16 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 1.0.5
|
44
44
|
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: builder
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.1.2
|
54
|
+
version:
|
45
55
|
description:
|
46
56
|
email: mark@viget.com
|
47
57
|
executables:
|
@@ -52,26 +62,24 @@ extra_rdoc_files:
|
|
52
62
|
- README.rdoc
|
53
63
|
files:
|
54
64
|
- README.rdoc
|
65
|
+
- Rakefile
|
55
66
|
- VERSION.yml
|
56
67
|
- bin/provisional
|
57
|
-
- lib/provisional
|
68
|
+
- lib/provisional.rb
|
58
69
|
- lib/provisional/project.rb
|
59
|
-
- lib/provisional/scm
|
60
70
|
- lib/provisional/scm/git.rb
|
61
71
|
- lib/provisional/scm/github.rb
|
62
|
-
- lib/provisional/
|
72
|
+
- lib/provisional/scm/unfuddle.rb
|
63
73
|
- lib/provisional/templates/viget.rb
|
64
|
-
- lib/provisional.rb
|
65
74
|
- test/test_helper.rb
|
66
|
-
- test/unit
|
67
75
|
- test/unit/git_test.rb
|
68
76
|
- test/unit/github_test.rb
|
69
77
|
- test/unit/project_test.rb
|
78
|
+
- test/unit/unfuddle_test.rb
|
70
79
|
has_rdoc: true
|
71
80
|
homepage: http://github.com/vigetlabs/provisional
|
72
81
|
post_install_message:
|
73
82
|
rdoc_options:
|
74
|
-
- --inline-source
|
75
83
|
- --charset=UTF-8
|
76
84
|
require_paths:
|
77
85
|
- lib
|
@@ -94,5 +102,9 @@ rubygems_version: 1.2.0
|
|
94
102
|
signing_key:
|
95
103
|
specification_version: 3
|
96
104
|
summary: Automation for new Rails Projects
|
97
|
-
test_files:
|
98
|
-
|
105
|
+
test_files:
|
106
|
+
- test/test_helper.rb
|
107
|
+
- test/unit/git_test.rb
|
108
|
+
- test/unit/github_test.rb
|
109
|
+
- test/unit/project_test.rb
|
110
|
+
- test/unit/unfuddle_test.rb
|