traquitana 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.
data/spec/cleaner_spec.rb CHANGED
@@ -1,22 +1,23 @@
1
- require "minitest/autorun"
1
+ require 'minitest/autorun'
2
+ require 'minitest/focus'
2
3
  require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
3
4
 
4
5
  describe Traquitana::Cleaner do
5
- before do
6
- @cleaner = Traquitana::Cleaner.new
7
- @config = Traquitana::Config.instance
8
- @config.load
9
- end
6
+ before do
7
+ @cleaner = Traquitana::Cleaner.new
8
+ @config = Traquitana::Config.instance
9
+ @config.load
10
+ end
10
11
 
11
- it "should have a run method" do
12
- @cleaner.must_respond_to :run
13
- end
12
+ it 'should have a run method' do
13
+ expect(@cleaner).must_respond_to :run
14
+ end
14
15
 
15
- it "should run cleaner on remote host" do
16
- network = MiniTest::Mock.new
17
- network.expect(:execute,nil,[["find #{@config.directory}/traq -type f -iname '*.zip' -o -iname '*.list' | sort | head -n-2 | xargs rm $1"]])
18
- @cleaner.network = network
19
- @cleaner.run
20
- network.verify
21
- end
16
+ it 'should run cleaner on remote host' do
17
+ network = MiniTest::Mock.new
18
+ network.expect(:execute, nil, [["find #{@config.directory}/traq -type f -iname '*.zip' -o -iname '*.list' | sort | head -n-2 | xargs rm $1"]])
19
+ @cleaner.network = network
20
+ @cleaner.run
21
+ network.verify
22
+ end
22
23
  end
data/spec/config/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'memoize'
4
+ gem 'rake'
data/spec/config/Rakefile CHANGED
@@ -0,0 +1,11 @@
1
+ namespace 'db' do
2
+ task :migrate do
3
+ STDOUT.puts "running migrations ..."
4
+ end
5
+ end
6
+
7
+ namespace 'assets' do
8
+ task :precompile do
9
+ STDOUT.puts "precompiling assets ..."
10
+ end
11
+ end
data/spec/config_spec.rb CHANGED
@@ -1,109 +1,114 @@
1
- require "yaml"
2
- require "fileutils"
3
- require "minitest/autorun"
1
+ require 'yaml'
2
+ require 'fileutils'
3
+ require 'minitest/autorun'
4
+ require 'minitest/focus'
4
5
  require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
5
6
 
6
7
  describe Traquitana::Config do
7
- before do
8
- @config = Traquitana::Config.instance
9
- end
10
-
11
- describe "paths" do
12
- it "should have a filename getter method" do
13
- @config.must_respond_to(:filename)
14
- end
15
-
16
- it "should have a filename called traq.yml if file name is not set" do
17
- File.basename(@config.filename).must_equal("traq.yml")
18
- end
19
-
20
- it "should have a filename setter method" do
21
- @config.must_respond_to(:filename=)
22
- end
23
-
24
- it "should have a custom filename if filename is set" do
25
- old = @config.filename
26
- custom = "config/custom.yml"
27
- @config.filename = custom
28
- @config.filename.must_equal custom
29
- @config.filename = old
30
- end
31
-
32
- it "should have a default file method" do
33
- @config.must_respond_to(:default)
34
- end
35
-
36
- it "should have a valid directory" do
37
- @config.directory.wont_be_nil
38
- (@config.directory.size > 0).must_equal true
39
- end
40
- end
41
-
42
- describe "configs" do
43
- it "should respond to configuration dynamic methods" do
44
- @config.banana.must_equal ""
45
- end
46
-
47
- it "should respond with the correct value" do
48
- @config.load
49
- @config.user.must_equal "taq"
50
- end
51
-
52
- it "should have basic information on the default file" do
53
- contents = YAML.load(File.read(@config.default))
54
- contents["directory"].wont_be_nil
55
- contents["server"].wont_be_nil
56
- contents["list"].wont_be_nil
57
- contents["host"].wont_be_nil
58
- end
59
- end
60
-
61
- describe "setup" do
62
- it "should have a method named setup" do
63
- @config.must_respond_to(:setup)
64
- end
65
-
66
- it "should do nothing if the configuration file exists" do
67
- @config.setup.must_equal false
68
- end
69
-
70
- it "should write the configuration file if it doesn't exists" do
71
- contents = File.read(@config.filename)
72
- File.unlink(@config.filename)
73
-
74
- assert !File.exists?(@config.filename)
75
- @config.setup.must_equal true
76
- assert File.exists?(@config.filename)
77
-
78
- File.open(@config.filename,"w") {|file| file << contents}
8
+ before do
9
+ @config = Traquitana::Config.instance
10
+ end
11
+
12
+ describe 'paths' do
13
+ it 'should have a filename getter method' do
14
+ expect(@config).must_respond_to :filename
15
+ end
16
+
17
+ it 'should have a filename called traq.yml if file name is not set' do
18
+ expect(File.basename(@config.filename)).must_equal('traq.yml')
19
+ end
20
+
21
+ it 'should have a filename setter method' do
22
+ expect(@config).must_respond_to :filename=
23
+ end
24
+
25
+ it 'should have a custom filename if filename is set' do
26
+ old = @config.filename
27
+ custom = 'config/custom.yml'
28
+
29
+ @config.filename = custom
30
+ expect(@config.filename).must_equal custom
31
+ @config.filename = old
32
+ end
33
+
34
+ it 'should have a default file method' do
35
+ expect(@config).must_respond_to :default
36
+ end
37
+
38
+ it 'should have a valid directory' do
39
+ expect(@config.directory).wont_be_nil
40
+ expect(@config.directory.size > 0).must_equal true
41
+ end
42
+ end
43
+
44
+ describe 'configs' do
45
+ it 'should respond to configuration dynamic methods' do
46
+ expect(@config.banana).must_equal ''
47
+ end
48
+
49
+ it 'should respond with the correct value' do
50
+ @config.load
51
+ expect(@config.user).must_equal 'taq'
52
+ end
53
+
54
+ it 'should have basic information on the default file' do
55
+ contents = YAML.load(File.read(@config.default))
56
+ expect(contents['directory']).wont_be_nil
57
+ expect(contents['server']).wont_be_nil
58
+ expect(contents['list']).wont_be_nil
59
+ expect(contents['host']).wont_be_nil
60
+ end
61
+ end
62
+
63
+ describe 'setup' do
64
+ it 'should have a method named setup' do
65
+ expect(@config).must_respond_to :setup
66
+ end
67
+
68
+ it 'should do nothing if the configuration file exists' do
69
+ expect(@config.setup).must_equal false
70
+ end
71
+
72
+ it 'should write the configuration file if it doesnt exists' do
73
+ contents = File.read(@config.filename)
74
+ File.unlink(@config.filename)
75
+
76
+ expect(File.exists?(@config.filename)).must_equal false
77
+ expect(@config.setup).must_equal true
78
+ expect(File.exists?(@config.filename)).must_equal true
79
+
80
+ File.open(@config.filename, 'w') do |file|
81
+ file << contents
79
82
  end
80
- end
81
-
82
- describe "targets" do
83
- it "should have a target readable attribute" do
84
- @config.must_respond_to :target
83
+ end
84
+ end
85
+
86
+ describe 'targets' do
87
+ it 'should have a target readable attribute' do
88
+ expect(@config).must_respond_to :target
89
+ end
90
+
91
+ it 'should have a target writable attribute' do
92
+ expect(@config).must_respond_to :target=
93
+ end
94
+
95
+ it 'should load custom target config' do
96
+ begin
97
+ @config.filename = 'config/custom.yml'
98
+ @config.target = 'custom'
99
+ @config.load
100
+ expect(@config.directory).must_equal '/tmp/traq_test_custom'
101
+ ensure
102
+ reset_config
85
103
  end
104
+ end
105
+ end
86
106
 
87
- it "should have a target writable attribute" do
88
- @config.must_respond_to :target=
89
- end
107
+ private
90
108
 
91
- it "should load custom target config" do
92
- begin
93
- @config.filename = "config/custom.yml"
94
- @config.target = "custom"
95
- @config.load
96
- @config.directory.must_equal "/tmp/traq_test_custom"
97
- ensure
98
- reset_config
99
- end
100
- end
101
- end
102
-
103
- private
104
- def reset_config
105
- @config.filename = "config/traq.yml"
106
- @config.target = nil
107
- @config.load
108
- end
109
+ def reset_config
110
+ @config.filename = 'config/traq.yml'
111
+ @config.target = nil
112
+ @config.load
113
+ end
109
114
  end
data/spec/deploy_spec.rb CHANGED
@@ -1,15 +1,18 @@
1
- require "yaml"
2
- require "fileutils"
3
- require "minitest/autorun"
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'fileutils'
5
+ require 'minitest/autorun'
4
6
  require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
5
7
 
6
8
  describe Traquitana::Deployer do
7
- before do
8
- @config = Traquitana::Config.instance
9
- @deploy = Traquitana::Deployer.new({ verbose: true })
10
- end
9
+ before do
10
+ FileUtils.cd("#{__dir__}/config")
11
+ @config = Traquitana::Config.instance
12
+ @deploy = Traquitana::Deployer.new(verbose: true)
13
+ end
11
14
 
12
- it 'deploys' do
13
- @deploy.run
14
- end
15
+ it 'deploys' do
16
+ @deploy.run
17
+ end
15
18
  end
data/spec/network_spec.rb CHANGED
@@ -1,56 +1,59 @@
1
- require "digest/md5"
2
- require "minitest/autorun"
1
+ require 'digest/md5'
2
+ require 'minitest/autorun'
3
3
  require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
4
4
 
5
5
  describe Traquitana::SSH do
6
- before do
7
- @config = Traquitana::Config.instance
8
- @network = Traquitana::SSH.new(@config.host,@config.user)
9
- @send = "#{File.expand_path(File.dirname(__FILE__))}/config/network_test.txt"
10
- @md5 = Digest::MD5.hexdigest(File.read(@send))
11
-
12
- Dir.mkdir(@config.directory) if !File.exists?(@config.directory)
13
- end
14
-
15
- describe "configs" do
16
- it "should have a host attribute" do
17
- @network.must_respond_to(:host)
18
- end
19
-
20
- it "should have an user attribute" do
21
- @network.must_respond_to(:user)
22
- end
23
-
24
- it "should have an options attribute" do
25
- @network.must_respond_to(:options)
26
- end
27
- end
28
-
29
- describe "operations" do
30
- it "should have a send method" do
31
- @network.must_respond_to(:send_files)
32
- end
33
-
34
- it "should send a file to the remote host" do
35
- check = "#{@config.directory}/#{File.basename(@send)}"
36
- File.unlink(check) if File.exists?(check)
37
- @network.send_files([[@send,"#{@config.directory}/#{File.basename(@send)}"]],Traquitana::Bar.new)
38
- assert File.exists?(check)
39
- Digest::MD5.hexdigest(File.read(check)).must_equal @md5
40
- end
41
-
42
- it "should have a execute method" do
43
- @network.must_respond_to(:execute)
44
- end
45
-
46
- it "should execute a command on the remote host" do
47
- remote_dir = "#{@config.directory}/remote_dir"
48
- FileUtils.rmdir(remote_dir) if File.exists?(remote_dir)
49
- @network.execute(["mkdir #{@config.directory}/remote_dir"])
50
- assert File.exists?(remote_dir)
51
- end
52
- end
53
-
54
- describe "uploading" do
55
- end
6
+ before do
7
+ @config = Traquitana::Config.instance
8
+ @network = Traquitana::SSH.new(@config.host, @config.user)
9
+ @send = "#{File.expand_path(File.dirname(__FILE__))}/config/network_test.txt"
10
+ @md5 = Digest::MD5.hexdigest(File.read(@send))
11
+
12
+ Dir.mkdir(@config.directory) if !File.exists?(@config.directory)
13
+ end
14
+
15
+ describe 'configs' do
16
+ it 'should have a host attribute' do
17
+ expect(@network).must_respond_to :host
18
+ end
19
+
20
+ it 'should have an user attribute' do
21
+ expect(@network).must_respond_to :user
22
+ end
23
+
24
+ it 'should have an options attribute' do
25
+ expect(@network).must_respond_to :options
26
+ end
27
+ end
28
+
29
+ describe 'operations' do
30
+ it 'should have a send method' do
31
+ expect(@network).must_respond_to :send_files
32
+ end
33
+
34
+ it 'should send a file to the remote host' do
35
+ check = "#{@config.directory}/#{File.basename(@send)}"
36
+ File.unlink(check) if File.exists?(check)
37
+
38
+ @network.send_files([[@send, "#{@config.directory}/#{File.basename(@send)}"]], Traquitana::Bar.new)
39
+
40
+ expect(File.exists?(check)).must_equal true
41
+ expect(Digest::MD5.hexdigest(File.read(check))).must_equal @md5
42
+ end
43
+
44
+ it 'should have a execute method' do
45
+ expect(@network).must_respond_to :execute
46
+ end
47
+
48
+ it 'should execute a command on the remote host' do
49
+ remote_dir = "#{@config.directory}/remote_dir"
50
+ FileUtils.rmdir(remote_dir) if File.exists?(remote_dir)
51
+
52
+ @network.execute(["mkdir #{@config.directory}/remote_dir"])
53
+ expect(File.exists?(remote_dir)).must_equal true
54
+ end
55
+ end
56
+
57
+ describe "uploading" do
58
+ end
56
59
  end
@@ -1,44 +1,44 @@
1
- require "fileutils"
2
- require "minitest/autorun"
1
+ require 'fileutils'
2
+ require 'minitest/autorun'
3
+ require 'minitest/focus'
3
4
  require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
4
5
 
5
6
  describe Traquitana::Packager do
6
- before do
7
- @packager = Traquitana::Packager.new(File.expand_path(File.dirname(__FILE__))+"/config/")
8
- end
9
-
10
- it "should have an id method" do
11
- @packager.must_respond_to(:id)
12
- end
13
-
14
- it "should return an id" do
15
- @packager.id.wont_be_nil
16
- end
17
-
18
- it "should have a list file method" do
19
- @packager.must_respond_to(:list_file)
20
- end
21
-
22
- it "should return the correct list file name" do
23
- id = @packager.id
24
- @packager.list_file.must_equal @packager.id+".list"
25
- end
26
-
27
- it "should have a zip file method" do
28
- @packager.must_respond_to(:zip_file)
29
- end
30
-
31
- it "should return the correct zip file name" do
32
- id = @packager.id
33
- @packager.zip_file.must_equal @packager.id+".zip"
34
- end
35
-
36
- it "should have a pack method" do
37
- @packager.must_respond_to(:pack)
38
- end
39
-
40
- it "should return the list and package file" do
41
- list, package = @packager.pack
42
- end
7
+ before do
8
+ @packager = Traquitana::Packager.new(File.expand_path(File.dirname(__FILE__)) + '/config/')
9
+ end
10
+
11
+ it 'should have an id method' do
12
+ expect(@packager).must_respond_to :id
13
+ end
14
+
15
+ it 'should return an id' do
16
+ expect(@packager.id).wont_be_nil
17
+ end
18
+
19
+ it 'should have a list file method' do
20
+ expect(@packager).must_respond_to :list_file
21
+ end
22
+
23
+ it 'should return the correct list file name' do
24
+ expect(@packager.list_file).must_equal @packager.id + '.list'
25
+ end
26
+
27
+ it 'should have a zip file method' do
28
+ expect(@packager).must_respond_to :zip_file
29
+ end
30
+
31
+ it 'should return the correct zip file name' do
32
+ expect(@packager.zip_file).must_equal @packager.id + '.zip'
33
+ end
34
+
35
+ it 'should have a pack method' do
36
+ expect(@packager).must_respond_to :pack
37
+ end
38
+
39
+ it 'should return the list and package file' do
40
+ list, package = @packager.pack
41
+ expect(list).wont_be_nil
42
+ expect(package).wont_be_nil
43
+ end
43
44
  end
44
-