travis_github_deployer 0.1.2 → 0.1.3

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.
@@ -10,6 +10,18 @@ class GitCommandLine
10
10
  git("config #{key} '#{value}'")
11
11
  end
12
12
 
13
+ def add(filename)
14
+ git("add #{filename}")
15
+ end
16
+
17
+ def commit(message)
18
+ git("commit -m \"#{message}\"")
19
+ end
20
+
21
+ def push
22
+ git("push")
23
+ end
24
+
13
25
  def config_username(username)
14
26
  config("user.name", username)
15
27
  end
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby -w
2
2
 
3
3
  require 'yaml'
4
+ require 'pathname'
5
+ require 'fileutils'
4
6
 
5
7
  class TravisGithubDeployer
6
8
 
@@ -86,7 +88,7 @@ class TravisGithubDeployer
86
88
 
87
89
  files_to_deploy.each { |source_location, destination_location|
88
90
  source = Pathname.new(source_location)
89
- destination = Pathname.new("github_pages")
91
+ destination = Pathname.new(destination_repository_dir)
90
92
  destination += destination_location.empty? ? source_location : destination_location
91
93
  FileUtils.copy(source, destination)
92
94
  }
@@ -1,4 +1,4 @@
1
1
 
2
2
  module TravisGithubDeployerVersion
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
@@ -10,6 +10,21 @@ describe "simple ruby interface around git command line" do
10
10
  subject.clone("repository", "destination")
11
11
  end
12
12
 
13
+ it "can add files" do
14
+ subject.should_receive(:git).with("add filename")
15
+ subject.add("filename")
16
+ end
17
+
18
+ it "can commit" do
19
+ subject.should_receive(:git).with('commit -m "message"')
20
+ subject.commit("message")
21
+ end
22
+
23
+ it "can push" do
24
+ subject.should_receive(:git).with("push")
25
+ subject.push
26
+ end
27
+
13
28
  it "can do a config" do
14
29
  subject.should_receive(:git).with("config key 'value'")
15
30
  subject.config("key", "value")
@@ -83,19 +83,29 @@ describe "travis github deployer" do
83
83
  context "Prepare the changes that need to be made commit" do
84
84
 
85
85
  it "should be able to copy a file from the root of the source repository to the root of the destination reportistory" do
86
+ subject.should_receive(:destination_repository_dir).and_return("destdir")
86
87
  subject.should_receive(:files_to_deploy).and_return( { "sourcefile" => ""})
87
- FileUtils.should_receive(:copy).with(Pathname.new("sourcefile"), Pathname.new("github_pages/sourcefile"))
88
+ FileUtils.should_receive(:copy).with(Pathname.new("sourcefile"), Pathname.new("destdir/sourcefile"))
88
89
  subject.copy_files_in_destination_repository
89
90
  end
90
91
 
91
92
  it "Should be able to copy multiple files" do
93
+ subject.should_receive(:destination_repository_dir).exactly(2).times.and_return("destdir")
92
94
  subject.should_receive(:files_to_deploy).and_return({ "dir/onefile" => "destonefile", "twofile" => "dir/desttwofile"})
93
- FileUtils.should_receive(:copy).with(Pathname.new("dir/onefile"), Pathname.new("github_pages/destonefile"))
94
- FileUtils.should_receive(:copy).with(Pathname.new("twofile"), Pathname.new("github_pages/dir/desttwofile"))
95
+ FileUtils.should_receive(:copy).with(Pathname.new("dir/onefile"), Pathname.new("destdir/destonefile"))
96
+ FileUtils.should_receive(:copy).with(Pathname.new("twofile"), Pathname.new("destdir/dir/desttwofile"))
95
97
  subject.copy_files_in_destination_repository
96
98
  end
97
99
  end
98
100
 
101
+ context "Actually committing the files" do
102
+
103
+ it "can add, commit and push up the files" do
104
+
105
+ subject.commit_and_push_files
106
+ end
107
+ end
108
+
99
109
  it "can read configuration parameters out of the .travis_github_deployer.yml" do
100
110
  configuration = {
101
111
  "destination_repository" => "https://github.com/cpputest/cpputest.github.io.git",
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: travis_github_deployer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bas Vodde