wordpress-deploy 1.0.0.alpha1 → 1.0.0.alpha2
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/.gitignore +26 -1
- data/.rspec +1 -0
- data/.rvmrc +48 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -5
- data/Gemfile.lock +40 -28
- data/Guardfile +24 -0
- data/README.md +22 -7
- data/bin/wp-deploy +1 -4
- data/lib/wordpress_deploy.rb +22 -48
- data/lib/wordpress_deploy/cli/helpers.rb +27 -14
- data/lib/wordpress_deploy/cli/utility.rb +86 -37
- data/lib/wordpress_deploy/database/mysql.rb +22 -136
- data/lib/wordpress_deploy/environment.rb +68 -0
- data/lib/wordpress_deploy/errors.rb +54 -0
- data/lib/wordpress_deploy/logger.rb +28 -50
- data/lib/wordpress_deploy/transfer_protocols/ftp.rb +305 -0
- data/lib/wordpress_deploy/version.rb +1 -1
- data/lib/wordpress_deploy/wordpress/configuration.rb +196 -0
- data/spec/data/ftp.yml +4 -0
- data/spec/data/wp-config-sample.php +90 -0
- data/spec/data/wp-config.yml +128 -0
- data/spec/database/mysql_spec.rb +93 -0
- data/spec/environment_spec.rb +35 -0
- data/spec/spec_helper.rb +36 -1
- data/spec/transfer_protocols/ftp_spec.rb +193 -0
- data/spec/wordpress/configuration_spec.rb +202 -0
- data/wordpress_deploy.gemspec +13 -10
- metadata +63 -47
- data/lib/wordpress_deploy/config.rb +0 -68
- data/lib/wordpress_deploy/database/base.rb +0 -53
- data/lib/wordpress_deploy/pipeline.rb +0 -110
- data/lib/wordpress_deploy/storage/base.rb +0 -99
- data/lib/wordpress_deploy/storage/ftp.rb +0 -133
- data/lib/wordpress_deploy/storage/local.rb +0 -82
- data/lib/wordpress_deploy/storage/scp.rb +0 -99
- data/lib/wordpress_deploy/storage/sftp.rb +0 -108
- data/spec/config_spec.rb +0 -16
data/spec/data/ftp.yml
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* The base configurations of the WordPress.
|
4
|
+
*
|
5
|
+
* This file has the following configurations: MySQL settings, Table Prefix,
|
6
|
+
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
|
7
|
+
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
|
8
|
+
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
|
9
|
+
*
|
10
|
+
* This file is used by the wp-config.php creation script during the
|
11
|
+
* installation. You don't have to use the web site, you can just copy this file
|
12
|
+
* to "wp-config.php" and fill in the values.
|
13
|
+
*
|
14
|
+
* @package WordPress
|
15
|
+
*/
|
16
|
+
|
17
|
+
// ** MySQL settings - You can get this info from your web host ** //
|
18
|
+
/** The name of the database for WordPress */
|
19
|
+
define('DB_NAME', 'database_name_here');
|
20
|
+
|
21
|
+
/** MySQL database username */
|
22
|
+
define('DB_USER', 'username_here');
|
23
|
+
|
24
|
+
/** MySQL database password */
|
25
|
+
define('DB_PASSWORD', 'password_here');
|
26
|
+
|
27
|
+
/** MySQL hostname */
|
28
|
+
define('DB_HOST', 'localhost');
|
29
|
+
|
30
|
+
/** Database Charset to use in creating database tables. */
|
31
|
+
define('DB_CHARSET', 'utf8');
|
32
|
+
|
33
|
+
/** The Database Collate type. Don't change this if in doubt. */
|
34
|
+
define('DB_COLLATE', '');
|
35
|
+
|
36
|
+
/**#@+
|
37
|
+
* Authentication Unique Keys and Salts.
|
38
|
+
*
|
39
|
+
* Change these to different unique phrases!
|
40
|
+
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
41
|
+
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
42
|
+
*
|
43
|
+
* @since 2.6.0
|
44
|
+
*/
|
45
|
+
define('AUTH_KEY', 'put your unique phrase here');
|
46
|
+
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
47
|
+
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
48
|
+
define('NONCE_KEY', 'put your unique phrase here');
|
49
|
+
define('AUTH_SALT', 'put your unique phrase here');
|
50
|
+
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
51
|
+
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
52
|
+
define('NONCE_SALT', 'put your unique phrase here');
|
53
|
+
|
54
|
+
/**#@-*/
|
55
|
+
|
56
|
+
/**
|
57
|
+
* WordPress Database Table prefix.
|
58
|
+
*
|
59
|
+
* You can have multiple installations in one database if you give each a unique
|
60
|
+
* prefix. Only numbers, letters, and underscores please!
|
61
|
+
*/
|
62
|
+
$table_prefix = 'wp_';
|
63
|
+
|
64
|
+
/**
|
65
|
+
* WordPress Localized Language, defaults to English.
|
66
|
+
*
|
67
|
+
* Change this to localize WordPress. A corresponding MO file for the chosen
|
68
|
+
* language must be installed to wp-content/languages. For example, install
|
69
|
+
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
|
70
|
+
* language support.
|
71
|
+
*/
|
72
|
+
define('WPLANG', '');
|
73
|
+
|
74
|
+
/**
|
75
|
+
* For developers: WordPress debugging mode.
|
76
|
+
*
|
77
|
+
* Change this to true to enable the display of notices during development.
|
78
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
79
|
+
* in their development environments.
|
80
|
+
*/
|
81
|
+
define('WP_DEBUG', false);
|
82
|
+
|
83
|
+
/* That's all, stop editing! Happy blogging. */
|
84
|
+
|
85
|
+
/** Absolute path to the WordPress directory. */
|
86
|
+
if ( !defined('ABSPATH') )
|
87
|
+
define('ABSPATH', dirname(__FILE__) . '/');
|
88
|
+
|
89
|
+
/** Sets up WordPress vars and included files. */
|
90
|
+
require_once(ABSPATH . 'wp-settings.php');
|
@@ -0,0 +1,128 @@
|
|
1
|
+
development:
|
2
|
+
DB_NAME: developer_database_name
|
3
|
+
DB_USER: root
|
4
|
+
DB_PASSWORD: q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$
|
5
|
+
DB_HOST: localhost
|
6
|
+
DB_CHARSET: utf8
|
7
|
+
DB_COLLATE: ''
|
8
|
+
|
9
|
+
# FTP Transfer settings
|
10
|
+
FTP_HOST: localhost
|
11
|
+
FTP_USER: root
|
12
|
+
FTP_PASSWORD: q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$
|
13
|
+
FTP_DIR: /wordpress
|
14
|
+
|
15
|
+
# Authentication Unique Keys and Salts
|
16
|
+
# https://api.wordpress.org/secret-key/1.1/salt/
|
17
|
+
# If no salts are supplied they will be generated automatically
|
18
|
+
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
19
|
+
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
20
|
+
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
21
|
+
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
22
|
+
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
23
|
+
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
24
|
+
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
25
|
+
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
26
|
+
|
27
|
+
production:
|
28
|
+
DB_NAME: production_database_name
|
29
|
+
DB_USER: some_user
|
30
|
+
DB_PASSWORD: trecuwawraJaZe6P@kucraDrachustUq
|
31
|
+
DB_HOST: abbott.biz:6654
|
32
|
+
DB_CHARSET: utf8
|
33
|
+
DB_COLLATE: ''
|
34
|
+
|
35
|
+
# FTP Transfer settings
|
36
|
+
FTP_HOST: ftp.abbott.biz:6654
|
37
|
+
FTP_USER: some_user
|
38
|
+
FTP_PASSWORD: trecuwawraJaZe6P@kucraDrachustUq
|
39
|
+
|
40
|
+
# Authentication Unique Keys and Salts
|
41
|
+
# https://api.wordpress.org/secret-key/1.1/salt/
|
42
|
+
# If no salts are supplied they will be generated automatically
|
43
|
+
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
44
|
+
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
45
|
+
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
46
|
+
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
47
|
+
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
48
|
+
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
49
|
+
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
50
|
+
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
51
|
+
|
52
|
+
red:
|
53
|
+
DB_NAME: red
|
54
|
+
DB_USER: red_user
|
55
|
+
DB_PASSWORD: Bun__huPEMeBreM6tebRAp@eguzuQExe
|
56
|
+
DB_HOST: hanerutherford.biz
|
57
|
+
DB_CHARSET: utf8
|
58
|
+
DB_COLLATE: ''
|
59
|
+
|
60
|
+
# FTP Transfer settings
|
61
|
+
FTP_HOST: ftp.hanerutherford.biz
|
62
|
+
FTP_USER: red_user
|
63
|
+
FTP_PASSWORD: Bun__huPEMeBreM6tebRAp@eguzuQExe
|
64
|
+
FTP_DIR: /html
|
65
|
+
|
66
|
+
# Authentication Unique Keys and Salts
|
67
|
+
# https://api.wordpress.org/secret-key/1.1/salt/
|
68
|
+
# If no salts are supplied they will be generated automatically
|
69
|
+
AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
70
|
+
SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
71
|
+
LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
72
|
+
NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
73
|
+
AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
74
|
+
SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
75
|
+
LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
76
|
+
NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
77
|
+
|
78
|
+
green:
|
79
|
+
DB_NAME: green
|
80
|
+
DB_USER: domenick.dare
|
81
|
+
DB_PASSWORD: Daw&HEWuzaz6sa&epHech_spAKucHaTH
|
82
|
+
DB_HOST: yundt.org
|
83
|
+
DB_CHARSET: utf8
|
84
|
+
DB_COLLATE: ''
|
85
|
+
|
86
|
+
# FTP Transfer settings
|
87
|
+
FTP_HOST: ftp.yundt.org
|
88
|
+
FTP_USER: domenick.dare
|
89
|
+
FTP_PASSWORD: Daw&HEWuzaz6sa&epHech_spAKucHaTH
|
90
|
+
FTP_DIR: /wordpress
|
91
|
+
|
92
|
+
# Authentication Unique Keys and Salts
|
93
|
+
# https://api.wordpress.org/secret-key/1.1/salt/
|
94
|
+
# If no salts are supplied they will be generated automatically
|
95
|
+
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
96
|
+
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
97
|
+
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
98
|
+
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
99
|
+
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
100
|
+
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
101
|
+
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
102
|
+
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
103
|
+
|
104
|
+
blue:
|
105
|
+
DB_NAME: blue
|
106
|
+
DB_USER: harrison
|
107
|
+
DB_PASSWORD: w5@reba?9?pepuk7w9a#H86ustaGawE!
|
108
|
+
DB_HOST: torphagenes.com:/tmp/mysql5.sock
|
109
|
+
DB_CHARSET: utf8
|
110
|
+
DB_COLLATE: ''
|
111
|
+
|
112
|
+
# FTP Transfer settings
|
113
|
+
FTP_HOST: ftp.torphagenes.com
|
114
|
+
FTP_USER: harrison
|
115
|
+
FTP_PASSWORD: w5@reba?9?pepuk7w9a#H86ustaGawE!
|
116
|
+
FTP_DIR: /wordpress
|
117
|
+
|
118
|
+
# Authentication Unique Keys and Salts
|
119
|
+
# https://api.wordpress.org/secret-key/1.1/salt/
|
120
|
+
# If no salts are supplied they will be generated automatically
|
121
|
+
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
122
|
+
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
123
|
+
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
124
|
+
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
125
|
+
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
126
|
+
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
127
|
+
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
128
|
+
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include WordpressDeploy::Database
|
4
|
+
include WordpressDeploy::Wordpress
|
5
|
+
|
6
|
+
describe MySql do
|
7
|
+
|
8
|
+
let(:mysql) { "/path/to/mysql" }
|
9
|
+
let(:mysqldump) { "/path/to/mysqldump" }
|
10
|
+
|
11
|
+
it { should respond_to :run }
|
12
|
+
it { should respond_to :utility }
|
13
|
+
it { should respond_to :command_name }
|
14
|
+
it { should respond_to :mysqldump }
|
15
|
+
it { should respond_to :configuration }
|
16
|
+
it { should respond_to :configuration= }
|
17
|
+
|
18
|
+
shared_examples "command based on configuration" do
|
19
|
+
before(:each) do
|
20
|
+
subject.configuration = WordpressDeploy::Wordpress::Configuration.new name
|
21
|
+
subject.stub(:utility).with("mysqldump").and_return(mysqldump)
|
22
|
+
end
|
23
|
+
its(:arguments) { should eq expected_args }
|
24
|
+
its(:mysqldump) { should eq "#{mysqldump} #{expected_args}" }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when configuration is 'development'" do
|
28
|
+
it_should_behave_like "command based on configuration" do
|
29
|
+
let(:name) { "development" }
|
30
|
+
let(:expected_args) { "-P \"3306\" -h \"localhost\" -u \"root\" -pq9&hu6Re_*dReWr_GAba_2wr89#2Ra8$ -B \"developer_database_name\"" }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when configuration is 'production'" do
|
35
|
+
it_should_behave_like "command based on configuration" do
|
36
|
+
let(:name) { "production" }
|
37
|
+
let(:expected_args) { "-P \"6654\" -h \"abbott.biz\" -u \"some_user\" -ptrecuwawraJaZe6P@kucraDrachustUq -B \"production_database_name\"" }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when configuration is 'red'" do
|
42
|
+
it_should_behave_like "command based on configuration" do
|
43
|
+
let(:name) { "red" }
|
44
|
+
let(:expected_args) { "-P \"3306\" -h \"hanerutherford.biz\" -u \"red_user\" -pBun__huPEMeBreM6tebRAp@eguzuQExe -B \"red\"" }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when configuration is 'green'" do
|
49
|
+
it_should_behave_like "command based on configuration" do
|
50
|
+
let(:name) { "green" }
|
51
|
+
let(:expected_args) { "-P \"3306\" -h \"yundt.org\" -u \"domenick.dare\" -pDaw&HEWuzaz6sa&epHech_spAKucHaTH -B \"green\"" }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when configuration is 'blue'" do
|
56
|
+
it_should_behave_like "command based on configuration" do
|
57
|
+
let(:name) { "blue" }
|
58
|
+
let(:expected_args) { "-P \"3306\" -h \"torphagenes.com\" -u \"harrison\" -pw5@reba?9?pepuk7w9a#H86ustaGawE! -B \"blue\"" }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "find commands" do
|
63
|
+
it "should raise Errors::Cli::UtilityNotFoundError if no command given" do
|
64
|
+
expect{subject.utility ""}.to raise_error(WordpressDeploy::Errors::Cli::UtilityNotFoundError)
|
65
|
+
end
|
66
|
+
it "should raise Errors::Cli::UtilityNotFoundError if command not found" do
|
67
|
+
expect{subject.utility "missing_system_command"}.to raise_error(WordpressDeploy::Errors::Cli::UtilityNotFoundError)
|
68
|
+
end
|
69
|
+
it "mysql" do
|
70
|
+
stdin = Object.new
|
71
|
+
stdin.stub(:close)
|
72
|
+
|
73
|
+
stdout = Object.new.stub(:read).and_return("")
|
74
|
+
stdout.stub(:read).and_return(mysql)
|
75
|
+
|
76
|
+
stderr = Object.new.stub(:read).and_return("")
|
77
|
+
stderr.stub(:read).and_return("")
|
78
|
+
|
79
|
+
wait_thr = Object.new
|
80
|
+
wait_thr.stub(:value).and_return($?)
|
81
|
+
|
82
|
+
Open3.should_receive(:popen3).exactly(1).times.and_yield(stdin, stdout, stderr, wait_thr)
|
83
|
+
|
84
|
+
subject.utility("mysql").should eq mysql
|
85
|
+
WordpressDeploy::Database::MySql::UTILITY["mysql"].should eq mysql
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should parse out the command name" do
|
90
|
+
subject.command_name("#{mysqldump} -P \"3306\" -h \"NOT_localhost\" -u \"root\" -ptemp -B \"developer_database_name\"").should eq "mysqldump"
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WordpressDeploy::Environment do
|
4
|
+
|
5
|
+
it { should respond_to :set_options }
|
6
|
+
|
7
|
+
let(:new_options) do
|
8
|
+
Hash["root_dir", "/some/new/dir", "wp_dir", "./dir2"]
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should allow mass assignment of options" do
|
12
|
+
subject.set_options new_options
|
13
|
+
subject.root_dir.should eq "/some/new/dir"
|
14
|
+
subject.wp_dir.should eq "/some/new/dir/dir2"
|
15
|
+
subject.log_file.should =~ /\/some\/new\/dir/
|
16
|
+
end
|
17
|
+
|
18
|
+
its(:root_dir) { should eq data_dir }
|
19
|
+
its(:wp_dir) { should eq data_dir }
|
20
|
+
its(:log_file) { should =~ /#{data_dir}.*.log/ }
|
21
|
+
|
22
|
+
context "logs" do
|
23
|
+
before(:all) { @log_before = WordpressDeploy::Environment.logging? }
|
24
|
+
it "should default to logging off unless explicitly set to true" do
|
25
|
+
WordpressDeploy::Environment.logging = true
|
26
|
+
[:true, "true", 1, 0, false, :false, "Cool"].each do |val|
|
27
|
+
WordpressDeploy::Environment.logging = val
|
28
|
+
WordpressDeploy::Environment.logging?.should be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
its(:logging?) { should be_false }
|
32
|
+
after(:all) { WordpressDeploy::Environment.logging = @log_before }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
1
4
|
require 'wordpress_deploy'
|
2
5
|
|
6
|
+
def data_dir
|
7
|
+
File.join(File.dirname(__FILE__), "data")
|
8
|
+
end
|
9
|
+
|
3
10
|
RSpec.configure do |config|
|
4
|
-
|
11
|
+
# == Mock Framework
|
12
|
+
#
|
13
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
+
#
|
15
|
+
# config.mock_with :mocha
|
16
|
+
# config.mock_with :flexmock
|
17
|
+
# config.mock_with :rr
|
18
|
+
config.mock_with :rspec
|
19
|
+
|
20
|
+
# Reset the environment for each spec that is run
|
21
|
+
config.before(:each) do
|
22
|
+
WordpressDeploy::Environment.root_dir = data_dir
|
23
|
+
WordpressDeploy::Environment.wp_dir = "."
|
24
|
+
WordpressDeploy::Environment.config_dir = "."
|
25
|
+
WordpressDeploy::Environment.logging = false
|
26
|
+
end
|
27
|
+
|
28
|
+
# Clean-up log files after each spec
|
29
|
+
config.after(:all) do
|
30
|
+
WordpressDeploy::Environment.clean!
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Matchers.define :be_salt do |expected|
|
36
|
+
match do |actual|
|
37
|
+
actual.instance_of? String
|
38
|
+
actual.to_s.size === 64
|
39
|
+
end
|
5
40
|
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include WordpressDeploy
|
4
|
+
|
5
|
+
describe WordpressDeploy::TransferProtocols::Ftp do
|
6
|
+
before(:each) do
|
7
|
+
# None of the methods that follow are testing
|
8
|
+
# the Net::FTP object actions; therefore they
|
9
|
+
# can be stubbed out
|
10
|
+
@ftp = double("ftp")
|
11
|
+
[:connect, :login, :passive=].each do |methods|
|
12
|
+
@ftp.stub(methods).with(any_args)
|
13
|
+
end
|
14
|
+
Net::FTP.stub(:new).and_return(@ftp)
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should respond_to :name }
|
18
|
+
it { should respond_to :name= }
|
19
|
+
it { should respond_to :available_names }
|
20
|
+
it { should respond_to :names }
|
21
|
+
it { should respond_to :port }
|
22
|
+
it { should respond_to :port? }
|
23
|
+
it { should respond_to :host }
|
24
|
+
it { should respond_to :configuration }
|
25
|
+
it { should respond_to :configuration= }
|
26
|
+
|
27
|
+
it { should respond_to :FTP_USER }
|
28
|
+
it { should respond_to :FTP_PASSWORD }
|
29
|
+
it { should respond_to :FTP_HOST }
|
30
|
+
it { should respond_to :FTP_DIR }
|
31
|
+
|
32
|
+
its(:names) { should have(5).strings }
|
33
|
+
its(:names) { should include "development" }
|
34
|
+
its(:names) { should include "production" }
|
35
|
+
its(:names) { should include "red" }
|
36
|
+
its(:names) { should include "green" }
|
37
|
+
its(:names) { should include "blue" }
|
38
|
+
its(:available_names) { should have(5).strings }
|
39
|
+
its(:available_names) { should include "development" }
|
40
|
+
its(:available_names) { should include "production" }
|
41
|
+
its(:available_names) { should include "red" }
|
42
|
+
its(:available_names) { should include "green" }
|
43
|
+
its(:available_names) { should include "blue" }
|
44
|
+
|
45
|
+
it "should allow creation of new configuration by name" do
|
46
|
+
ftp = WordpressDeploy::TransferProtocols::Ftp.new "red"
|
47
|
+
ftp.name.should eq "red"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should only allow configuration names found in the yaml file" do
|
51
|
+
["production", "development", "red", "green", "blue"].each do |name|
|
52
|
+
subject.name = name
|
53
|
+
subject.name.should eq name
|
54
|
+
end
|
55
|
+
[:production, nil].each do |name|
|
56
|
+
subject.name = name
|
57
|
+
subject.name.should_not eq name
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
shared_examples "ftp named configuration" do
|
62
|
+
before(:each) { subject.name = name }
|
63
|
+
its(:name) { should eq name }
|
64
|
+
its(:FTP_USER) { should eq ftp_user }
|
65
|
+
its(:FTP_PASSWORD) { should eq ftp_password }
|
66
|
+
its(:FTP_HOST) { should eq ftp_host }
|
67
|
+
its(:FTP_DIR) { should eq ftp_dir_raw }
|
68
|
+
its(:local_path) { should eq Environment.wp_dir }
|
69
|
+
its(:remote_path) { should eq ftp_dir }
|
70
|
+
its(:username) { should eq ftp_user }
|
71
|
+
its(:password) { should eq ftp_password }
|
72
|
+
its(:host) { should eq host }
|
73
|
+
its(:port) { should eq port }
|
74
|
+
its(:port?) { should eq has_port }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "development" do
|
78
|
+
it_should_behave_like "ftp named configuration" do
|
79
|
+
let(:name) { "development" }
|
80
|
+
let(:ftp_user) { "root" }
|
81
|
+
let(:ftp_password) { "q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$" }
|
82
|
+
let(:ftp_host) { "localhost" }
|
83
|
+
let(:ftp_dir_raw) { "/wordpress" }
|
84
|
+
let(:ftp_dir) { "/wordpress" }
|
85
|
+
let(:host) { "localhost" }
|
86
|
+
let(:port) { 21 }
|
87
|
+
let(:has_port) { false }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "production" do
|
92
|
+
it_should_behave_like "ftp named configuration" do
|
93
|
+
let(:name) { "production" }
|
94
|
+
let(:ftp_user) { "some_user" }
|
95
|
+
let(:ftp_password) { "trecuwawraJaZe6P@kucraDrachustUq" }
|
96
|
+
let(:ftp_host) { "ftp.abbott.biz:6654" }
|
97
|
+
let(:ftp_dir_raw) { nil }
|
98
|
+
let(:ftp_dir) { "/" }
|
99
|
+
let(:host) { "ftp.abbott.biz" }
|
100
|
+
let(:port) { 6654 }
|
101
|
+
let(:has_port) { true }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "red" do
|
106
|
+
it_should_behave_like "ftp named configuration" do
|
107
|
+
let(:name) { "red" }
|
108
|
+
let(:ftp_user) { "red_user" }
|
109
|
+
let(:ftp_password) { "Bun__huPEMeBreM6tebRAp@eguzuQExe" }
|
110
|
+
let(:ftp_host) { "ftp.hanerutherford.biz" }
|
111
|
+
let(:ftp_dir_raw) { "/html" }
|
112
|
+
let(:ftp_dir) { "/html" }
|
113
|
+
let(:host) { "ftp.hanerutherford.biz" }
|
114
|
+
let(:port) { 21 }
|
115
|
+
let(:has_port) { false }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "green" do
|
120
|
+
it_should_behave_like "ftp named configuration" do
|
121
|
+
let(:name) { "green" }
|
122
|
+
let(:ftp_user) { "domenick.dare" }
|
123
|
+
let(:ftp_password) { "Daw&HEWuzaz6sa&epHech_spAKucHaTH" }
|
124
|
+
let(:ftp_host) { "ftp.yundt.org" }
|
125
|
+
let(:ftp_dir_raw) { "/wordpress" }
|
126
|
+
let(:ftp_dir) { "/wordpress" }
|
127
|
+
let(:host) { "ftp.yundt.org" }
|
128
|
+
let(:port) { 21 }
|
129
|
+
let(:has_port) { false }
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "blue" do
|
134
|
+
it_should_behave_like "ftp named configuration" do
|
135
|
+
let(:name) { "blue" }
|
136
|
+
let(:ftp_user) { "harrison" }
|
137
|
+
let(:ftp_password) { "w5@reba?9?pepuk7w9a#H86ustaGawE!" }
|
138
|
+
let(:ftp_host) { "ftp.torphagenes.com" }
|
139
|
+
let(:ftp_dir_raw) { "/wordpress" }
|
140
|
+
let(:ftp_dir) { "/wordpress" }
|
141
|
+
let(:host) { "ftp.torphagenes.com" }
|
142
|
+
let(:port) { 21 }
|
143
|
+
let(:has_port) { false }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
it "has methods that allow for interactive overwrite" do
|
148
|
+
expect { subject.transmit }.to raise_error(NotImplementedError)
|
149
|
+
expect { subject.receive }.to raise_error(NotImplementedError)
|
150
|
+
end
|
151
|
+
|
152
|
+
it { should respond_to :transmit! }
|
153
|
+
it { should respond_to :receive! }
|
154
|
+
|
155
|
+
context "FTP connection" do
|
156
|
+
before(:each) do
|
157
|
+
@ftp = double("ftp")
|
158
|
+
@ftp.should_receive(:connect).with("localhost", 21)
|
159
|
+
@ftp.should_receive(:login).with("root", "q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$")
|
160
|
+
@ftp.should_receive(:passive=).with(true)
|
161
|
+
@ftp.stub(:pwd)
|
162
|
+
@ftp.stub(:closed?).and_return(false)
|
163
|
+
@ftp.stub(:close)
|
164
|
+
@ftp.stub(:chdir)
|
165
|
+
@ftp.stub(:putbinaryfile)
|
166
|
+
Net::FTP.stub(:new).and_return(@ftp)
|
167
|
+
WordpressDeploy::TransferProtocols::Ftp.any_instance.stub(:ftp).and_return(@ftp)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "with valid credentials" do
|
171
|
+
ftp = WordpressDeploy::TransferProtocols::Ftp.new("developer")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "close an open connection" do
|
175
|
+
ftp = WordpressDeploy::TransferProtocols::Ftp.new("developer")
|
176
|
+
ftp.close.should be_true
|
177
|
+
#ftp.close.should be_false
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should send files" do
|
181
|
+
files = Dir.glob(File.join(data_dir, "**/*"))
|
182
|
+
|
183
|
+
Dir.should_receive(:glob).with("/Users/ryan/Source/wordpress-deploy/spec/data/**/*").and_return(files)
|
184
|
+
|
185
|
+
ftp = WordpressDeploy::TransferProtocols::Ftp.new("developer")
|
186
|
+
|
187
|
+
ftp.should_receive(:put_file).exactly(files.count).times
|
188
|
+
|
189
|
+
ftp.transmit!
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|