git-rails 0.1.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.
@@ -0,0 +1,68 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ module GitRailsCommandsInitHelper
4
+ end
5
+
6
+ describe "GitRails::Commands::Init" do
7
+ include GitRailsCommandsInitHelper
8
+ include GitRails::SpecHelpers
9
+
10
+ before(:each) do
11
+ @init = GitRails::Commands::Init.new
12
+ @project = tmppath(:project)
13
+ @git = GitRails::Git.new
14
+ end
15
+
16
+ after(:each) do
17
+ cleanup
18
+ end
19
+
20
+ it "should create a .gitignore file in the current directory" do
21
+ in_tmp_directory(@project) do
22
+ create_file("testfile")
23
+ @init.run(nil, '', false)
24
+ File.exists?(".gitignore").should == true
25
+ @git.status.should match(/new file:/)
26
+ end
27
+ end
28
+
29
+ it "should commit when commit option is provided" do
30
+ in_tmp_directory(@project) do
31
+ create_file("testfile")
32
+ @init.run(nil, 'commit message', true)
33
+ @git.status.should match(/nothing to commit/)
34
+ end
35
+ end
36
+
37
+ it "should not overwrite an existing .gitignore file" do
38
+ in_tmp_directory(@project) do
39
+ create_file(".gitignore")
40
+ @init.run(nil, '', false)
41
+ File.size(".gitignore").should == 0
42
+ end
43
+ end
44
+
45
+ it "should create a tmp/.gitignore file and log/.gitignore" do
46
+ in_tmp_directory(@project) do
47
+ create_file("testfile")
48
+ @init.run(nil)
49
+ File.exists?("log/.gitignore").should == true
50
+ File.exists?("tmp/.gitignore").should == true
51
+ end
52
+ end
53
+
54
+ it "should link to remote repository if provided" do
55
+ origin = in_tmp_directory(tmppath(:origin)) do
56
+ @git.init
57
+ end
58
+ in_tmp_directory(@project) do
59
+ create_file("testfile")
60
+ @init.run(origin, 'commit message', true)
61
+ @git.push("origin", "master")
62
+ end
63
+ in_tmp_directory(origin) do
64
+ @git.log.should match(/commit/)
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ module GitRailsCommandsInstallHelper
4
+ end
5
+
6
+ describe "GitRails::Commands::Install" do
7
+ include GitRailsCommandsInstallHelper
8
+ include GitRails::SpecHelpers
9
+
10
+ before(:each) do
11
+ @init = GitRails::Commands::Init.new
12
+ @install = GitRails::Commands::Install.new
13
+ @project = tmppath(:project)
14
+ @git = GitRails::Git.new
15
+ end
16
+
17
+ after(:each) do
18
+ cleanup
19
+ end
20
+
21
+ it "should download remote url into vendor/plugins and add it as a submodule" do
22
+ plugin = in_tmp_directory(tmppath(:plugin)) do
23
+ create_file("pluginfile")
24
+ @init.run(nil, 'commit message', true)
25
+ end
26
+ project = in_tmp_directory(@project) do
27
+ create_file("testfile")
28
+ @init.run(nil, 'commit message', true)
29
+ @install.run(plugin, "plugin1")
30
+ File.exists?(File.join("vendor", "plugins", "plugin1")).should == true
31
+ File.exists?(File.join("vendor", "plugins", "plugin1", "pluginfile")).should == true
32
+ @git.status.should match(/Changes to be committed/)
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ module GitRailsCommandsUpdateHelper
4
+ end
5
+
6
+ describe "GitRails::Commands::Update" do
7
+ include GitRailsCommandsUpdateHelper
8
+ include GitRails::SpecHelpers
9
+
10
+ before(:each) do
11
+ @init = GitRails::Commands::Init.new
12
+ @install = GitRails::Commands::Install.new
13
+ @update = GitRails::Commands::Update.new
14
+ @project = tmppath(:project)
15
+ @git = GitRails::Git.new
16
+ end
17
+
18
+ after(:each) do
19
+ cleanup
20
+ end
21
+
22
+ it "should update changes to a plugin file" do
23
+ plugin = in_tmp_directory(tmppath(:plugin)) do
24
+ create_file("pluginfile")
25
+ @init.run(nil, 'commit message', true)
26
+ end
27
+ in_tmp_directory(@project) do
28
+ create_file("testfile")
29
+ @init.run(nil, 'commit message', true)
30
+ @install.run(plugin, "plugin1")
31
+ File.exists?(File.join("vendor", "plugins", "plugin1")).should == true
32
+ File.exists?(File.join("vendor", "plugins", "plugin1", "pluginfile")).should == true
33
+ @git.commit_all('', {"-m" => "commit message"})
34
+ end
35
+
36
+ in_tmp_directory(plugin) do
37
+ file = File.new("pluginfile", "w")
38
+ file<< "make some changes\n"
39
+ file.close
40
+ @git.commit_all('', {"-m" => "commit change to pluginfile"})
41
+ end
42
+
43
+ in_tmp_directory(@project) do
44
+ @update.run("plugin1")
45
+ IO.read(File.join("vendor", "plugins", "plugin1", "pluginfile")).should match(/changes/)
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "GitRails::Command" do
4
+ before(:each) do
5
+ end
6
+
7
+ it "should exist" do
8
+ GitRails::Command.new
9
+ end
10
+
11
+ end
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "GitRails::Git" do
4
+ include GitRails::SpecHelpers
5
+
6
+ before(:each) do
7
+ @git = GitRails::Git.new
8
+ @project = tmppath(:project)
9
+ end
10
+
11
+ after(:each) do
12
+ cleanup
13
+ end
14
+
15
+ it "should create a .git directory when calling init" do
16
+ in_tmp_directory(@project) do
17
+ File.exists?(".git").should == false
18
+ @git.init
19
+ File.exists?(".git").should == true
20
+ end
21
+ end
22
+
23
+ it "should add files in local project" do
24
+ in_tmp_directory(@project) do
25
+ create_file("test")
26
+ @git.init
27
+ @git.add(".")
28
+ @git.status.should match(/new file: test/)
29
+ end
30
+ end
31
+
32
+ it "should commit" do
33
+ in_tmp_directory(@project) do
34
+ create_file("testfile")
35
+ @git.init
36
+ @git.add(".")
37
+ output = @git.commit_all('', {"-m" => "commit message"})
38
+ output.should match(/Created initial commit/)
39
+ output.should match(/testfile/)
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ describe "GitRails::Git::SubModule" do
46
+ include GitRails::SpecHelpers
47
+
48
+ before(:each) do
49
+ @git = GitRails::Git.new
50
+ @git_sub_module = GitRails::Git::SubModule.new
51
+ @project = tmppath(:project)
52
+ end
53
+
54
+ after(:each) do
55
+ cleanup
56
+ end
57
+
58
+ it "should add a module and initialize .gitmodules" do
59
+ sub_project = in_tmp_directory(tmppath(:sub_project)) do
60
+ create_file("testfile")
61
+ @git.init
62
+ @git.add(".")
63
+ @git.commit_all('', {"-m" => "commit message"})
64
+ end
65
+ in_tmp_directory(@project) do
66
+ @git.init
67
+ @git_sub_module.add(sub_project, "./sub_project")
68
+ @git_sub_module.init
69
+ @git_sub_module.update
70
+ File.exists?(".gitmodules").should == true
71
+ File.exists?("sub_project/testfile").should == true
72
+ end
73
+ end
74
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format specdoc
3
+ --loadby mtime
@@ -0,0 +1,64 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ #gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ dir = File.dirname(__FILE__)
10
+ lib_path = File.expand_path("#{dir}/../lib")
11
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
12
+
13
+ require 'git_rails'
14
+
15
+ require "logger"
16
+ require "fileutils"
17
+
18
+ $logger = Logger.new($stderr)
19
+ $logger.level = Logger::INFO unless $DEBUG
20
+
21
+ module GitRails
22
+ module SpecHelpers
23
+ def logger
24
+ $logger
25
+ end
26
+
27
+ def create_file(path)
28
+ file = File.new(path, "w")
29
+ file.close
30
+ file
31
+ end
32
+
33
+ def tmppath(*paths)
34
+ parts = [File.dirname(__FILE__), "tmp"]
35
+ parts << (@root_time ||= Time.now.to_i.to_s)
36
+ parts += paths
37
+ # parts << rand().to_s.split(".").last
38
+ parts.collect! {|path| path.to_s}
39
+ path = File.join(*parts)
40
+ attempts = 10
41
+ while File.exists?(path)
42
+ path.succ!
43
+ attempts -= 1
44
+ raise "Unable to find a good temp pathname: #{path.inspect}" if attempts.zero?
45
+ end
46
+
47
+ File.expand_path(path)
48
+ end
49
+
50
+ def cleanup
51
+ path = File.expand_path(File.join(File.dirname(__FILE__), "tmp"))
52
+ logger.debug {"Removing #{path.inspect}"}
53
+ FileUtils.rm_rf(path)
54
+ end
55
+
56
+ def in_tmp_directory(path)
57
+ FileUtils.mkdir_p(path)
58
+ Dir.chdir(path) do
59
+ yield
60
+ end
61
+ path
62
+ end
63
+ end
64
+ end
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/*_spec.rb','spec/commands/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pascal Belloncle (nano RAILS)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANwc3Ex
14
+ GTAXBgoJkiaJk/IsZAEZFgluYW5vcmFpbHMxEzARBgoJkiaJk/IsZAEZFgNjb20w
15
+ HhcNMDgwMjA0MDgzOTU3WhcNMDkwMjAzMDgzOTU3WjA+MQwwCgYDVQQDDANwc3Ex
16
+ GTAXBgoJkiaJk/IsZAEZFgluYW5vcmFpbHMxEzARBgoJkiaJk/IsZAEZFgNjb20w
17
+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9ArQhN6DW+QBDgRR4dYn1
18
+ F6Y4O4Gmetew3JHLuNHPuTHZxYoallfj+Kq/9GBh+gaxCWECem621M4DcHug2qzR
19
+ y28ojmdCwIs3vVp8HSVpPgsTCYU1hTazcf6m1n1GJzK7/Cn5tVpKtmpggMg3KRet
20
+ B/gLZ7V+Wmobwc9hMOq7M1EJWGGu6RO4O3AVATJbhJJrxik7fudIIxVsQXHXfSbM
21
+ 4I+ckDg8rXQFLT05ZaeXluykbgpaBbqukEkmXdcRq7r+xHQiifyukW91/hOcI0VI
22
+ uymCxquaoBe6BbJyCGAqS/LAx9ghUeauiupXk7MQ2SJZR52EsAgsLwk6S6sdnmVl
23
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQqXXgt
24
+ NiMYFw60w5BVh9ZfZ35vYzANBgkqhkiG9w0BAQUFAAOCAQEABp1bJbQA89xE2eUQ
25
+ P70MsQxPARP9WDZ3K8/U3iwWxFBwqBkN3rA1huu9ffDSGKuReLt1peHrITUuTGwX
26
+ XH1kvHzCs+GMxWYvvz07NNhM+Y+mAgqpKrZnLhoWrrQyz0TEUpCmoUgDzc1evn6V
27
+ 1pyu7zUQ6TFX20kYzOupVAwLfhaUv9Smj1YI/YI8lkqNJqpJLbm6Ib0Gr/sLkY/E
28
+ o1mnIpaqkxNMBS+u8/ToejKdRYOtoXb5134I8WSbkVH2mTHlVgLPVRR2uqxxyQTD
29
+ bYaWAJcLlC+oPUfD5uc2DkmnjUyAWSIEVQcL20dwU8WbYWp/oFmiRpvgYk4LLFs2
30
+ TCvXyw==
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2008-02-04 00:00:00 -08:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.0
44
+ version:
45
+ description: "== DESCRIPTION: Tools to help using git with rails == FEATURES/PROBLEMS: * run specs for non committed files * install plugins from git source as git modules * install plugins from svn source as git modules"
46
+ email: psq@nanorails.com
47
+ executables:
48
+ - git-rails
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - History.txt
53
+ - Manifest.txt
54
+ - README.txt
55
+ files:
56
+ - History.txt
57
+ - Manifest.txt
58
+ - README.txt
59
+ - Rakefile
60
+ - bin/git-rails
61
+ - lib/git-rails/commands.rb
62
+ - lib/git-rails/commands/init.rb
63
+ - lib/git-rails/commands/install.rb
64
+ - lib/git-rails/commands/update.rb
65
+ - lib/git-rails/exceptions.rb
66
+ - lib/git-rails/git.rb
67
+ - lib/git-rails/version.rb
68
+ - lib/git_rails.rb
69
+ - setup.rb
70
+ - spec/commands/init_spec.rb
71
+ - spec/commands/install_spec.rb
72
+ - spec/commands/update_spec.rb
73
+ - spec/git_rails_commands_spec.rb
74
+ - spec/git_rails_git_spec.rb
75
+ - spec/spec.opts
76
+ - spec/spec_helper.rb
77
+ - tasks/rspec.rake
78
+ has_rdoc: true
79
+ homepage:
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --main
83
+ - README.txt
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ requirements: []
99
+
100
+ rubyforge_project: git-rails
101
+ rubygems_version: 1.0.0
102
+ signing_key:
103
+ specification_version: 2
104
+ summary: Tools to make using git with rails a breeze
105
+ test_files: []
106
+