|
2 | 2 |
|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 |
| -RSpec.describe Kanrisuru::Core::Archive do |
6 |
| - TestHosts.each_os do |os_name| |
| 5 | +TestHosts.each_os do |os_name, host_json, spec_dir| |
| 6 | + RSpec.describe Kanrisuru::Core::Archive do |
7 | 7 | context "with #{os_name}" do
|
8 | 8 | before(:all) do
|
9 |
| - host_json = TestHosts.host(os_name) |
10 | 9 | host = Kanrisuru::Remote::Host.new(
|
11 | 10 | host: host_json['hostname'],
|
12 | 11 | username: host_json['username'],
|
13 | 12 | keys: [host_json['ssh_key']]
|
14 | 13 | )
|
15 | 14 |
|
16 |
| - host.mkdir("#{host_json['home']}/.kanrisuru_spec_files", silent: true) |
| 15 | + host.mkdir(spec_dir, silent: true) |
17 | 16 | host.disconnect
|
18 | 17 | end
|
19 | 18 |
|
20 |
| - let(:host_json) { TestHosts.host(os_name) } |
21 | 19 | let(:host) do
|
22 | 20 | Kanrisuru::Remote::Host.new(
|
23 | 21 | host: host_json['hostname'],
|
|
26 | 24 | )
|
27 | 25 | end
|
28 | 26 |
|
29 |
| - let(:spec_dir) { "#{host_json['home']}/.kanrisuru_spec_files" } |
30 |
| - |
31 | 27 | after do
|
32 | 28 | host.disconnect
|
33 | 29 | end
|
34 | 30 |
|
35 | 31 | after(:all) do
|
36 |
| - host_json = TestHosts.host(os_name) |
37 | 32 | host = Kanrisuru::Remote::Host.new(
|
38 | 33 | host: host_json['hostname'],
|
39 | 34 | username: host_json['username'],
|
40 | 35 | keys: [host_json['ssh_key']]
|
41 | 36 | )
|
42 | 37 |
|
43 |
| - host.rmdir("#{host_json['home']}/.kanrisuru_spec_files") |
44 |
| - host.rmdir("#{host_json['home']}/extract-tar-files") if host.dir?("#{host_json['home']}/extract-tar-files") |
| 38 | + host.rmdir(spec_dir) |
| 39 | + host.rmdir("#{spec_dir}/extract-tar-files") if host.dir?("#{spec_dir}/extract-tar-files") |
45 | 40 | host.disconnect
|
46 | 41 | end
|
47 | 42 |
|
|
126 | 121 | paths = result.map(&:path)
|
127 | 122 | expect(paths.include?('test2.config')).to eq(false)
|
128 | 123 |
|
129 |
| - host.mkdir("#{host_json['home']}/extract-tar-files", silent: true) |
130 |
| - host.tar('extract', 'archive.tar', directory: "#{host_json['home']}/extract-tar-files") |
| 124 | + host.mkdir("#{spec_dir}/extract-tar-files", silent: true) |
| 125 | + host.tar('extract', 'archive.tar', directory: "#{spec_dir}/extract-tar-files") |
131 | 126 |
|
132 |
| - result = host.ls(path: "#{host_json['home']}/extract-tar-files") |
| 127 | + result = host.ls(path: "#{spec_dir}/extract-tar-files") |
133 | 128 | paths = result.map(&:path)
|
134 | 129 |
|
135 | 130 | expect(paths.include?('test1.config')).to eq(true)
|
|
0 commit comments