s3-mysql-backup 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68c808d94c4006434ae710b9602b4511c6833cea
4
- data.tar.gz: 98040176bbab5f6e59c41471511bdb90994cfd64
3
+ metadata.gz: 696c4cb78b7a521ed337aeb7348712d338f0c407
4
+ data.tar.gz: 95743351851fda6539bacb44c259116407e68e3f
5
5
  SHA512:
6
- metadata.gz: ed796d0c791bc6a3a3ea3ba25b87c426038c68f651c2a822a7e6e63b7d37b6853ec63dc3a552ab45a29e2c7930695f7d846682676fee60dfa44cf903de31822d
7
- data.tar.gz: 803ee3265a805312d43d28405b68f2f6129bbe4eaea1c5997d43cea715d1fed6b4f5eafdb7fac963b6382dee4c29561394b2531c0b64aead8af3f5ac3779c61c
6
+ metadata.gz: 7bab2531ddb39cc3edbb98b2a57c311c91689750e19d5e40ab567ea563eb62260d4708eeaec78c84eba14c6e914d353c1df32587f1736942a7a7f48994f833cf
7
+ data.tar.gz: cf6fa294ad8877d7c9081ac78e33c159004930030626663cbf84134d63b7b5e99a68005b3127441f2011c6e64697a41995e176e5982a63fe9289684e2c0adb3c
@@ -89,7 +89,12 @@ class S3MysqlBackup
89
89
 
90
90
  smtp = Net::SMTP.new(config["mail_domain"], config["mail_port"])
91
91
  smtp.enable_starttls unless config["mail_start_tls"] == false
92
- smtp.start(config["mail_domain"], config['mail_user'], config['mail_pass'], config['mail_authentication']) do
92
+ smtp.start(
93
+ config["mail_domain"].to_s,
94
+ config['mail_user'].to_s,
95
+ config['mail_pass'].to_s,
96
+ config['mail_authentication'].to_s
97
+ ) do
93
98
  smtp.send_message(content, mail_from, config['mail_to'])
94
99
  end
95
100
  end
@@ -2,52 +2,104 @@ require "spec_helper"
2
2
 
3
3
  describe S3MysqlBackup do
4
4
 
5
- before :each do
6
- @config = YAML::load_file(File.dirname(__FILE__) + '/s3_mysql_backup.yml')
7
- stub.instance_of(S3MysqlBackup).config.times(any_times){ @config }
5
+ context "with smtp stubbed" do
6
+ before :each do
7
+ @config = YAML::load_file(File.dirname(__FILE__) + '/s3_mysql_backup.yml')
8
+ stub.instance_of(S3MysqlBackup).config.times(any_times){ @config }
8
9
 
9
- stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(any_times){ true }
10
+ stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(any_times){ true }
10
11
 
11
- @dump_file_name = "/tmp/test.20130101.010101.sql.gz"
12
- stub.instance_of(S3MysqlBackup).dump_db.times(any_times){ @dump_file_name }
12
+ @dump_file_name = "/tmp/test.20130101.010101.sql.gz"
13
+ stub.instance_of(S3MysqlBackup).dump_db.times(any_times){ @dump_file_name }
13
14
 
14
- mock_stats = Object.new
15
- stub(File).stat.with_any_args.times(any_times){ mock_stats }
16
- stub(mock_stats).size{ 1024 }
15
+ mock_stats = Object.new
16
+ stub(File).stat.with_any_args.times(any_times){ mock_stats }
17
+ stub(mock_stats).size{ 1024 }
17
18
 
18
- mock_utils = Object.new
19
- stub(S3Utils).new.with_any_args.times(any_times){ mock_utils }
20
- stub.instance_of(S3MysqlBackup).connect_to_s3.times(any_times){ mock_utils }
19
+ mock_utils = Object.new
20
+ stub(S3Utils).new.with_any_args.times(any_times){ mock_utils }
21
+ stub.instance_of(S3MysqlBackup).connect_to_s3.times(any_times){ mock_utils }
21
22
 
22
- stub.instance_of(Net::SMTP).enable_starttls.times(any_times)
23
- stub.instance_of(Net::SMTP).start.with_any_args.times(any_times){ true }
24
- end
25
-
26
- describe "#run" do
27
- it "should call ensure_backup_dir_exists" do
28
- stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(1)
29
- S3MysqlBackup.new('test', @config_path).run
23
+ stub.instance_of(Net::SMTP).enable_starttls.times(any_times)
24
+ stub.instance_of(Net::SMTP).start.with_any_args.times(any_times){ true }
30
25
  end
31
26
 
32
- it "should call connect_to_s3" do
33
- stub.instance_of(S3MysqlBackup).connect_to_s3.times(1)
34
- S3MysqlBackup.new('test', @config_path).run
35
- end
27
+ describe "#run" do
28
+ it "should call ensure_backup_dir_exists" do
29
+ stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(1)
30
+ S3MysqlBackup.new('test', @config_path).run
31
+ end
32
+
33
+ it "should call connect_to_s3" do
34
+ stub.instance_of(S3MysqlBackup).connect_to_s3.times(1)
35
+ S3MysqlBackup.new('test', @config_path).run
36
+ end
36
37
 
37
- it "should call remove_old_backups" do
38
- stub.instance_of(S3MysqlBackup).remove_old_backups.times(1)
39
- S3MysqlBackup.new('test', @config_path).run
38
+ it "should call remove_old_backups" do
39
+ stub.instance_of(S3MysqlBackup).remove_old_backups.times(1)
40
+ S3MysqlBackup.new('test', @config_path).run
41
+ end
42
+
43
+ it "should call dump_db" do
44
+ stub.instance_of(S3MysqlBackup).dump_db.times(1){ @dump_file_name }
45
+ S3MysqlBackup.new('test', @config_path).run
46
+ end
47
+
48
+ it "should call mail_notification" do
49
+ stub.instance_of(S3MysqlBackup).mail_notification.times(1)
50
+ S3MysqlBackup.new('test', @config_path).run
51
+ end
40
52
  end
53
+ end
54
+
55
+ context "without smtp stubbed" do
56
+ before :each do
57
+ # @config = YAML::load_file(File.dirname(__FILE__) + '/s3_mysql_backup.yml')
58
+ # stub.instance_of(S3MysqlBackup).config.times(any_times){ @config }
41
59
 
42
- it "should call dump_db" do
43
- stub.instance_of(S3MysqlBackup).dump_db.times(1){ @dump_file_name }
44
- S3MysqlBackup.new('test', @config_path).run
60
+ stub.instance_of(S3MysqlBackup).ensure_backup_dir_exists.times(any_times){ true }
61
+
62
+ @dump_file_name = "/tmp/test.20130101.010101.sql.gz"
63
+ stub.instance_of(S3MysqlBackup).dump_db.times(any_times){ @dump_file_name }
64
+
65
+ mock_stats = Object.new
66
+ stub(File).stat.with_any_args.times(any_times){ mock_stats }
67
+ stub(mock_stats).size{ 1024 }
68
+
69
+ mock_utils = Object.new
70
+ stub(S3Utils).new.with_any_args.times(any_times){ mock_utils }
71
+ stub.instance_of(S3MysqlBackup).connect_to_s3.times(any_times){ mock_utils }
72
+
73
+ stub.instance_of(Net::SMTP).send_message.with_any_args.times(any_times)
45
74
  end
46
75
 
47
- it "should call mail_notification" do
48
- stub.instance_of(S3MysqlBackup).mail_notification.times(1)
49
- S3MysqlBackup.new('test', @config_path).run
76
+ describe "#mail_notification" do
77
+ it "should not raise with integer password" do
78
+ expect{
79
+
80
+ begin
81
+ S3MysqlBackup.new('test', {
82
+ backup_dir: "/tmp/s3_mysql_backups",
83
+ s3_access_key_id: "my-key",
84
+ s3_secret_access_key: "my-secret",
85
+ s3_bucket: "my-bucket",
86
+ dump_user: "my-user",
87
+ dump_pass: "my-pass",
88
+ mail_to: "recipient@example.com",
89
+ mail_user: "me@gmail.com",
90
+ mail_pass: 12345,
91
+ mail_start_tls: true,
92
+ }
93
+ ).send :mail_notification, "some_file_name"
94
+
95
+ rescue Exception => e
96
+ raise e if e.is_a?(TypeError)
97
+ end
98
+
99
+ }.not_to raise_error
100
+ end
50
101
  end
102
+
51
103
  end
52
104
 
53
105
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,6 @@
1
1
  require "s3_mysql_backup"
2
2
  require "rr"
3
- require 'fakefs/spec_helpers'
4
3
 
5
4
  RSpec.configure do |config|
6
- config.color_enabled = true
7
- config.formatter = 'documentation'
8
5
  config.mock_framework = :rr
9
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3-mysql-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Emminger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2015-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.4.2
91
+ rubygems_version: 2.4.7
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Simple mysql backup to S3