releasy 0.2.0 → 0.2.2

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.
Files changed (60) hide show
  1. data/.yardopts +3 -1
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +114 -41
  4. data/Rakefile +1 -1
  5. data/bin/7z_sfx_LICENSE.txt +56 -0
  6. data/bin/7za.exe +0 -0
  7. data/bin/7za_exe_LICENSE.txt +29 -0
  8. data/lib/releasy.rb +4 -1
  9. data/lib/releasy/builders/builder.rb +14 -6
  10. data/lib/releasy/builders/ocra_builder.rb +4 -2
  11. data/lib/releasy/builders/osx_app.rb +18 -6
  12. data/lib/releasy/builders/source.rb +9 -2
  13. data/lib/releasy/builders/windows_folder.rb +12 -3
  14. data/lib/releasy/builders/windows_installer.rb +2 -3
  15. data/lib/releasy/builders/windows_standalone.rb +13 -3
  16. data/lib/releasy/builders/windows_wrapped.rb +14 -4
  17. data/lib/releasy/cli/install_sfx.rb +1 -1
  18. data/lib/releasy/deployers.rb +1 -1
  19. data/lib/releasy/deployers/deployer.rb +22 -1
  20. data/lib/releasy/deployers/github.rb +31 -124
  21. data/lib/releasy/deployers/local.rb +55 -0
  22. data/lib/releasy/deployers/rsync.rb +59 -0
  23. data/lib/releasy/mixins/has_packagers.rb +1 -1
  24. data/lib/releasy/mixins/utilities.rb +34 -0
  25. data/lib/releasy/packagers/dmg.rb +17 -0
  26. data/lib/releasy/packagers/exe.rb +18 -1
  27. data/lib/releasy/packagers/packager.rb +22 -6
  28. data/lib/releasy/packagers/seven_zip.rb +17 -0
  29. data/lib/releasy/packagers/tar_bzip2.rb +19 -0
  30. data/lib/releasy/packagers/tar_gzip.rb +19 -0
  31. data/lib/releasy/packagers/tar_packager.rb +2 -1
  32. data/lib/releasy/packagers/zip.rb +17 -0
  33. data/lib/releasy/project.rb +45 -4
  34. data/lib/releasy/version.rb +1 -1
  35. data/releasy.gemspec +1 -1
  36. data/test/releasy/builders/data/Main.rb +3 -2
  37. data/test/releasy/builders/helpers/builder_helper.rb +35 -0
  38. data/test/releasy/builders/helpers/ocra_builder_helper.rb +31 -0
  39. data/test/releasy/builders/helpers/windows_builder_helper.rb +25 -0
  40. data/test/releasy/builders/osx_app_test.rb +6 -4
  41. data/test/releasy/builders/source_test.rb +7 -4
  42. data/test/releasy/builders/windows_folder_test.rb +3 -1
  43. data/test/releasy/builders/windows_installer_test.rb +6 -4
  44. data/test/releasy/builders/windows_standalone_test.rb +6 -4
  45. data/test/releasy/builders/windows_wrapped_test.rb +3 -1
  46. data/test/releasy/cli/install_sfx_test.rb +1 -1
  47. data/test/releasy/deployers/github_test.rb +30 -32
  48. data/test/releasy/deployers/local_test.rb +93 -0
  49. data/test/releasy/deployers/rsync_test.rb +55 -0
  50. data/test/releasy/integration/source_test.rb +6 -6
  51. data/test/releasy/mixins/utilities_test.rb +50 -0
  52. data/test/releasy/packagers/packager_test.rb +79 -0
  53. data/test/releasy/packagers_test.rb +12 -6
  54. data/test/releasy/project_test.rb +5 -5
  55. data/test/teststrap.rb +6 -0
  56. data/test/yard_test.rb +1 -1
  57. metadata +40 -28
  58. data/lib/releasy/mixins/exec.rb +0 -14
  59. data/test/releasy/builders/ocra_builder_test.rb +0 -37
  60. data/test/releasy/builders/windows_builder_test.rb +0 -26
@@ -1,3 +1,3 @@
1
1
  module Releasy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -29,7 +29,7 @@ END
29
29
  s.add_runtime_dependency('rake', '~> 0.9.2.2')
30
30
  s.add_runtime_dependency('cri', '~> 2.1.0')
31
31
  s.add_runtime_dependency('thor', '~> 0.14.6') # Only needed in Ruby 1.8, since it provides HashWithIndifferentAccess.
32
- s.add_runtime_dependency('net-github-upload', '~> 0.0.7')
32
+ s.add_runtime_dependency('net-github-upload', '~> 0.0.8')
33
33
 
34
34
  s.add_development_dependency('riot', '~> 0.12.5')
35
35
  s.add_development_dependency('rr', '~> 1.0.4')
@@ -6,7 +6,8 @@ OSX_EXECUTABLE_FOLDER = File.expand_path("../../..", __FILE__)
6
6
 
7
7
  # Really hacky fudge-fix for something oddly missing in the .app.
8
8
  class Encoding
9
- UTF_7 = UTF_16BE = UTF_16LE = UTF_32BE = UTF_32LE = Encoding.list.first
9
+ BINARY = UTF_7 = UTF_16BE = UTF_16LE = UTF_32BE = UTF_32LE = Encoding.list.first
10
10
  end
11
11
 
12
- load 'application/bin/test_app'
12
+ Dir.chdir 'application'
13
+ load 'bin/test_app'
@@ -0,0 +1,35 @@
1
+ require File.expand_path("helper", File.dirname(__FILE__))
2
+
3
+ def acts_like_a_builder
4
+ context Releasy::Builders::Builder do
5
+ asserts_topic.kind_of Releasy::Builders::Builder
6
+
7
+ asserts_topic.respond_to :setup
8
+ asserts_topic.respond_to :task_group
9
+ asserts_topic.respond_to :folder
10
+
11
+ asserts(:type).equals { topic.class::TYPE }
12
+ asserts(:suffix).equals { topic.class::DEFAULT_FOLDER_SUFFIX }
13
+ asserts("valid_for_platform? returns a Boolean") { [true, false].include? topic.valid_for_platform? }
14
+
15
+ asserts(:project).is_a? Releasy::Project
16
+ asserts(:suffix).is_a? String
17
+
18
+ asserts(:suffix=, 5).raises TypeError
19
+
20
+ context "#suffix=" do
21
+ hookup { topic.suffix = "hello" }
22
+ asserts(:suffix).equals "hello"
23
+ end
24
+
25
+ context "#copy_files_relative" do
26
+ should "copy files to their relative directories" do
27
+ mock(topic).mkdir_p "d/.", :verbose => false
28
+ mock(topic).cp "a", "d/.", :verbose => false
29
+ mock(topic).mkdir_p "d/b", :verbose => false
30
+ mock(topic).cp "b/c", "d/b", :verbose => false
31
+ topic.send :copy_files_relative, %w[a b/c], 'd'
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path("windows_builder_helper", File.dirname(__FILE__))
2
+
3
+ def acts_like_an_ocra_builder
4
+ acts_like_a_windows_builder
5
+
6
+ context Releasy::Builders::OcraBuilder do
7
+ asserts_topic.kind_of Releasy::Builders::OcraBuilder
8
+ asserts(:ocra_parameters).equals ""
9
+ asserts(:icon).nil
10
+ asserts("setting incorrect icon") { topic.icon = "frog.png" }.raises ArgumentError, /icon must be a .ico file/
11
+ asserts(:ocra_command).raises Releasy::ConfigError, /Unless the executable file extension is .rbw or .rb, then #executable_type must be explicitly :windows or :console/
12
+
13
+ context "#icon=" do
14
+ hookup { topic.icon = "icon.ico" }
15
+ asserts(:icon).equals "icon.ico"
16
+ end
17
+
18
+ context "#ocra_command" do
19
+ hookup do
20
+ topic.exclude_encoding
21
+ topic.ocra_parameters = "--wobble"
22
+ topic.project.executable = source_files.first
23
+ topic.executable_type = :console
24
+ topic.icon = "icon.ico"
25
+ end
26
+
27
+ helper(:command) { %[ocra "bin/test_app" --console --no-enc --wobble --icon "icon.ico" "lib/test_app.rb" "lib/test_app/stuff.rb" "README.txt" "LICENSE.txt" "Gemfile.lock" "Gemfile"] }
28
+ asserts(:ocra_command).equals { %[bundle exec #{command}] }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path("builder_helper", File.dirname(__FILE__))
2
+
3
+ def acts_like_a_windows_builder
4
+ acts_like_a_builder
5
+
6
+ context Releasy::Builders::WindowsBuilder do
7
+ asserts_topic.kind_of Releasy::Builders::WindowsBuilder
8
+ context "#executable_type undefined and Project#executable doesn't have meaningful extension" do
9
+ hookup { topic.project.executable = "fred" }
10
+ asserts(:effective_executable_type).raises Releasy::ConfigError, /Unless the executable file extension is .rbw or .rb, then #executable_type must be explicitly :windows or :console/
11
+ end
12
+
13
+ context "valid" do
14
+ hookup { topic.executable_type = :console }
15
+
16
+ asserts(:effective_executable_type).equals :console
17
+ asserts(:encoding_excluded?).equals false
18
+
19
+ context "exclude_encoding" do
20
+ hookup { topic.exclude_encoding }
21
+ asserts(:encoding_excluded?).equals true
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path("helpers/helper", File.dirname(__FILE__))
1
+ require File.expand_path("helpers/builder_helper", File.dirname(__FILE__))
2
2
 
3
3
  folder = File.join(output_path, "test_app_0_1_OSX")
4
4
  app_folder = File.join(folder, "Test App.app")
@@ -17,6 +17,8 @@ if osx_app_wrapper
17
17
  Dir.chdir project_path
18
18
  end
19
19
 
20
+ acts_like_a_builder
21
+
20
22
  asserts(:folder_suffix).equals "OSX"
21
23
  asserts(:encoding_excluded?).equals false
22
24
  asserts(:icon=, "test_app.ico").raises ArgumentError, /icon must be a .icns file/
@@ -69,9 +71,9 @@ if osx_app_wrapper
69
71
  context "tasks" do
70
72
  tasks = [
71
73
  [ :Task, "build:osx:app", [folder] ],
72
- [ :FileCreationTask, '..', [] ], # byproduct of using #directory
73
- [ :FileCreationTask, output_path, [] ], # byproduct of using #directory
74
- [ :FileCreationTask, folder, source_files + [osx_app_wrapper]],
74
+ [ :FileTask, '..', [] ], # byproduct of using #directory
75
+ [ :FileTask, output_path, [] ], # byproduct of using #directory
76
+ [ :FileTask, folder, source_files + [osx_app_wrapper]],
75
77
  ]
76
78
 
77
79
  test_tasks tasks
@@ -1,4 +1,5 @@
1
- require File.expand_path("helpers/helper", File.dirname(__FILE__))
1
+ require File.expand_path("helpers/builder_helper", File.dirname(__FILE__))
2
+
2
3
 
3
4
  folder = File.join(output_path, "test_app_0_1_SOURCE")
4
5
  context Releasy::Builders::Source do
@@ -13,6 +14,8 @@ context Releasy::Builders::Source do
13
14
  Dir.chdir project_path
14
15
  end
15
16
 
17
+ acts_like_a_builder
18
+
16
19
  context "valid" do
17
20
  hookup do
18
21
 
@@ -25,9 +28,9 @@ context Releasy::Builders::Source do
25
28
  context "tasks" do
26
29
  tasks = [
27
30
  [ :Task, "build:source", [folder] ],
28
- [ :FileCreationTask, '..', [] ], # byproduct of using #directory
29
- [ :FileCreationTask, output_path, [] ], # byproduct of using #directory
30
- [ :FileCreationTask, folder, source_files ],
31
+ [ :FileTask, '..', [] ], # byproduct of using #directory
32
+ [ :FileTask, output_path, [] ], # byproduct of using #directory
33
+ [ :FileTask, folder, source_files ],
31
34
  ]
32
35
 
33
36
  test_tasks tasks
@@ -1,4 +1,4 @@
1
- require File.expand_path("helpers/helper", File.dirname(__FILE__))
1
+ require File.expand_path("helpers/ocra_builder_helper", File.dirname(__FILE__))
2
2
 
3
3
  folder = File.join(output_path, "test_app_0_1_WIN32")
4
4
 
@@ -12,6 +12,8 @@ context Releasy::Builders::WindowsFolder do
12
12
 
13
13
  hookup { Dir.chdir project_path }
14
14
 
15
+ acts_like_an_ocra_builder
16
+
15
17
  context "valid" do
16
18
  if Gem.win_platform?
17
19
  context "on Windows" do
@@ -1,4 +1,4 @@
1
- require File.expand_path("helpers/helper", File.dirname(__FILE__))
1
+ require File.expand_path("helpers/ocra_builder_helper", File.dirname(__FILE__))
2
2
 
3
3
  folder = File.join(output_path, "test_app_0_1_WIN32_INSTALLER")
4
4
 
@@ -12,6 +12,8 @@ context Releasy::Builders::WindowsInstaller do
12
12
 
13
13
  hookup { Dir.chdir project_path }
14
14
 
15
+ acts_like_an_ocra_builder
16
+
15
17
  context "valid" do
16
18
  if Gem.win_platform?
17
19
  context "on Windows" do
@@ -36,9 +38,9 @@ context Releasy::Builders::WindowsInstaller do
36
38
  context "tasks" do
37
39
  tasks = [
38
40
  [ :Task, "build:windows:installer", [folder] ],
39
- [ :FileCreationTask, '..', [] ], # byproduct of using #directory
40
- [ :FileCreationTask, output_path, [] ], # byproduct of using #directory
41
- [ :FileCreationTask, folder, source_files ],
41
+ [ :FileTask, '..', [] ], # byproduct of using #directory
42
+ [ :FileTask, output_path, [] ], # byproduct of using #directory
43
+ [ :FileTask, folder, source_files ],
42
44
  ]
43
45
 
44
46
  test_tasks tasks
@@ -1,4 +1,4 @@
1
- require File.expand_path("helpers/helper", File.dirname(__FILE__))
1
+ require File.expand_path("helpers/ocra_builder_helper", File.dirname(__FILE__))
2
2
 
3
3
  folder = File.join(output_path, "test_app_0_1_WIN32_EXE")
4
4
 
@@ -12,6 +12,8 @@ context Releasy::Builders::WindowsStandalone do
12
12
 
13
13
  hookup { Dir.chdir project_path }
14
14
 
15
+ acts_like_an_ocra_builder
16
+
15
17
  context "valid" do
16
18
  if Gem.win_platform?
17
19
  context "on Windows" do
@@ -31,9 +33,9 @@ context Releasy::Builders::WindowsStandalone do
31
33
  context "tasks" do
32
34
  tasks = [
33
35
  [ :Task, "build:windows:standalone", [folder] ],
34
- [ :FileCreationTask, '..', [] ], # byproduct of using #directory
35
- [ :FileCreationTask, output_path, [] ], # byproduct of using #directory
36
- [ :FileCreationTask, folder, source_files ],
36
+ [ :FileTask, '..', [] ], # byproduct of using #directory
37
+ [ :FileTask, output_path, [] ], # byproduct of using #directory
38
+ [ :FileTask, folder, source_files ],
37
39
  ]
38
40
 
39
41
  test_tasks tasks
@@ -1,4 +1,4 @@
1
- require File.expand_path("helpers/helper", File.dirname(__FILE__))
1
+ require File.expand_path("helpers/windows_builder_helper", File.dirname(__FILE__))
2
2
 
3
3
  Dir[File.expand_path("wrappers/ruby-*.7z", $original_path)].each do |path_to_ruby_dist|
4
4
  ruby_version = path_to_ruby_dist[/\d\.\d\.\d-p\d+/]
@@ -17,6 +17,8 @@ Dir[File.expand_path("wrappers/ruby-*.7z", $original_path)].each do |path_to_rub
17
17
  Dir.chdir project_path
18
18
  end
19
19
 
20
+ acts_like_a_windows_builder
21
+
20
22
  asserts(:wrapper).nil
21
23
  asserts(:folder_suffix).equals "WIN32"
22
24
  asserts(:generate_tasks).raises Releasy::ConfigError, /wrapper not set/
@@ -79,7 +79,7 @@ context "releasy install-sfx" do
79
79
  stub(File).exists?("/usr/lib/p7zip/7z.sfx").returns false
80
80
  stub(FileUtils).cp(File.expand_path("bin/7z.sfx"), "/usr/lib/p7zip", :verbose => true) { raise Errno::ENOENT }
81
81
  any_instance_of(Cri::CommandDSL) do |o|
82
- mock(o).exec(%[sudo cp "#{File.expand_path('bin/7z.sfx')}" "/usr/lib/p7zip"]) do
82
+ mock(o).system(%[sudo cp "#{File.expand_path('bin/7z.sfx')}" "/usr/lib/p7zip"]) do
83
83
  stub(File).exists?("/usr/lib/p7zip/7z.sfx").returns true
84
84
  end
85
85
  end
@@ -3,10 +3,8 @@ require 'net/github-upload' # Because this isn't otherwise loaded until it is ne
3
3
 
4
4
  context Releasy::Deployers::Github do
5
5
  setup do
6
- any_instance_of Releasy::Deployers::Github do |github|
7
- stub(github, :`).with("git config github.user").returns "test_user"
8
- stub(github, :`).with("git config github.token").returns "0" * 32
9
- end
6
+ stub(Kernel, :`).with("git config github.user").returns "test_user"
7
+ stub(Kernel, :`).with("git config github.token").returns "0" * 32
10
8
 
11
9
  Releasy::Deployers::Github.new new_project
12
10
  end
@@ -20,15 +18,14 @@ context Releasy::Deployers::Github do
20
18
  Dir.chdir project_path
21
19
  end
22
20
 
21
+ asserts(:type).equals :github
23
22
  asserts(:user).equals "test_user"
24
23
  asserts(:token).equals "0" * 32
25
24
  asserts(:description).equals "Test App 0.1"
26
25
 
27
26
  context "repository not configured" do
28
27
  setup do
29
- any_instance_of Releasy::Deployers::Github do |github|
30
- mock(github, :`).with("git config remote.origin.url").returns { raise Errno::ENOENT }
31
- end
28
+ mock(Kernel, :`).with("git config remote.origin.url").returns { raise Errno::ENOENT }
32
29
 
33
30
  Releasy::Deployers::Github.new new_project
34
31
  end
@@ -38,9 +35,7 @@ context Releasy::Deployers::Github do
38
35
 
39
36
  context "repository configured" do
40
37
  setup do
41
- any_instance_of Releasy::Deployers::Github do |github|
42
- mock(github, :`).with("git config remote.origin.url").returns "git@github.com:test_user/test-app.git"
43
- end
38
+ mock(Kernel, :`).with("git config remote.origin.url").returns "git@github.com:test_user/test-app.git"
44
39
 
45
40
  Releasy::Deployers::Github.new new_project
46
41
  end
@@ -50,10 +45,8 @@ context Releasy::Deployers::Github do
50
45
 
51
46
  context "user not configured" do
52
47
  setup do
53
- any_instance_of Releasy::Deployers::Github do |github|
54
- mock(github, :`).with("git config github.user").returns { raise Errno::ENOENT }
55
- mock(github, :`).with("git config github.token").returns "0" * 32
56
- end
48
+ mock(Kernel, :`).with("git config github.user").returns { raise Errno::ENOENT }
49
+ mock(Kernel, :`).with("git config github.token").returns "0" * 32
57
50
 
58
51
  Releasy::Deployers::Github.new new_project
59
52
  end
@@ -65,10 +58,9 @@ context Releasy::Deployers::Github do
65
58
 
66
59
  context "token not configured" do
67
60
  setup do
68
- any_instance_of Releasy::Deployers::Github do |github|
69
- mock(github, :`).with("git config github.user").returns "test_user"
70
- mock(github, :`).with("git config github.token").returns { raise Errno::ENOENT }
71
- end
61
+ mock(Kernel, :`).with("git config github.user").returns "test_user"
62
+ mock(Kernel, :`).with("git config github.token").returns { raise Errno::ENOENT }
63
+
72
64
  Releasy::Deployers::Github.new new_project
73
65
  end
74
66
 
@@ -89,12 +81,9 @@ context Releasy::Deployers::Github do
89
81
  end
90
82
 
91
83
  context "#deploy" do
92
- helper(:stub_file_size) { stub(File).size("file.zip").returns 1000 }
93
-
94
- should "expect an Net::GitHub::Upload to be created and used to upload" do
95
- stub_file_size
84
+ should "upload the file if it doesn't exist on the server" do
96
85
  mock(Net::GitHub::Upload).new :login => "test_user", :token => "0" * 32 do
97
- mock!.upload_async :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => false, :upload_timeout => 3600
86
+ mock!.upload :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => false, :upload_timeout => 3600
98
87
  end
99
88
 
100
89
  topic.send :deploy, "file.zip"
@@ -102,25 +91,34 @@ context Releasy::Deployers::Github do
102
91
  true
103
92
  end
104
93
 
105
- should "expect an Net::GitHub::Upload to be created and exit (not forcing replacement and file already exists)" do
106
- stub_file_size
94
+ should "give a warning if the file already exists and not in replacement mode" do
107
95
  mock(Net::GitHub::Upload).new :login => "test_user", :token => "0" * 32 do
108
- mock!.upload_async :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => false, :upload_timeout => 3600 do
109
- raise "file already exists"
96
+ mock!.upload :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => false, :upload_timeout => 3600 do
97
+ raise "file 'file.zip' is already uploaded. please try different name"
110
98
  end
111
99
  end
112
-
113
- mock(topic).exit(1)
100
+ mock(topic).warn "Skipping 'file.zip' as it is already uploaded. Use #replace! to force uploading"
114
101
 
115
102
  topic.send :deploy, "file.zip"
116
103
 
117
104
  true
118
105
  end
119
106
 
120
- should "expect an Net::GitHub::Upload to be created and used to upload (forcing replacement)" do
121
- stub_file_size
107
+ asserts "errors other than file already exists" do
108
+ mock(Net::GitHub::Upload).new :login => "test_user", :token => "0" * 32 do
109
+ mock!.upload :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => false, :upload_timeout => 3600 do
110
+ raise "something else happened"
111
+ end
112
+ end
113
+
114
+ dont_allow(topic).warn anything
115
+
116
+ topic.send :deploy, "file.zip"
117
+ end.raises RuntimeError, "something else happened"
118
+
119
+ should "upload the file if it exists on the server and in replacement mode" do
122
120
  mock(Net::GitHub::Upload).new :login => "test_user", :token => "0" * 32 do
123
- mock!.upload_async :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => true, :upload_timeout => 3600
121
+ mock!.upload :repos => "test_app", :file => "file.zip", :description => "Test App 0.1", :replace => true, :upload_timeout => 3600
124
122
  end
125
123
 
126
124
  topic.replace!
@@ -0,0 +1,93 @@
1
+ require File.expand_path("helpers/helper", File.dirname(__FILE__))
2
+
3
+ context Releasy::Deployers::Local do
4
+ setup do
5
+ Releasy::Deployers::Local.new new_project
6
+ end
7
+
8
+ teardown do
9
+ Dir.chdir $original_path
10
+ Rake::Task.clear
11
+ end
12
+
13
+ hookup do
14
+ Dir.chdir project_path
15
+ end
16
+
17
+ asserts(:type).equals :local
18
+ asserts(:path).nil
19
+ asserts(:path=, 5).raises TypeError, /path must be a String/
20
+
21
+ context "#path=" do
22
+ hookup { topic.path = "fish" }
23
+ asserts(:path).equals "fish"
24
+ end
25
+
26
+ context "valid" do
27
+ context "#generate_tasks" do
28
+ hookup { topic.send :generate_tasks, "source:7z", "SOURCE.7z", ".7z" }
29
+ tasks = [
30
+ [ :Task, "deploy:source:7z:local", %w[package:source:7z] ],
31
+ ]
32
+
33
+ test_tasks tasks
34
+ end
35
+
36
+ context "#deploy" do
37
+ context "without #path" do
38
+ asserts(:deploy, "file.zip").raises Releasy::ConfigError, /#path must be set/
39
+ end
40
+
41
+ context "valid" do
42
+ hookup { topic.path = "fish" }
43
+
44
+ should "create directory and copy file if directory doesn't exist" do
45
+ stub(File).exists?("fish").returns false
46
+ stub(File).exists?("fish/file.zip").returns false
47
+
48
+ mock(topic).mkdir_p("fish", :verbose => false)
49
+ mock(topic).cp("file.zip", "fish", :verbose => false, :force => false)
50
+ topic.send :deploy, "file.zip"
51
+
52
+ true
53
+ end
54
+
55
+ should "copy file to directory if directory exists" do
56
+ stub(File).exists?("fish").returns true
57
+ stub(File).exists?("fish/file.zip").returns false
58
+
59
+ mock(topic).cp("file.zip", "fish", :verbose => false, :force => false)
60
+ topic.send :deploy, "file.zip"
61
+
62
+ true
63
+ end
64
+
65
+ should "copy file forcefully if destination file is older" do
66
+ stub(File).exists?("fish").returns true
67
+ stub(File).exists?("fish/file.zip").returns true
68
+ stub(File).ctime("fish/file.zip").returns 0
69
+ stub(File).ctime("file.zip").returns 1
70
+
71
+ mock(topic).cp("file.zip", "fish", :verbose => false, :force => true)
72
+ topic.send :deploy, "file.zip"
73
+
74
+ true
75
+ end
76
+
77
+ should "not copy file if destination file is not older" do
78
+ stub(File).exists?("fish").returns true
79
+ stub(File).exists?("fish/file.zip").returns true
80
+ stub(File).ctime("fish/file.zip").returns 1
81
+ stub(File).ctime("file.zip").returns 1
82
+
83
+ dont_allow(topic).cp
84
+ mock(topic).warn "Skipping 'file.zip' because it already exists in 'fish'"
85
+ topic.send :deploy, "file.zip"
86
+
87
+ true
88
+ end
89
+ end
90
+ end
91
+
92
+ end
93
+ end